Skip to content

Commit 9b31b41

Browse files
authored
Merge pull request #1 from justinkenel/master
sync fork to original repo
2 parents 199c45c + 5f01092 commit 9b31b41

File tree

6 files changed

+143
-17
lines changed

6 files changed

+143
-17
lines changed

.github/workflows/nodejs.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Node CI
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: [8.x, 10.x, 12.x]
13+
14+
steps:
15+
- uses: actions/checkout@v1
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- name: npm install, build, and test
21+
run: |
22+
npm ci
23+
npm run build --if-present
24+
npm test
25+
env:
26+
CI: true

npmpublish.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Node.js Package
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v1
12+
- uses: actions/setup-node@v1
13+
with:
14+
node-version: 12
15+
- run: npm ci
16+
- run: npm test
17+
18+
publish-npm:
19+
needs: build
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v1
23+
- uses: actions/setup-node@v1
24+
with:
25+
node-version: 12
26+
registry-url: https://registry.npmjs.org/
27+
- run: npm ci
28+
- run: npm publish
29+
env:
30+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
31+
32+
publish-gpr:
33+
needs: build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v1
37+
- uses: actions/setup-node@v1
38+
with:
39+
node-version: 12
40+
registry-url: https://npm.pkg.github.com/
41+
scope: '@your-github-username'
42+
- run: npm ci
43+
- run: npm publish
44+
env:
45+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

package-lock.json

Lines changed: 43 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"nearley": "^2.9.0"
99
},
1010
"devDependencies": {
11-
"mocha": "^3.3.0"
11+
"mocha": "^3.3.0",
12+
"diff": ">=3.5.0",
13+
"debug": ">=2.6.9",
14+
"growl": ">=1.10.0"
1215
},
1316
"scripts": {
1417
"compile": "nearleyc ./sql.ne -o sql-parse.js",

sql.ne

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ identifier_comma_list ->
149149
table ->
150150
identifier {% d => ({type: 'table', table: d[0].value}) %}
151151
| identifier "." identifier {% d => ({type: 'table', table: d[0].value +'.'+ d[2].value }) %}
152+
| identifier "." identifier ( __ AS __ | __ ) identifier {% d => ({type: 'table', table: d[0].value +'.'+ d[2].value, alias: d[4].value }) %}
152153
| identifier ( __ AS __ | __) identifier {% d => ({type: 'table', table: d[0].value, alias: d[2].value}) %}
153154

154155
where_clause ->

test/test1.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,29 @@ const tests = [
311311
}]
312312
}]
313313
}
314-
}
314+
},
315+
{
316+
sql: `select a.x, b.y from s.c a left join s.d as b on a.x=b.x`,
317+
toSql: '(select `a`.`x`, `b`.`y` from ((`s.c`as `a` left join `s.d`as `b` on (`a`.`x` = `b`.`x`))))',
318+
expected: {
319+
sourceTables: ['s.c', 's.d'],
320+
aliases: {
321+
a: 's.c',
322+
b: 's.d'
323+
}
324+
}
325+
},
326+
{
327+
sql: `select a.x, b.y from [s].[c a] a left join s.[d] as b on a.x=b.x`,
328+
toSql: '(select `a`.`x`, `b`.`y` from ((`s.c a`as `a` left join `s.d`as `b` on (`a`.`x` = `b`.`x`))))',
329+
expected: {
330+
sourceTables: ['s.c a', 's.d'],
331+
aliases: {
332+
a: 's.c a',
333+
b: 's.d'
334+
}
335+
}
336+
}
315337
];
316338

317339
const parser = require('../parser')();
@@ -338,4 +360,4 @@ describe('parse', function() {
338360
}
339361
});
340362
})
341-
});
363+
});

0 commit comments

Comments
 (0)