pgsql-ast-parser
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Yet another simple Postgres SQL parser", | ||
@@ -9,3 +9,3 @@ "main": "index.js", | ||
"build": "rimraf lib && webpack --config webpack.config.js --prod", | ||
"release": "git diff --exit-code && npm run test && npm run build && cp -r src lib/src && npm run build:deno && deno run deno-test.ts && npm publish lib && npm run && npm run release-deno", | ||
"release": "git diff --exit-code && npm run test && npm run cover && npm run build && cp -r src lib/src && npm run build:deno && deno run deno-test.ts && npm publish lib && npm run release-deno", | ||
"release-deno": "git add -A && git commit -m \"Build deno\" && PACKAGE_VERSION=$(cat package.json | grep \\\"version\\\" | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push --tags", | ||
@@ -12,0 +12,0 @@ "typecheck": "tsc --project tsconfig.json --noEmit", |
@@ -5,3 +5,3 @@ 🏃♀️ `pgsql-ast-parser` is a Postgres SQL syntax parser. It produces a typed AST tree, covering the most common syntaxes of pgsql. | ||
💓 Open an issue if you find an bug or unsupported syntax ! | ||
❤ Open an issue if you find an bug or unsupported syntax ! | ||
@@ -11,2 +11,5 @@ 🔗 This parser has been created to implement [pg-mem](https://github.com/oguimbal/pg-mem), an in-memory postgres db emulator. 👉 [Play with it here](https://oguimbal.github.io/pg-mem-playground/) | ||
👉 Dont forget to ⭐ this repo if you like this package :) | ||
# 📐 Installation | ||
@@ -13,0 +16,0 @@ |
@@ -19,3 +19,3 @@ import {compile, keywords} from 'moo'; | ||
word: { | ||
match: /[a-zA-Z][A-Za-z0-9_]*(?!')/, | ||
match: /[eE](?!')[A-Za-z0-9_]*|[a-df-zA-DF-Z][A-Za-z0-9_]*/, | ||
type: caseInsensitiveKeywords(keywodsMap), | ||
@@ -36,3 +36,3 @@ }, | ||
eString: { | ||
match: /(?:e|E)'(?:[^'\\]|[\r\n\s]|(?:\\\s)|(?:\\\n)|(?:\\.)|(?:\'\'))+'/, | ||
match: /\b(?:e|E)'(?:[^'\\]|[\r\n\s]|(?:\\\s)|(?:\\\n)|(?:\\.)|(?:\'\'))+'/, | ||
value: x => { | ||
@@ -39,0 +39,0 @@ return x.substr(2, x.length - 3) |
@@ -468,3 +468,3 @@ import 'mocha'; | ||
describe('Unaries', () => { | ||
checkTreeExpr(['not a and b', 'NOT"a"and"b"'], { | ||
checkTreeExpr(['not e and b', 'NOT"e"and"b"'], { | ||
type: 'binary', | ||
@@ -475,3 +475,3 @@ op: 'AND', | ||
op: 'NOT', | ||
operand: { type: 'ref', name: 'a' }, | ||
operand: { type: 'ref', name: 'e' }, | ||
}, | ||
@@ -756,2 +756,15 @@ right: { type: 'ref', name: 'b' }, | ||
}); | ||
// bugfix (was taking E'FALSE' as an escaped string) | ||
checkTreeExpr([`case when b then 1 ELSE'FALSE' end`], { | ||
type: 'case', | ||
whens: [{ | ||
when: { type: 'ref', name: 'b' }, | ||
value: { type: 'integer', value: 1 } | ||
}], | ||
else: { | ||
type: 'string', | ||
value: 'FALSE', | ||
} | ||
}); | ||
}); | ||
@@ -758,0 +771,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
650474
7079
199