Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
run: |
npm ci
npm run build --if-present
npm test
env:
CI: true
45 changes: 45 additions & 0 deletions npmpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
scope: '@your-github-username'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
57 changes: 43 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"nearley": "^2.9.0"
},
"devDependencies": {
"mocha": "^3.3.0"
"mocha": "^3.3.0",
"diff": ">=3.5.0",
"debug": ">=2.6.9",
"growl": ">=1.10.0"
},
"scripts": {
"compile": "nearleyc ./sql.ne -o sql-parse.js",
Expand Down
1 change: 1 addition & 0 deletions sql.ne
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ identifier_comma_list ->
table ->
identifier {% d => ({type: 'table', table: d[0].value}) %}
| identifier "." identifier {% d => ({type: 'table', table: d[0].value +'.'+ d[2].value }) %}
| identifier "." identifier ( __ AS __ | __ ) identifier {% d => ({type: 'table', table: d[0].value +'.'+ d[2].value, alias: d[4].value }) %}
| identifier ( __ AS __ | __) identifier {% d => ({type: 'table', table: d[0].value, alias: d[2].value}) %}

where_clause ->
Expand Down
26 changes: 24 additions & 2 deletions test/test1.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,29 @@ const tests = [
}]
}]
}
}
},
{
sql: `select a.x, b.y from s.c a left join s.d as b on a.x=b.x`,
toSql: '(select `a`.`x`, `b`.`y` from ((`s.c`as `a` left join `s.d`as `b` on (`a`.`x` = `b`.`x`))))',
expected: {
sourceTables: ['s.c', 's.d'],
aliases: {
a: 's.c',
b: 's.d'
}
}
},
{
sql: `select a.x, b.y from [s].[c a] a left join s.[d] as b on a.x=b.x`,
toSql: '(select `a`.`x`, `b`.`y` from ((`s.c a`as `a` left join `s.d`as `b` on (`a`.`x` = `b`.`x`))))',
expected: {
sourceTables: ['s.c a', 's.d'],
aliases: {
a: 's.c a',
b: 's.d'
}
}
}
];

const parser = require('../parser')();
Expand All @@ -338,4 +360,4 @@ describe('parse', function() {
}
});
})
});
});