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 0aba244e
authored
Apr 19, 2013
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #554 from innofluence/543fix
Fix Model.find(0)
2 parents
3580e56d
de46a5be
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
4 deletions
.travis.yml
lib/dialects/mysql/query-generator.js
lib/dialects/postgres/query-generator.js
spec/dao-factory.spec.js
.travis.yml
View file @
0aba244
...
@@ -19,4 +19,5 @@ env:
...
@@ -19,4 +19,5 @@ env:
language
:
node_js
language
:
node_js
node_js
:
node_js
:
-
0.8
-
0.8
\ No newline at end of file
\ No newline at end of file
lib/dialects/mysql/query-generator.js
View file @
0aba244
...
@@ -155,7 +155,7 @@ module.exports = (function() {
...
@@ -155,7 +155,7 @@ module.exports = (function() {
options
.
attributes
=
optAttributes
.
join
(
', '
)
options
.
attributes
=
optAttributes
.
join
(
', '
)
}
}
if
(
options
.
where
)
{
if
(
options
.
hasOwnProperty
(
'where'
)
)
{
options
.
where
=
this
.
getWhereConditions
(
options
.
where
,
tableName
)
options
.
where
=
this
.
getWhereConditions
(
options
.
where
,
tableName
)
query
+=
" WHERE <%= where %>"
query
+=
" WHERE <%= where %>"
}
}
...
...
lib/dialects/postgres/query-generator.js
View file @
0aba244
...
@@ -224,7 +224,7 @@ module.exports = (function() {
...
@@ -224,7 +224,7 @@ module.exports = (function() {
options
.
attributes
=
optAttributes
.
join
(
', '
)
options
.
attributes
=
optAttributes
.
join
(
', '
)
}
}
if
(
options
.
where
)
{
if
(
options
.
hasOwnProperty
(
'where'
)
)
{
options
.
where
=
QueryGenerator
.
getWhereConditions
(
options
.
where
)
options
.
where
=
QueryGenerator
.
getWhereConditions
(
options
.
where
)
query
+=
" WHERE <%= where %>"
query
+=
" WHERE <%= where %>"
}
}
...
...
spec/dao-factory.spec.js
View file @
0aba244
...
@@ -2,6 +2,7 @@ if(typeof require === 'function') {
...
@@ -2,6 +2,7 @@ if(typeof require === 'function') {
const
buster
=
require
(
"buster"
)
const
buster
=
require
(
"buster"
)
,
Sequelize
=
require
(
"../index"
)
,
Sequelize
=
require
(
"../index"
)
,
Helpers
=
require
(
'./buster-helpers'
)
,
Helpers
=
require
(
'./buster-helpers'
)
,
_
=
require
(
'underscore'
)
,
dialect
=
Helpers
.
getTestDialect
()
,
dialect
=
Helpers
.
getTestDialect
()
}
}
...
@@ -486,6 +487,31 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
...
@@ -486,6 +487,31 @@ describe(Helpers.getTestDialectTeaser("DAOFactory"), function() {
}.
bind
(
this
))
}.
bind
(
this
))
})
})
it
(
'always honors ZERO as primary key'
,
function
(
_done
)
{
var
permutations
=
[
0
,
'0'
,
{
where
:
{
id
:
0
}},
{
where
:
{
id
:
'0'
}}
]
,
done
=
_
.
after
(
2
*
permutations
.
length
,
_done
);
this
.
User
.
create
({
name
:
'jack'
}).
success
(
function
(
jack
)
{
this
.
User
.
create
({
name
:
'jill'
}).
success
(
function
(
jill
)
{
permutations
.
forEach
(
function
(
perm
)
{
this
.
User
.
find
(
perm
).
done
(
function
(
err
,
user
)
{
expect
(
err
).
toBeNull
();
expect
(
user
).
toBeNull
();
done
();
}).
on
(
'sql'
,
function
(
s
)
{
expect
(
s
.
indexOf
(
0
)).
not
.
toEqual
(
-
1
);
done
();
})
}.
bind
(
this
))
}.
bind
(
this
))
}.
bind
(
this
))
})
describe
(
'eager loading'
,
function
()
{
describe
(
'eager loading'
,
function
()
{
before
(
function
()
{
before
(
function
()
{
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
Sequelize
.
STRING
})
this
.
Task
=
this
.
sequelize
.
define
(
'Task'
,
{
title
:
Sequelize
.
STRING
})
...
...
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