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 ae9260ff
authored
Apr 19, 2014
by
Nuno Sousa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix postgres casting conflict in named parameters
1 parent
8c678a7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletions
lib/sql-string.js
test/sequelize.test.js
lib/sql-string.js
View file @
ae9260f
...
@@ -143,7 +143,11 @@ SqlString.format = function(sql, values, timeZone, dialect) {
...
@@ -143,7 +143,11 @@ SqlString.format = function(sql, values, timeZone, dialect) {
}
}
SqlString
.
formatNamedParameters
=
function
(
sql
,
values
,
timeZone
,
dialect
)
{
SqlString
.
formatNamedParameters
=
function
(
sql
,
values
,
timeZone
,
dialect
)
{
return
sql
.
replace
(
/
\:(?!\d)(\w
+
)
/g
,
function
(
value
,
key
)
{
return
sql
.
replace
(
/
\:
+
(?!\d)(\w
+
)
/g
,
function
(
value
,
key
)
{
if
(
'postgres'
===
dialect
&&
'::'
===
value
.
slice
(
0
,
2
))
{
return
value
}
if
(
values
.
hasOwnProperty
(
key
))
{
if
(
values
.
hasOwnProperty
(
key
))
{
return
SqlString
.
escape
(
values
[
key
],
false
,
timeZone
,
dialect
)
return
SqlString
.
escape
(
values
[
key
],
false
,
timeZone
,
dialect
)
}
else
{
}
else
{
...
...
test/sequelize.test.js
View file @
ae9260f
...
@@ -390,6 +390,13 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
...
@@ -390,6 +390,13 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
})
})
if
(
Support
.
getTestDialect
()
===
'postgres'
)
{
if
(
Support
.
getTestDialect
()
===
'postgres'
)
{
it
(
'replaces named parameters with the passed object and ignores casts'
,
function
(
done
)
{
this
.
sequelize
.
query
(
'select :one as foo, :two as bar, \'1000\'::integer as baz'
,
null
,
{
raw
:
true
},
{
one
:
1
,
two
:
2
}).
success
(
function
(
result
)
{
expect
(
result
).
to
.
deep
.
equal
([{
foo
:
1
,
bar
:
2
,
baz
:
1000
}])
done
()
})
})
it
(
'supports WITH queries'
,
function
(
done
)
{
it
(
'supports WITH queries'
,
function
(
done
)
{
this
this
.
sequelize
.
sequelize
...
...
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