(sql, values, timeZone, dialect)
| 161 | exports.escape = escape; |
| 162 | |
| 163 | function format(sql, values, timeZone, dialect) { |
| 164 | values = [].concat(values); |
| 165 | |
| 166 | if (typeof sql !== 'string') { |
| 167 | throw new Error(`Invalid SQL string provided: ${sql}`); |
| 168 | } |
| 169 | |
| 170 | return sql.replace(/\?/g, match => { |
| 171 | if (!values.length) { |
| 172 | return match; |
| 173 | } |
| 174 | |
| 175 | return escape(values.shift(), timeZone, dialect, true); |
| 176 | }); |
| 177 | } |
| 178 | exports.format = format; |
| 179 | |
| 180 | function formatNamedParameters(sql, values, timeZone, dialect) { |