Skip to content

Commit

Permalink
revert some prettier formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mmkal committed Oct 19, 2020
1 parent 008aa0d commit 80c5d69
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 51 deletions.
12 changes: 10 additions & 2 deletions src/binders/bindPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ export default (
clientConfiguration,
'IMPLICIT_QUERY',
(connectionLog, connection, boundConnection) => {
return boundConnection.copyFromBinary(copyQuery, values, columnTypes);
return boundConnection.copyFromBinary(
copyQuery,
values,
columnTypes,
);
},
(newPool) => {
return newPool.copyFromBinary(copyQuery, values, columnTypes);
return newPool.copyFromBinary(
copyQuery,
values,
columnTypes,
);
},
);
},
Expand Down
5 changes: 1 addition & 4 deletions src/factories/createMockPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ import {
import createClientConfiguration from './createClientConfiguration';

type OverridesType = {
readonly query: (
sql: string,
values: ReadonlyArray<PrimitiveValueExpressionType>,
) => Promise<QueryResultType<QueryResultRowType>>;
readonly query: (sql: string, values: ReadonlyArray<PrimitiveValueExpressionType>) => Promise<QueryResultType<QueryResultRowType>>;
};

export default (
Expand Down
28 changes: 17 additions & 11 deletions src/factories/createSqlTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ export default () => {
}

if (token === undefined) {
log.debug(
{
index,
values,
},
'bound values',
);
log.debug({
index,
values,
}, 'bound values');

throw new InvalidInputError('SQL tag cannot be bound an undefined value.');
} else if (isPrimitiveValueExpression(token)) {
Expand Down Expand Up @@ -115,14 +112,18 @@ export default () => {
});
};

sql.binary = (data: Buffer): BinarySqlTokenType => {
sql.binary = (
data: Buffer,
): BinarySqlTokenType => {
return deepFreeze({
data,
type: BinaryToken,
});
};

sql.identifier = (names: ReadonlyArray<string>): IdentifierSqlTokenType => {
sql.identifier = (
names: ReadonlyArray<string>,
): IdentifierSqlTokenType => {
// @todo Replace `type` with a symbol once Flow adds symbol support
// @see https://github.com/facebook/flow/issues/810
return deepFreeze({
Expand All @@ -131,14 +132,19 @@ export default () => {
});
};

sql.json = (value: SerializableValueType): JsonSqlTokenType => {
sql.json = (
value: SerializableValueType,
): JsonSqlTokenType => {
return deepFreeze({
type: JsonToken,
value,
});
};

sql.join = (members: ReadonlyArray<ValueExpressionType>, glue: SqlTokenType): ListSqlTokenType => {
sql.join = (
members: ReadonlyArray<ValueExpressionType>,
glue: SqlTokenType,
): ListSqlTokenType => {
return deepFreeze({
glue,
members,
Expand Down
11 changes: 7 additions & 4 deletions src/routines/createTypeOverrides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export default async (connection: InternalDatabaseConnectionType, typeParsers: R
});

const postgresTypes = (
await connection.query('SELECT oid, typarray, typname FROM pg_type WHERE typname = ANY($1::text[])', [typeNames])
await connection.query('SELECT oid, typarray, typname FROM pg_type WHERE typname = ANY($1::text[])', [
typeNames,
])
).rows;

for (const typeParser of typeParsers) {
Expand All @@ -40,9 +42,10 @@ export default async (connection: InternalDatabaseConnectionType, typeParsers: R

if (postgresType.typarray) {
typeOverrides.setTypeParser(postgresType.typarray, (arrayValue) => {
return parseArray(arrayValue).map((value) => {
return typeParser.parse(value);
});
return parseArray(arrayValue)
.map((value) => {
return typeParser.parse(value);
});
});
}
}
Expand Down
30 changes: 9 additions & 21 deletions src/routines/executeQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,10 @@ const retryTransaction = async (
await connection.query('BEGIN');

for (const transactionQuery of transactionQueries) {
connectionLogger.trace(
{
attempt,
queryId: transactionQuery.executionContext.queryId,
},
'retrying query',
);
connectionLogger.trace({
attempt,
queryId: transactionQuery.executionContext.queryId,
}, 'retrying query');

result = await transactionQuery.executionRoutine(
connection,
Expand Down Expand Up @@ -193,9 +190,7 @@ export default async (
result = await interceptor.beforeQueryExecution(executionContext, actualQuery);

if (result) {
log.info(
'beforeQueryExecution interceptor produced a result; short-circuiting query execution using beforeQueryExecution result',
);
log.info('beforeQueryExecution interceptor produced a result; short-circuiting query execution using beforeQueryExecution result');

return result;
}
Expand Down Expand Up @@ -230,11 +225,7 @@ export default async (
actualQuery,
);
} catch (error) {
if (
typeof error.code === 'string' &&
error.code.startsWith(TRANSACTION_ROLLBACK_ERROR_PREFIX) &&
clientConfiguration.transactionRetryLimit > 0
) {
if (typeof error.code === 'string' && error.code.startsWith(TRANSACTION_ROLLBACK_ERROR_PREFIX) && clientConfiguration.transactionRetryLimit > 0) {
result = await retryTransaction(
connectionLogger,
connection,
Expand All @@ -246,12 +237,9 @@ export default async (
}
}
} catch (error) {
log.error(
{
error: serializeError(error),
},
'execution routine produced an error',
);
log.error({
error: serializeError(error),
}, 'execution routine produced an error');

// 'Connection terminated' refers to node-postgres error.
// @see https://github.com/brianc/node-postgres/blob/eb076db5d47a29c19d3212feac26cd7b6d257a95/lib/client.js#L199
Expand Down
10 changes: 5 additions & 5 deletions src/sqlFragmentFactories/createArraySqlFragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export default (token: ArraySqlTokenType, greatestParameterPosition: number): Sq
}
}

const values = [token.values];
const values = [
token.values,
];

placeholderIndex++;

Expand All @@ -44,15 +46,13 @@ export default (token: ArraySqlTokenType, greatestParameterPosition: number): Sq
} else if (typeof token.memberType === 'string') {
sql += escapeIdentifier(token.memberType) + '[]';
} else {
throw new InvalidInputError(
'Unsupported `memberType`. `memberType` must be a string or SqlToken of "SLONIK_TOKEN_SQL" type.',
);
throw new InvalidInputError('Unsupported `memberType`. `memberType` must be a string or SqlToken of "SLONIK_TOKEN_SQL" type.');
}

return {
sql,

// @ts-ignore (is this right?)
// @ts-ignore
values,
};
};
5 changes: 1 addition & 4 deletions src/utilities/normaliseQueryValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import type {
PrimitiveValueExpressionType,
} from '../types';

export default (
queryValues: ReadonlyArray<PrimitiveValueExpressionType>,
native: boolean,
): ReadonlyArray<PrimitiveValueExpressionType> => {
export default (queryValues: ReadonlyArray<PrimitiveValueExpressionType>, native: boolean): ReadonlyArray<PrimitiveValueExpressionType> => {
if (native && queryValues) {
const finalValues = [];

Expand Down

0 comments on commit 80c5d69

Please sign in to comment.