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 a1a31073
authored
Mar 23, 2015
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for newlines in hstore. Closes #3383. Also fixes an unrelated include test
1 parent
f93294de
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
5 deletions
changelog.md
lib/dialects/postgres/query.js
test/integration/dialects/postgres/dao.test.js
test/integration/include/findAndCountAll.test.js
changelog.md
View file @
a1a3107
# Next
-
[
BUG
]
Fix for newlines in hstore
[
#3383
](
https://github.com/sequelize/sequelize/issues/3383
)
# 2.0.5
# 2.0.5
-
[
FEATURE
]
Highly experimental support for nested creation
[
#3386
](
https://github.com/sequelize/sequelize/pull/3386
)
-
[
FEATURE
]
Highly experimental support for nested creation
[
#3386
](
https://github.com/sequelize/sequelize/pull/3386
)
...
...
lib/dialects/postgres/query.js
View file @
a1a3107
...
@@ -18,9 +18,15 @@ parseDialectSpecificFields = {
...
@@ -18,9 +18,15 @@ parseDialectSpecificFields = {
hstore
:
function
(
value
,
options
)
{
hstore
:
function
(
value
,
options
)
{
if
(
value
===
null
)
return
null
;
if
(
value
===
null
)
return
null
;
// hstore does not require you to escape newlines, but JSON.parse does!
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
HSTORE
)
?
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
HSTORE
)
?
Utils
.
_
.
map
(
Utils
.
_
.
map
(
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
+
']'
),
function
(
v
)
{
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
.
replace
(
'\n'
,
'\\n'
)
.
replace
(
'\t'
,
'\\t'
)
.
replace
(
'\r'
,
'\\r'
)
+
']'
),
function
(
v
)
{
return
hstore
.
parse
(
v
);
return
hstore
.
parse
(
v
);
})
:
hstore
.
parse
(
value
);
})
:
hstore
.
parse
(
value
);
},
},
...
...
test/integration/dialects/postgres/dao.test.js
View file @
a1a3107
...
@@ -540,13 +540,13 @@ if (dialect.match(/^postgres/)) {
...
@@ -540,13 +540,13 @@ if (dialect.match(/^postgres/)) {
return
this
.
User
.
create
({
return
this
.
User
.
create
({
username
:
'bob'
,
username
:
'bob'
,
email
:
[
'myemail@email.com'
],
email
:
[
'myemail@email.com'
],
phones
:
[{
number
:
'123456789'
,
type
:
'mobile'
},
{
number
:
'987654321'
,
type
:
'landline'
},
{
number
:
'8675309'
,
type
:
"Jenny's"
},
{
number
:
'5555554321'
,
type
:
'"home"'
}]
phones
:
[{
number
:
'123456789'
,
type
:
'mobile'
},
{
number
:
'987654321'
,
type
:
'landline'
},
{
number
:
'8675309'
,
type
:
"Jenny's"
},
{
number
:
'5555554321'
,
type
:
'"home
\n
"'
}]
}).
then
(
function
()
{
}).
then
(
function
()
{
return
User
.
find
(
1
).
then
(
function
(
user
)
{
return
User
.
find
(
1
).
then
(
function
(
user
)
{
expect
(
user
.
phones
.
length
).
to
.
equal
(
4
);
expect
(
user
.
phones
.
length
).
to
.
equal
(
4
);
expect
(
user
.
phones
[
1
].
number
).
to
.
equal
(
'987654321'
);
expect
(
user
.
phones
[
1
].
number
).
to
.
equal
(
'987654321'
);
expect
(
user
.
phones
[
2
].
type
).
to
.
equal
(
"Jenny's"
);
expect
(
user
.
phones
[
2
].
type
).
to
.
equal
(
"Jenny's"
);
expect
(
user
.
phones
[
3
].
type
).
to
.
equal
(
'"home"'
);
expect
(
user
.
phones
[
3
].
type
).
to
.
equal
(
'"home
\n
"'
);
});
});
});
});
});
});
...
...
test/integration/include/findAndCountAll.test.js
View file @
a1a3107
...
@@ -24,9 +24,9 @@ describe(Support.getTestDialectTeaser('Include'), function() {
...
@@ -24,9 +24,9 @@ describe(Support.getTestDialectTeaser('Include'), function() {
C
=
this
.
sequelize
.
define
(
'C'
,
{
name
:
DataTypes
.
STRING
(
40
)
},
{
paranoid
:
true
});
C
=
this
.
sequelize
.
define
(
'C'
,
{
name
:
DataTypes
.
STRING
(
40
)
},
{
paranoid
:
true
});
// Associate them
// Associate them
User
.
hasMany
(
SomeConnection
,
{
foreignKey
:
'u'
});
User
.
hasMany
(
SomeConnection
,
{
foreignKey
:
'u'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
User
,
{
foreignKey
:
'u'
});
SomeConnection
.
belongsTo
(
User
,
{
foreignKey
:
'u'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
A
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
A
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
B
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
B
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
C
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
SomeConnection
.
belongsTo
(
C
,
{
foreignKey
:
'fk'
,
constraints
:
false
});
...
...
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