Skip to content

Commit

Permalink
fix: use consistent SqlTokenType suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Aug 4, 2019
1 parent aa0f31e commit 43085ea
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 47 deletions.
12 changes: 6 additions & 6 deletions .README/QUERY_BUILDING.md
Expand Up @@ -298,7 +298,7 @@ Produces:
```js
(
names: $ReadOnlyArray<string>
) => IdentifierTokenType;
) => IdentifierSqlTokenType;

```

Expand Down Expand Up @@ -327,7 +327,7 @@ Produces:
```js
(
identifiers: $ReadOnlyArray<$ReadOnlyArray<string>>
) => IdentifierListTokenType;
) => IdentifierListSqlTokenType;

```

Expand Down Expand Up @@ -496,7 +496,7 @@ Named parameters are matched using `/[\s,(]:([a-z_]+)/g` regex.
(
members: $ReadOnlyArray<ValueExpressionType>,
operator: LogicalBooleanOperatorType
) => BooleanExpressionTokenType;
) => BooleanExpressionSqlTokenType;

```

Expand Down Expand Up @@ -560,7 +560,7 @@ Note: Do not use `sql.booleanExpression` when expression consists of a single pr
leftOperand: ValueExpressionType,
operator: ComparisonOperatorType,
rightOperand: ValueExpressionType
) => ComparisonPredicateTokenType;
) => ComparisonPredicateSqlTokenType;

```

Expand Down Expand Up @@ -612,7 +612,7 @@ Produces:
```js
(
namedAssignmentValueBindings: NamedAssignmentType
) => AssignmentListTokenType
) => AssignmentListSqlTokenType

```

Expand Down Expand Up @@ -729,7 +729,7 @@ With this configuration, the earlier code example produces:
```js
(
value: SerializableValueType
) => JsonTokenType;
) => JsonSqlTokenType;

```

Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -1433,7 +1433,7 @@ Produces:
```js
(
names: $ReadOnlyArray<string>
) => IdentifierTokenType;
) => IdentifierSqlTokenType;

```
Expand Down Expand Up @@ -1463,7 +1463,7 @@ Produces:
```js
(
identifiers: $ReadOnlyArray<$ReadOnlyArray<string>>
) => IdentifierListTokenType;
) => IdentifierListSqlTokenType;

```
Expand Down Expand Up @@ -1637,7 +1637,7 @@ Named parameters are matched using `/[\s,(]:([a-z_]+)/g` regex.
(
members: $ReadOnlyArray<ValueExpressionType>,
operator: LogicalBooleanOperatorType
) => BooleanExpressionTokenType;
) => BooleanExpressionSqlTokenType;

```
Expand Down Expand Up @@ -1702,7 +1702,7 @@ Note: Do not use `sql.booleanExpression` when expression consists of a single pr
leftOperand: ValueExpressionType,
operator: ComparisonOperatorType,
rightOperand: ValueExpressionType
) => ComparisonPredicateTokenType;
) => ComparisonPredicateSqlTokenType;

```
Expand Down Expand Up @@ -1755,7 +1755,7 @@ Produces:
```js
(
namedAssignmentValueBindings: NamedAssignmentType
) => AssignmentListTokenType
) => AssignmentListSqlTokenType

```
Expand Down
20 changes: 10 additions & 10 deletions src/factories/createSqlTag.js
Expand Up @@ -2,14 +2,14 @@

import type {
ArraySqlTokenType,
AssignmentListTokenType,
BooleanExpressionTokenType,
AssignmentListSqlTokenType,
BooleanExpressionSqlTokenType,
ComparisonOperatorType,
ComparisonPredicateTokenType,
ComparisonPredicateSqlTokenType,
IdentifierListMemberType,
IdentifierListTokenType,
IdentifierListSqlTokenType,
IdentifierNormalizerType,
IdentifierTokenType,
IdentifierSqlTokenType,
JsonSqlTokenType,
LogicalBooleanOperatorType,
NamedAssignmentType,
Expand Down Expand Up @@ -122,7 +122,7 @@ export default (configuration?: SqlTagConfigurationType) => {

sql.identifier = (
names: $ReadOnlyArray<string>
): IdentifierTokenType => {
): IdentifierSqlTokenType => {
// @todo Replace `type` with a symbol once Flow adds symbol support
// @see https://github.com/facebook/flow/issues/810
return deepFreeze({
Expand All @@ -133,7 +133,7 @@ export default (configuration?: SqlTagConfigurationType) => {

sql.identifierList = (
identifiers: $ReadOnlyArray<IdentifierListMemberType>
): IdentifierListTokenType => {
): IdentifierListSqlTokenType => {
return deepFreeze({
identifiers,
type: IdentifierListToken,
Expand Down Expand Up @@ -203,7 +203,7 @@ export default (configuration?: SqlTagConfigurationType) => {
sql.booleanExpression = (
members: $ReadOnlyArray<ValueExpressionType>,
operator: LogicalBooleanOperatorType
): BooleanExpressionTokenType => {
): BooleanExpressionSqlTokenType => {
return deepFreeze({
members,
operator,
Expand All @@ -215,7 +215,7 @@ export default (configuration?: SqlTagConfigurationType) => {
leftOperand: ValueExpressionType,
operator: ComparisonOperatorType,
rightOperand: ValueExpressionType
): ComparisonPredicateTokenType => {
): ComparisonPredicateSqlTokenType => {
return deepFreeze({
leftOperand,
operator,
Expand All @@ -226,7 +226,7 @@ export default (configuration?: SqlTagConfigurationType) => {

sql.assignmentList = (
namedAssignment: NamedAssignmentType
): AssignmentListTokenType => {
): AssignmentListSqlTokenType => {
return deepFreeze({
namedAssignment,
normalizeIdentifier,
Expand Down
6 changes: 3 additions & 3 deletions src/sqlFragmentFactories/createAssignmentListSqlFragment.js
@@ -1,7 +1,7 @@
// @flow

import type {
AssignmentListTokenType,
AssignmentListSqlTokenType,
SqlFragmentType,
} from '../types';
import {
Expand All @@ -12,7 +12,7 @@ import {
createSqlTokenSqlFragment,
} from '../factories';

export default (token: AssignmentListTokenType, greatestParameterPosition: number): SqlFragmentType => {
export default (token: AssignmentListSqlTokenType, greatestParameterPosition: number): SqlFragmentType => {
let placeholderIndex = greatestParameterPosition;

const values = [];
Expand All @@ -33,7 +33,7 @@ export default (token: AssignmentListTokenType, greatestParameterPosition: numbe
// $FlowFixMe
values.push(value);

// @todo allow AssignmentListTokenType key to be sql.identifier.
// @todo allow AssignmentListSqlTokenType key to be sql.identifier.
// @see https://github.com/gajus/slonik/issues/53
return escapeIdentifier(token.normalizeIdentifier(column)) + ' = $' + ++placeholderIndex;
}
Expand Down
@@ -1,7 +1,7 @@
// @flow

import type {
BooleanExpressionTokenType,
BooleanExpressionSqlTokenType,
SqlFragmentType,
} from '../types';
import {
Expand All @@ -14,7 +14,7 @@ import {
UnexpectedStateError,
} from '../errors';

export default (token: BooleanExpressionTokenType, greatestParameterPosition: number): SqlFragmentType => {
export default (token: BooleanExpressionSqlTokenType, greatestParameterPosition: number): SqlFragmentType => {
if (token.operator !== 'AND' && token.operator !== 'OR') {
throw new UnexpectedStateError('Invalid operator.');
}
Expand Down
@@ -1,7 +1,7 @@
// @flow

import type {
ComparisonPredicateTokenType,
ComparisonPredicateSqlTokenType,
SqlFragmentType,
} from '../types';
import {
Expand All @@ -16,7 +16,7 @@ import {

export type ComparisonOperatorType = '<' | '>' | '<=' | '>=' | '=' | '<>' | '!=' | '%';

export default (token: ComparisonPredicateTokenType, greatestParameterPosition: number): SqlFragmentType => {
export default (token: ComparisonPredicateSqlTokenType, greatestParameterPosition: number): SqlFragmentType => {
if (
token.operator !== '<' &&
token.operator !== '>' &&
Expand Down
4 changes: 2 additions & 2 deletions src/sqlFragmentFactories/createIdentifierListSqlFragment.js
@@ -1,14 +1,14 @@
// @flow

import type {
IdentifierListTokenType,
IdentifierListSqlTokenType,
SqlFragmentType,
} from '../types';
import {
escapeIdentifier,
} from '../utilities';

export default (token: IdentifierListTokenType): SqlFragmentType => {
export default (token: IdentifierListSqlTokenType): SqlFragmentType => {
const sql = token.identifiers
.map((identifier) => {
if (Array.isArray(identifier)) {
Expand Down
4 changes: 2 additions & 2 deletions src/sqlFragmentFactories/createIdentifierSqlFragment.js
@@ -1,14 +1,14 @@
// @flow

import type {
IdentifierTokenType,
IdentifierSqlTokenType,
SqlFragmentType,
} from '../types';
import {
escapeIdentifier,
} from '../utilities';

export default (token: IdentifierTokenType): SqlFragmentType => {
export default (token: IdentifierSqlTokenType): SqlFragmentType => {
const sql = token.names
.map((identifierName) => {
if (typeof identifierName !== 'string') {
Expand Down
30 changes: 15 additions & 15 deletions src/types.js
Expand Up @@ -232,31 +232,31 @@ export type ArraySqlTokenType = {|
+values: PositionalParameterValuesType,
|};

export type AssignmentListTokenType = {|
export type AssignmentListSqlTokenType = {|
+namedAssignment: NamedAssignmentType,
+normalizeIdentifier: IdentifierNormalizerType,
+type: 'SLONIK_TOKEN_ASSIGNMENT_LIST',
|};

export type BooleanExpressionTokenType = {|
export type BooleanExpressionSqlTokenType = {|
+members: $ReadOnlyArray<ValueExpressionType>,
+operator: LogicalBooleanOperatorType,
+type: 'SLONIK_TOKEN_BOOLEAN_EXPRESSION',
|};

export type ComparisonPredicateTokenType = {|
export type ComparisonPredicateSqlTokenType = {|
+leftOperand: ValueExpressionType,
+operator: ComparisonOperatorType,
+rightOperand: ValueExpressionType,
+type: 'SLONIK_TOKEN_COMPARISON_PREDICATE',
|};

export type IdentifierListTokenType = {|
export type IdentifierListSqlTokenType = {|
+identifiers: $ReadOnlyArray<IdentifierListMemberType>,
+type: 'SLONIK_TOKEN_IDENTIFIER_LIST',
|};

export type IdentifierTokenType = {|
export type IdentifierSqlTokenType = {|
+names: $ReadOnlyArray<string>,
+type: 'SLONIK_TOKEN_IDENTIFIER',
|};
Expand Down Expand Up @@ -303,11 +303,11 @@ export type PrimitiveValueExpressionType = $ReadOnlyArray<PrimitiveValueExpressi

export type SqlTokenType =
ArraySqlTokenType |
AssignmentListTokenType |
BooleanExpressionTokenType |
ComparisonPredicateTokenType |
IdentifierListTokenType |
IdentifierTokenType |
AssignmentListSqlTokenType |
BooleanExpressionSqlTokenType |
ComparisonPredicateSqlTokenType |
IdentifierListSqlTokenType |
IdentifierSqlTokenType |
JsonSqlTokenType |
RawSqlTokenType |
SqlSqlTokenType |
Expand Down Expand Up @@ -345,22 +345,22 @@ export type SqlTaggedTemplateType = {|
) => ArraySqlTokenType,
assignmentList: (
namedAssignmentValueBindings: NamedAssignmentType
) => AssignmentListTokenType,
) => AssignmentListSqlTokenType,
booleanExpression: (
members: $ReadOnlyArray<ValueExpressionType>,
operator: LogicalBooleanOperatorType
) => BooleanExpressionTokenType,
) => BooleanExpressionSqlTokenType,
comparisonPredicate: (
leftOperand: ValueExpressionType,
operator: ComparisonOperatorType,
rightOperand: ValueExpressionType
) => ComparisonPredicateTokenType,
) => ComparisonPredicateSqlTokenType,
identifier: (
names: $ReadOnlyArray<string>
) => IdentifierTokenType,
) => IdentifierSqlTokenType,
identifierList: (
identifiers: $ReadOnlyArray<IdentifierListMemberType>
) => IdentifierListTokenType,
) => IdentifierListSqlTokenType,
json: (
value: SerializableValueType
) => JsonSqlTokenType,
Expand Down

0 comments on commit 43085ea

Please sign in to comment.