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 6fa22d6f
authored
Mar 27, 2014
by
Nuno Sousa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add hstore parsing during retrieval
1 parent
93b0daa1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletions
lib/dialects/postgres/query.js
test/postgres/dao.test.js
lib/dialects/postgres/query.js
View file @
6fa22d6
...
@@ -128,6 +128,14 @@ module.exports = (function() {
...
@@ -128,6 +128,14 @@ module.exports = (function() {
})
})
}
}
// Parse hstore fields.
// This cannot be done in the 'pg' lib because hstore is a UDT.
for
(
var
key
in
rows
[
0
])
{
if
(
!!
this
.
callee
&&
!!
this
.
callee
.
rawAttributes
&&
!!
this
.
callee
.
rawAttributes
[
key
]
&&
!!
this
.
callee
.
rawAttributes
[
key
].
type
&&
this
.
callee
.
rawAttributes
[
key
].
type
.
toString
()
===
DataTypes
.
HSTORE
.
toString
())
{
rows
[
0
][
key
]
=
hstore
.
parse
(
rows
[
0
][
key
])
}
}
this
.
emit
(
'success'
,
this
.
send
(
'handleSelectQuery'
,
rows
))
this
.
emit
(
'success'
,
this
.
send
(
'handleSelectQuery'
,
rows
))
}
}
}
else
if
(
this
.
send
(
'isShowOrDescribeQuery'
))
{
}
else
if
(
this
.
send
(
'isShowOrDescribeQuery'
))
{
...
...
test/postgres/dao.test.js
View file @
6fa22d6
...
@@ -254,7 +254,7 @@ if (dialect.match(/^postgres/)) {
...
@@ -254,7 +254,7 @@ if (dialect.match(/^postgres/)) {
})
})
})
})
it
(
"should
handl
e hstore correctly"
,
function
(
done
)
{
it
(
"should
sav
e hstore correctly"
,
function
(
done
)
{
var
self
=
this
var
self
=
this
this
.
User
this
.
User
...
@@ -273,6 +273,24 @@ if (dialect.match(/^postgres/)) {
...
@@ -273,6 +273,24 @@ if (dialect.match(/^postgres/)) {
})
})
.
error
(
console
.
log
)
.
error
(
console
.
log
)
})
})
it
(
"should read hstore correctly"
,
function
(
done
)
{
var
self
=
this
var
data
=
{
username
:
'user'
,
email
:
[
'foo@bar.com'
],
settings
:
{
created
:
{
test
:
'"value"'
}}}
this
.
User
.
create
(
data
)
.
success
(
function
()
{
// Check that the hstore fields are the same when retrieving the user
self
.
User
.
find
({
where
:
{
username
:
'user'
}})
.
success
(
function
(
user
)
{
expect
(
user
.
settings
).
to
.
deep
.
equal
(
data
.
settings
)
done
()
})
})
.
error
(
console
.
log
)
})
})
})
describe
(
'[POSTGRES] Unquoted identifiers'
,
function
()
{
describe
(
'[POSTGRES] Unquoted identifiers'
,
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