-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ba0ed5
commit 79ee783
Showing
15 changed files
with
18,764 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import {EncodeTextFunction, FetchOptions} from '../definitions'; | ||
import {escapeLiteral} from './escape-literal'; | ||
|
||
export function stringifyArrayForSQL(v: any[], options?: FetchOptions, encode?: EncodeTextFunction): string { | ||
const arr = v.map(x => stringifyValueForSQL(x, options, encode)); | ||
return 'ARRAY[' + arr.join(',') + ']'; | ||
} | ||
|
||
export function stringifyValueForSQL(v: any, options?: FetchOptions, encode?: EncodeTextFunction): string { | ||
if (v == null) | ||
return 'null'; | ||
if (typeof v === 'boolean') | ||
return v ? 'true' : 'false'; | ||
if (Array.isArray(v)) | ||
return stringifyArrayForSQL(v, options, encode); | ||
if (encode) | ||
v = encode(v, options || {}); | ||
if (typeof v === 'number') | ||
return '' + v; | ||
if (typeof v === 'bigint') | ||
return v.toString(); | ||
if (typeof v === 'object') | ||
return escapeLiteral(JSON.stringify(v)); | ||
return escapeLiteral('' + v); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.