@@ -96,37 +96,35 @@ export function handleValue(x, parameters, types, options) {
96
96
97
97
const defaultHandlers = typeHandlers ( types )
98
98
99
- export function stringify ( q , string , value , parameters , types , o ) { // eslint-disable-line
99
+ export function stringify ( q , string , value , parameters , types , options ) { // eslint-disable-line
100
100
for ( let i = 1 ; i < q . strings . length ; i ++ ) {
101
- string += (
102
- value && value [ 0 ] instanceof Query ? value . reduce ( ( acc , x ) => acc + ' ' + fragment ( x , parameters , types , o ) , '' ) :
103
- value instanceof Query ? fragment ( value , parameters , types , o ) :
104
- value instanceof Identifier ? value . value :
105
- value instanceof Builder ? value . build ( string , parameters , types , o ) :
106
- handleValue ( value , parameters , types , o )
107
- ) + q . strings [ i ]
101
+ string += ( stringifyValue ( string , value , parameters , types , options ) ) + q . strings [ i ]
108
102
value = q . args [ i ]
109
103
}
110
104
111
105
return string
112
106
}
113
107
108
+ function stringifyValue ( string , value , parameters , types , o ) {
109
+ return (
110
+ value instanceof Builder ? value . build ( string , parameters , types , o ) :
111
+ value instanceof Query ? fragment ( value , parameters , types , o ) :
112
+ value instanceof Identifier ? value . value :
113
+ value && value [ 0 ] instanceof Query ? value . reduce ( ( acc , x ) => acc + ' ' + fragment ( x , parameters , types , o ) , '' ) :
114
+ handleValue ( value , parameters , types , o )
115
+ )
116
+ }
117
+
114
118
function fragment ( q , parameters , types , options ) {
115
119
q . fragment = true
116
120
return stringify ( q , q . strings [ 0 ] , q . args [ 0 ] , parameters , types , options )
117
121
}
118
122
119
123
function valuesBuilder ( first , parameters , types , columns , options ) {
120
- let value
121
124
return first . map ( row =>
122
- '(' + columns . map ( column => {
123
- value = row [ column ]
124
- return (
125
- value instanceof Query ? fragment ( value , parameters , types ) :
126
- value instanceof Identifier ? value . value :
127
- handleValue ( value , parameters , types , options )
128
- )
129
- } ) . join ( ',' ) + ')'
125
+ '(' + columns . map ( column =>
126
+ stringifyValue ( 'values' , row [ column ] , parameters , types , options )
127
+ ) . join ( ',' ) + ')'
130
128
) . join ( ',' )
131
129
}
132
130
@@ -146,7 +144,7 @@ function select(first, rest, parameters, types, options) {
146
144
return columns . map ( x => {
147
145
value = first [ x ]
148
146
return (
149
- value instanceof Query ? fragment ( value , parameters , types ) :
147
+ value instanceof Query ? fragment ( value , parameters , types , options ) :
150
148
value instanceof Identifier ? value . value :
151
149
handleValue ( value , parameters , types , options )
152
150
) + ' as ' + escapeIdentifier ( options . transform . column . to ? options . transform . column . to ( x ) : x )
0 commit comments