Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make sql template tagged literal a stand-alone function
BREAKING CHANGE: connection.query and other methods are no longer allowed to be called as template literals. Use “sql” import to construct the query input.
- Loading branch information
Showing
5 changed files
with
52 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
// @flow | ||
|
||
// eslint-disable-next-line flowtype/no-weak-types | ||
export default (targetMethod: Function) => { | ||
// eslint-disable-next-line flowtype/no-weak-types | ||
return (maybeQuery: string | Array<string>, ...args: any) => { | ||
import type { | ||
DatabaseQueryValuesType, | ||
TaggledTemplateLiteralInvocationType | ||
} from '../types'; | ||
|
||
export default (targetMethod: *) => { | ||
return (maybeQuery: string | TaggledTemplateLiteralInvocationType, values?: DatabaseQueryValuesType) => { | ||
if (typeof maybeQuery === 'string') { | ||
return targetMethod(maybeQuery, args[0]); | ||
return targetMethod(maybeQuery, values); | ||
} else { | ||
const strings = maybeQuery; | ||
|
||
return targetMethod(strings.join('?'), args); | ||
return targetMethod(maybeQuery.sql, maybeQuery.values); | ||
} | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.