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 750817c5
authored
May 03, 2013
by
Daniel Durante
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
git://github.com/wyplay/sequelize
into wyplay-master
2 parents
c78b7396
773b2b6c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
17 deletions
changelog.md
lib/sequelize.js
lib/sql-string.js
lib/utils.js
changelog.md
View file @
750817c
# v1.7.0 #
-
[
BUG
]
Fix string escape with postgresql on raw SQL queries/
[
#586
](
https://github.com/sequelize/sequelize/pull/586
)
. thanks to zanamixx
-
[
BUG
]
"order by" is now after "group by".
[
#585
](
https://github.com/sequelize/sequelize/pull/585
)
. thanks to mekanics
-
[
BUG
]
Added decimal support for min/max.
[
#583
](
https://github.com/sequelize/sequelize/pull/583
)
. thanks to durango
-
[
FEATURE
]
Schematics.
[
#564
](
https://github.com/sequelize/sequelize/pull/564
)
. thanks to durango
...
...
lib/sequelize.js
View file @
750817c
...
...
@@ -202,7 +202,7 @@ module.exports = (function() {
Sequelize
.
prototype
.
query
=
function
(
sql
,
callee
,
options
,
replacements
)
{
if
(
arguments
.
length
===
4
)
{
sql
=
Utils
.
format
([
sql
].
concat
(
replacements
))
sql
=
Utils
.
format
([
sql
].
concat
(
replacements
)
,
this
.
options
.
dialect
)
}
else
if
(
arguments
.
length
===
3
)
{
options
=
options
}
else
if
(
arguments
.
length
===
2
)
{
...
...
lib/sql-string.js
View file @
750817c
...
...
@@ -7,7 +7,7 @@ SqlString.escapeId = function (val, forbidQualified) {
return
'`'
+
val
.
replace
(
/`/g
,
'``'
).
replace
(
/
\.
/g
,
'`.`'
)
+
'`'
;
};
SqlString
.
escape
=
function
(
val
,
stringifyObjects
,
timeZone
)
{
SqlString
.
escape
=
function
(
val
,
stringifyObjects
,
timeZone
,
dialect
)
{
if
(
val
===
undefined
||
val
===
null
)
{
return
'NULL'
;
}
...
...
@@ -37,17 +37,22 @@ SqlString.escape = function(val, stringifyObjects, timeZone) {
}
}
val
=
val
.
replace
(
/
[\0\n\r\b\t\\\'\"\x
1a
]
/g
,
function
(
s
)
{
switch
(
s
)
{
case
"\0"
:
return
"\\0"
;
case
"\n"
:
return
"\\n"
;
case
"\r"
:
return
"\\r"
;
case
"\b"
:
return
"\\b"
;
case
"\t"
:
return
"\\t"
;
case
"\x1a"
:
return
"\\Z"
;
default
:
return
"\\"
+
s
;
}
});
if
(
dialect
==
"postgres"
)
{
// http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS
val
=
val
.
replace
(
/'/g
,
"''"
);
}
else
{
val
=
val
.
replace
(
/
[\0\n\r\b\t\\\'\"\x
1a
]
/g
,
function
(
s
)
{
switch
(
s
)
{
case
"\0"
:
return
"\\0"
;
case
"\n"
:
return
"\\n"
;
case
"\r"
:
return
"\\r"
;
case
"\b"
:
return
"\\b"
;
case
"\t"
:
return
"\\t"
;
case
"\x1a"
:
return
"\\Z"
;
default
:
return
"\\"
+
s
;
}
});
}
return
"'"
+
val
+
"'"
;
};
...
...
@@ -58,7 +63,7 @@ SqlString.arrayToList = function(array, timeZone) {
}).
join
(
', '
);
};
SqlString
.
format
=
function
(
sql
,
values
,
timeZone
)
{
SqlString
.
format
=
function
(
sql
,
values
,
timeZone
,
dialect
)
{
values
=
[].
concat
(
values
);
return
sql
.
replace
(
/
\?
/g
,
function
(
match
)
{
...
...
@@ -66,7 +71,7 @@ SqlString.format = function(sql, values, timeZone) {
return
match
;
}
return
SqlString
.
escape
(
values
.
shift
(),
false
,
timeZone
);
return
SqlString
.
escape
(
values
.
shift
(),
false
,
timeZone
,
dialect
);
});
};
...
...
lib/utils.js
View file @
750817c
...
...
@@ -47,8 +47,9 @@ var Utils = module.exports = {
escape
:
function
(
s
)
{
return
SqlString
.
escape
(
s
,
true
,
"local"
).
replace
(
/
\\
"/g
,
'"'
)
},
format
:
function
(
arr
)
{
return
SqlString
.
format
(
arr
.
shift
(),
arr
)
format
:
function
(
arr
,
dialect
)
{
var
timeZone
=
null
;
return
SqlString
.
format
(
arr
.
shift
(),
arr
,
timeZone
,
dialect
)
},
isHash
:
function
(
obj
)
{
return
Utils
.
_
.
isObject
(
obj
)
&&
!
Array
.
isArray
(
obj
);
...
...
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