diff --git a/src/db/parser/parser_ra.ts b/src/db/parser/parser_ra.ts index 318a260f..f7775d07 100644 --- a/src/db/parser/parser_ra.ts +++ b/src/db/parser/parser_ra.ts @@ -3,6 +3,9 @@ import { i18n } from 'calc2/i18n'; const pegParserRelalg = require('./grammar_ra.pegjs') as any; export function parseRelalg(text: string, relationNames: string[] = []): relalgAst.rootRelalg { + // Remove any whitespace before '(' character + text = text.replace(/\s*\(/g, '('); + const ast = pegParserRelalg.parse(text, { startRule: 'start', relationNames: relationNames, diff --git a/src/db/relalg.ts b/src/db/relalg.ts index 3ac5a684..6f2cd8e6 100644 --- a/src/db/relalg.ts +++ b/src/db/relalg.ts @@ -137,7 +137,8 @@ const pegParserSql = require('./parser/grammar_sql.pegjs') as any; export function parseSQLSelect(text: string): sqlAst.rootSql { return pegParserSql.parse( - text, + // Remove any whitespace before '(' character + text.replace(/\s*\(/g, '('), { startRule: 'start', tracer: undefined,