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 9c53f5a7
authored
Jan 11, 2014
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #1234 - Postgres query should set on .dataValues instead of object directly
1 parent
20cf37f7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
lib/dialects/postgres/query.js
test/dao/values.test.js
lib/dialects/postgres/query.js
View file @
9c53f5a
...
@@ -139,7 +139,7 @@ module.exports = (function() {
...
@@ -139,7 +139,7 @@ module.exports = (function() {
if
(
!!
this
.
callee
.
daoFactory
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
]
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
&&
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
===
DataTypes
.
HSTORE
.
type
)
{
if
(
!!
this
.
callee
.
daoFactory
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
]
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
&&
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
===
DataTypes
.
HSTORE
.
type
)
{
record
=
hstore
.
parse
(
record
)
record
=
hstore
.
parse
(
record
)
}
}
this
.
callee
[
key
]
=
record
this
.
callee
.
dataValues
[
key
]
=
record
}
}
}
}
}
}
...
@@ -152,7 +152,7 @@ module.exports = (function() {
...
@@ -152,7 +152,7 @@ module.exports = (function() {
if
(
!!
this
.
callee
.
daoFactory
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
]
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
&&
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
===
DataTypes
.
HSTORE
.
type
)
{
if
(
!!
this
.
callee
.
daoFactory
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
]
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
&&
!!
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
&&
this
.
callee
.
daoFactory
.
rawAttributes
[
key
].
type
.
type
===
DataTypes
.
HSTORE
.
type
)
{
record
=
hstore
.
parse
(
record
)
record
=
hstore
.
parse
(
record
)
}
}
this
.
callee
[
key
]
=
record
this
.
callee
.
dataValues
[
key
]
=
record
}
}
}
}
}
}
...
...
test/dao/values.test.js
View file @
9c53f5a
...
@@ -193,6 +193,40 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
...
@@ -193,6 +193,40 @@ describe(Support.getTestDialectTeaser("DAO"), function () {
})
})
expect
(
product
.
toJSON
()).
to
.
deep
.
equal
({
withTaxes
:
1250
,
price
:
1000
,
id
:
null
})
expect
(
product
.
toJSON
()).
to
.
deep
.
equal
({
withTaxes
:
1250
,
price
:
1000
,
id
:
null
})
})
})
it
(
'should work with save'
,
function
(
done
)
{
var
Contact
=
this
.
sequelize
.
define
(
'Contact'
,
{
first
:
{
type
:
Sequelize
.
STRING
},
last
:
{
type
:
Sequelize
.
STRING
},
tags
:
{
type
:
Sequelize
.
STRING
,
get
:
function
(
field
)
{
var
val
=
this
.
getDataValue
(
field
);
return
JSON
.
parse
(
val
);
},
set
:
function
(
val
,
field
)
{
this
.
setDataValue
(
field
,
JSON
.
stringify
(
val
));
}
}
});
this
.
sequelize
.
sync
().
done
(
function
()
{
var
contact
=
Contact
.
build
({
first
:
'My'
,
last
:
'Name'
,
tags
:
[
'yes'
,
'no'
]
});
expect
(
contact
.
get
(
'tags'
)).
to
.
deep
.
equal
([
'yes'
,
'no'
])
contact
.
save
().
done
(
function
(
err
,
me
)
{
expect
(
err
).
not
.
to
.
be
.
ok
var
idToTest
=
me
.
id
;
expect
(
me
.
get
(
'tags'
)).
to
.
deep
.
equal
([
'yes'
,
'no'
])
done
();
});
});
})
})
})
describe
(
'changed'
,
function
()
{
describe
(
'changed'
,
function
()
{
...
...
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