-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow sql tokens as values of valueList, tuple and tupleList
- Loading branch information
Showing
13 changed files
with
336 additions
and
65 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// @flow | ||
|
||
import { | ||
ArrayTokenSymbol, | ||
SqlTokenSymbol, | ||
RawSqlTokenSymbol, | ||
IdentifierTokenSymbol, | ||
IdentifierListTokenSymbol, | ||
ValueListTokenSymbol, | ||
TupleTokenSymbol, | ||
TupleListTokenSymbol, | ||
UnnestTokenSymbol | ||
} from '../symbols'; | ||
import { | ||
createArraySqlFragment, | ||
createIdentifierSqlFragment, | ||
createIdentifierListSqlFragment, | ||
createRawSqlSqlFragment, | ||
createSqlSqlFragment, | ||
createTupleListSqlFragment, | ||
createTupleSqlFragment, | ||
createUnnestSqlFragment, | ||
createValueListSqlFragment | ||
} from '../sqlFragmentFactories'; | ||
import { | ||
UnexpectedStateError | ||
} from '../errors'; | ||
import type { | ||
SqlTokenType, | ||
SqlFragmentType | ||
} from '../types'; | ||
|
||
export default (token: SqlTokenType, greatestParameterPosition: number): SqlFragmentType => { | ||
if (token.type === SqlTokenSymbol) { | ||
// @see https://github.com/gajus/slonik/issues/36 regarding FlowFixMe use. | ||
// $FlowFixMe | ||
return createSqlSqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === RawSqlTokenSymbol) { | ||
// $FlowFixMe | ||
return createRawSqlSqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === IdentifierTokenSymbol) { | ||
// $FlowFixMe | ||
return createIdentifierSqlFragment(token); | ||
} else if (token.type === IdentifierListTokenSymbol) { | ||
// $FlowFixMe | ||
return createIdentifierListSqlFragment(token); | ||
} else if (token.type === ArrayTokenSymbol) { | ||
// $FlowFixMe | ||
return createArraySqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === ValueListTokenSymbol) { | ||
// $FlowFixMe | ||
return createValueListSqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === TupleTokenSymbol) { | ||
// $FlowFixMe | ||
return createTupleSqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === TupleListTokenSymbol) { | ||
// $FlowFixMe | ||
return createTupleListSqlFragment(token, greatestParameterPosition); | ||
} else if (token.type === UnnestTokenSymbol) { | ||
// $FlowFixMe | ||
return createUnnestSqlFragment(token, greatestParameterPosition); | ||
} | ||
|
||
throw new UnexpectedStateError(); | ||
}; |
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 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.