Skip to content

Commit

Permalink
fix: clarify format's type to infer getDbStatement's return type
Browse files Browse the repository at this point in the history
also refactor getDbStatement logic to always return a string

Signed-off-by: Naseem <naseem@transit.app>
  • Loading branch information
Naseem committed Sep 2, 2020
1 parent 2c5d472 commit 8fdcd0d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions plugins/node/opentelemetry-plugin-mysql/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ function getJDBCString(
*/
export function getDbStatement(
query: string | Query | QueryOptions,
format: Function,
format: (
sql: string,
values: any[],
stringifyObjects?: boolean,
timeZone?: string
) => string,
values?: any[]
) {
if (typeof query === 'string') {
return values ? format(query, values) : query;
} else if (typeof query === 'object') {
if (query.values) {
return format(query.sql, query.values);
}
return values ? format(query.sql, values) : query.sql;
} else {
return values || query.values
? format(query.sql, values || query.values)
: query.sql;
}
}

0 comments on commit 8fdcd0d

Please sign in to comment.