You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
time(n) with time zone is parsed as timestamp(n) with time zone #178
Parsing a time(n) with time zone (or time(n) without time zone) data type produces timestamp with time zone (or timestamp without time zone) in the AST instead of time with time zone / time without time zone. Without the precision modifier, time with time zone is parsed as expected.
const{ parse, toSql }=require('pgsql-ast-parser');constast=parse('CREATE TABLE t (a time(2) with time zone, b time with time zone, c time(2))')[0];console.log(JSON.stringify(ast.columns.map(c=>c.dataType)));console.log(toSql.statement(ast));console.log(toSql.statement(parse('SELECT now()::time(0) with time zone')[0]));
Run with node repro.js:
Actual output:
[{"name":"timestamp with time zone","config":[2]},{"name":"time with time zone"},{"name":"time","config":[2]}]
CREATE TABLE t (a timestamp(2) with time zone , b time with time zone , c time (2) )
SELECT ((now () )::timestamp(0) with time zone )
In src/syntax/base.ne, the data_type_date rule matches (%word {% anyKw('timestamp', 'time') %}) with precision (lparen int rparen) but hardcodes name: `timestamp ${toStr(x[2])} time zone` instead of using the matched keyword x[0].
Activity