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 eb8c4569
authored
May 14, 2011
by
Allan Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix where clause generation for models with explicit primary keys.
1 parent
46cfe2c4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
lib/sequelize/model.js
lib/sequelize/query.js
test/Model/update-attributes.js
lib/sequelize/model.js
View file @
eb8c456
...
...
@@ -69,7 +69,7 @@ Model.prototype.save = function() {
})
return
eventEmitter
.
run
()
}
else
{
var
identifier
=
this
.
options
.
hasPrimaryKeys
?
this
.
definition
.
primaryKey
s
:
this
.
id
var
identifier
=
this
.
options
.
hasPrimaryKeys
?
this
.
primaryKeyValue
s
:
this
.
id
return
this
.
query
(
QueryGenerator
.
updateQuery
(
this
.
definition
.
tableName
,
this
.
values
,
identifier
))
}
}
...
...
lib/sequelize/query.js
View file @
eb8c456
...
...
@@ -16,6 +16,9 @@ Query.prototype.run = function(query) {
database
:
this
.
config
.
database
})
// Save the query text for testing and debugging.
this
.
sql
=
query
if
(
this
.
options
.
logging
)
console
.
log
(
'Executing: '
+
query
)
...
...
test/Model/update-attributes.js
View file @
eb8c456
...
...
@@ -28,7 +28,7 @@ module.exports = {
})
},
'it should not set primary keys or timestamps'
:
function
(
exit
)
{
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
var
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
,
identifier
:
{
type
:
Sequelize
.
STRING
,
primaryKey
:
true
}
})
...
...
@@ -44,5 +44,18 @@ module.exports = {
})
})
})
},
"it should use the primary keys in the where clause"
:
function
(
exit
)
{
var
User
=
sequelize
.
define
(
'User'
+
config
.
rand
(),
{
name
:
Sequelize
.
STRING
,
bio
:
Sequelize
.
TEXT
,
identifier
:
{
type
:
Sequelize
.
STRING
,
primaryKey
:
true
}
})
User
.
sync
({
force
:
true
}).
on
(
'success'
,
function
()
{
User
.
create
({
name
:
'snafu'
,
identifier
:
'identifier'
}).
on
(
'success'
,
function
(
user
)
{
var
query
=
user
.
updateAttributes
({
name
:
'foobar'
})
assert
.
match
(
query
.
sql
,
/WHERE `identifier`..identifier./
)
exit
(
function
(){})
})
})
}
}
\ No newline at end of file
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