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 ffc8030e
authored
Jul 28, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Smart where object will no longer try to handle NULLs (as Sequelize currently do…
…esn't support it as-is).
1 parent
5b617de1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
lib/utils.js
test/dao-factory.test.js
lib/utils.js
View file @
ffc8030
...
...
@@ -88,9 +88,12 @@ var Utils = module.exports = {
type
=
typeof
where
[
i
]
_where
[
i
]
=
_where
[
i
]
||
{}
if
(
Array
.
isArray
(
where
[
i
]))
{
if
(
where
[
i
]
===
null
)
{
// skip nulls
}
else
if
(
Array
.
isArray
(
where
[
i
]))
{
_where
[
i
].
in
=
_where
[
i
].
in
||
[]
_where
[
i
].
in
.
concat
(
where
[
i
])
;
_where
[
i
].
in
.
concat
(
where
[
i
])
}
else
if
(
type
===
"object"
)
{
Object
.
keys
(
where
[
i
]).
forEach
(
function
(
ii
)
{
...
...
test/dao-factory.test.js
View file @
ffc8030
...
...
@@ -907,7 +907,7 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
describe
(
'special where conditions'
,
function
()
{
describe
(
'special where conditions
/smartWhere object
'
,
function
()
{
beforeEach
(
function
(
done
)
{
var
self
=
this
...
...
@@ -919,6 +919,45 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
it
(
'should be able to retun a record with primaryKey being null for new inserts'
,
function
(
done
)
{
var
Session
=
this
.
sequelize
.
define
(
'Session'
,
{
token
:
{
type
:
DataTypes
.
TEXT
,
allowNull
:
false
},
lastUpdate
:
{
type
:
DataTypes
.
DATE
,
allowNull
:
false
}
},
{
charset
:
'utf8'
,
collate
:
'utf8_general_ci'
,
omitNull
:
true
})
,
User
=
this
.
sequelize
.
define
(
'User'
,
{
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
,
unique
:
true
},
password
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
false
},
isAdmin
:
{
type
:
DataTypes
.
BOOLEAN
,
allowNull
:
false
,
defaultValue
:
false
}
},
{
charset
:
'utf8'
,
collate
:
'utf8_general_ci'
})
User
.
hasMany
(
Session
,
{
as
:
'Sessions'
})
Session
.
belongsTo
(
User
)
Session
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
sync
({
force
:
true
}).
success
(
function
()
{
User
.
create
({
name
:
'Name1'
,
password
:
'123'
,
isAdmin
:
false
}).
success
(
function
(
user
)
{
var
sess
=
Session
.
build
({
lastUpdate
:
new
Date
(),
token
:
'123'
})
user
.
addSession
(
sess
).
success
(
function
(
u
)
{
expect
(
u
.
token
).
to
.
equal
(
'123'
)
done
()
})
})
})
})
})
it
(
'should be able to find a row between a certain date'
,
function
(
done
)
{
this
.
User
.
findAll
({
where
:
{
...
...
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