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 1175b39e
authored
Feb 04, 2014
by
Dan Kohn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1344 honor unique false
1 parent
cec519bf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletions
lib/dao-factory.js
test/dao-factory.test.js
lib/dao-factory.js
View file @
1175b39
...
@@ -121,7 +121,7 @@ module.exports = (function() {
...
@@ -121,7 +121,7 @@ module.exports = (function() {
self
.
options
.
uniqueKeys
=
{}
self
.
options
.
uniqueKeys
=
{}
Utils
.
_
.
each
(
this
.
rawAttributes
,
function
(
columnValues
,
columnName
)
{
Utils
.
_
.
each
(
this
.
rawAttributes
,
function
(
columnValues
,
columnName
)
{
if
(
columnValues
.
hasOwnProperty
(
'unique'
)
&&
columnValues
.
unique
!==
true
)
{
if
(
columnValues
.
hasOwnProperty
(
'unique'
)
&&
columnValues
.
unique
!==
true
&&
columnValues
.
unique
!==
false
)
{
var
idxName
=
columnValues
.
unique
var
idxName
=
columnValues
.
unique
if
(
typeof
columnValues
.
unique
===
"object"
)
{
if
(
typeof
columnValues
.
unique
===
"object"
)
{
idxName
=
columnValues
.
unique
.
name
idxName
=
columnValues
.
unique
.
name
...
...
test/dao-factory.test.js
View file @
1175b39
...
@@ -1968,4 +1968,42 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1968,4 +1968,42 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
describe
(
'Unique'
,
function
()
{
it
(
"should set unique when unique is true"
,
function
(
done
)
{
var
self
=
this
var
uniqueTrue
=
self
.
sequelize
.
define
(
'uniqueTrue'
,
{
str
:
{
type
:
Sequelize
.
STRING
,
unique
:
true
}
})
uniqueTrue
.
sync
({
force
:
true
}).
on
(
'sql'
,
function
(
s
)
{
expect
(
s
).
to
.
match
(
/UNIQUE/
)
done
()
})
})
it
(
"should not set unique when unique is false"
,
function
(
done
)
{
var
self
=
this
var
uniqueFalse
=
self
.
sequelize
.
define
(
'uniqueFalse'
,
{
str
:
{
type
:
Sequelize
.
STRING
,
unique
:
false
}
})
uniqueFalse
.
sync
({
force
:
true
}).
on
(
'sql'
,
function
(
s
)
{
expect
(
s
).
not
.
to
.
match
(
/UNIQUE/
)
done
()
})
})
it
(
"should not set unique when unique is unset"
,
function
(
done
)
{
var
self
=
this
var
uniqueUnset
=
self
.
sequelize
.
define
(
'uniqueUnset'
,
{
str
:
{
type
:
Sequelize
.
STRING
}
})
uniqueUnset
.
sync
({
force
:
true
}).
on
(
'sql'
,
function
(
s
)
{
expect
(
s
).
not
.
to
.
match
(
/UNIQUE/
)
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