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 0f3b6f26
authored
Sep 06, 2013
by
Jan Scheurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow SqlString.arrayToList method to process typed arrays
1 parent
5025a3ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
lib/sql-string.js
lib/sql-string.js
View file @
0f3b6f2
...
@@ -62,8 +62,7 @@ SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
...
@@ -62,8 +62,7 @@ SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
if
(
Buffer
.
isBuffer
(
val
))
{
if
(
Buffer
.
isBuffer
(
val
))
{
return
SqlString
.
bufferToString
(
val
,
dialect
);
return
SqlString
.
bufferToString
(
val
,
dialect
);
}
}
if
(
Array
.
isArray
(
val
)
||
isArrayBufferView
(
val
))
{
if
(
Array
.
isArray
(
val
))
{
return
SqlString
.
arrayToList
(
val
,
timeZone
,
dialect
,
field
);
return
SqlString
.
arrayToList
(
val
,
timeZone
,
dialect
,
field
);
}
}
...
@@ -97,19 +96,36 @@ SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
...
@@ -97,19 +96,36 @@ SqlString.escape = function(val, stringifyObjects, timeZone, dialect, field) {
SqlString
.
arrayToList
=
function
(
array
,
timeZone
,
dialect
,
field
)
{
SqlString
.
arrayToList
=
function
(
array
,
timeZone
,
dialect
,
field
)
{
if
(
dialect
===
'postgres'
)
{
if
(
dialect
===
'postgres'
)
{
var
ret
=
'ARRAY['
+
array
.
map
(
function
(
v
)
{
if
(
array
.
map
)
{
return
SqlString
.
escape
(
v
,
true
,
timeZone
,
dialect
,
field
);
var
valstr
=
array
.
map
(
function
(
v
)
{
}).
join
(
','
)
+
']'
;
return
SqlString
.
escape
(
v
,
true
,
timeZone
,
dialect
,
field
);
}).
join
(
','
);
}
else
{
var
valstr
=
""
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
valstr
+=
SqlString
.
escape
(
array
[
i
],
true
,
timeZone
,
dialect
,
field
)
+
','
;
}
valstr
=
valstr
.
slice
(
0
,
-
1
);
}
var
ret
=
'ARRAY['
+
valstr
+
']'
;
if
(
!!
field
&&
!!
field
.
type
)
{
if
(
!!
field
&&
!!
field
.
type
)
{
ret
+=
'::'
+
field
.
type
.
replace
(
/
\(\d
+
\)
/g
,
''
);
ret
+=
'::'
+
field
.
type
.
replace
(
/
\(\d
+
\)
/g
,
''
);
}
}
return
ret
;
return
ret
;
}
else
{
}
else
{
return
array
.
map
(
function
(
v
)
{
if
(
array
.
map
)
{
if
(
Array
.
isArray
(
v
))
return
array
.
map
(
function
(
v
)
{
return
'('
+
SqlString
.
arrayToList
(
v
,
timeZone
,
dialect
)
+
')'
;
if
(
Array
.
isArray
(
v
))
return
SqlString
.
escape
(
v
,
true
,
timeZone
,
dialect
);
return
'('
+
SqlString
.
arrayToList
(
v
,
timeZone
,
dialect
)
+
')'
;
}).
join
(
', '
);
return
SqlString
.
escape
(
v
,
true
,
timeZone
,
dialect
);
}).
join
(
', '
);
}
else
{
var
valstr
=
""
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
valstr
+=
SqlString
.
escape
(
array
[
i
],
true
,
timeZone
,
dialect
)
+
', '
;
}
return
valstr
.
slice
(
0
,
-
2
);
}
}
}
};
};
...
...
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