Skip to content

Commit

Permalink
fix: add type tag to SqlContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
petrzjunior committed Jul 28, 2022
1 parent 5247866 commit 73ffa6d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ function sqlText(
if (expression === undefined) {
// if expression is undefined, just skip it
text += chains[i + 1]
} else if (expression && expression._sql instanceof SqlContainer) {
} else if (
expression &&
typeof expression === 'object' &&
typeof expression._sql === 'object' &&
typeof expression._sql.isSqlContainer === 'function' &&
expression._sql.isSqlContainer()
) {
// if expression is a sub `sql` template literal
const {
text: _text,
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export class SqlContainer {
this.expressions = expressions
this.count = count
}
public isSqlContainer(): boolean {
return true
}
}

export type TemplateLiteralFunc<T> = (
Expand Down

0 comments on commit 73ffa6d

Please sign in to comment.