-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make compatible with the latest Slonik
- Loading branch information
Showing
10 changed files
with
111 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// @flow | ||
|
||
import type { | ||
ValueExpressionType, | ||
} from 'slonik'; | ||
|
||
export type NamedAssignmentPayloadType = { | ||
[key: string]: ValueExpressionType, | ||
..., | ||
}; |
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,24 @@ | ||
// @flow | ||
|
||
import { | ||
sql, | ||
} from 'slonik'; | ||
import type { | ||
ListSqlTokenType, | ||
} from 'slonik'; | ||
import type { | ||
NamedAssignmentPayloadType, | ||
} from '../types'; | ||
import normalizeIdentifier from './normalizeIdentifier'; | ||
|
||
export default (namedAssignment: NamedAssignmentPayloadType): ListSqlTokenType => { | ||
const values = Object.values(Object | ||
.entries(namedAssignment) | ||
.map(([column, value]) => { | ||
// $FlowFixMe | ||
return sql`${sql.identifier([normalizeIdentifier(column)])} = ${value}`; | ||
})); | ||
|
||
// $FlowFixMe | ||
return sql.join(values, sql`, `); | ||
}; |
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,3 +1,4 @@ | ||
// @flow | ||
|
||
export {default as escapeIdentifier} from './escapeIdentifier'; | ||
export {default as assignmentList} from './assignmentList'; | ||
export {default as normalizeIdentifier} from './normalizeIdentifier'; |
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,9 @@ | ||
// @flow | ||
|
||
import { | ||
snakeCase, | ||
} from 'lodash'; | ||
|
||
export default (propertyName: string): string => { | ||
return snakeCase(propertyName); | ||
}; |
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.