Skip to content

Commit

Permalink
Use Deparser class directly to work around type issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilogorek committed Nov 5, 2024
1 parent d910e3a commit c493f85
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/Parser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import prettier from 'prettier/standalone.js'
import SqlFormatter from 'prettier-plugin-sql'
import { parse, deparse } from 'pgsql-parser'
import { parse, Deparser } from 'pgsql-parser'
import { FormatterOptions } from './types.js'

const DEFAULT_FORMATTER_OPTIONS = {
Expand Down Expand Up @@ -33,9 +33,7 @@ interface ParseReturnValues {
*/
export function Deparse(parsedSql: object): DeparseReturnValues {
try {
// @ts-ignore - Type definition defines non-optional any, though the argument is not required
const data = deparse(parsedSql)

const data = new Deparser(parsedSql).deparseQuery()
return { data, error: null }
} catch (error) {
return { data: null, error: error as Error }
Expand Down

0 comments on commit c493f85

Please sign in to comment.