Skip to content

Commit

Permalink
Fix issue 1 in #22
Browse files Browse the repository at this point in the history
  • Loading branch information
dsferruzza committed Dec 29, 2015
1 parent a1a8882 commit 189b5c0
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 11 deletions.
18 changes: 15 additions & 3 deletions dist/simpleSqlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,13 @@ var argListExpression = expression.map(function(node) {
var tableListExpression = seq(
alt(
tableAndColumn.map(mkString),
colName
colName,
regex(/"([^"\\]*(?:\\.[^"\\]*)*)"/, 1).map(function(node) {
return {
table: node,
expression: '"' + node + '"',
};
})
),
opt( // Alias
seq(
Expand All @@ -984,9 +990,15 @@ var tableListExpression = seq(
)
).map(function(node) {
var n = {};
n.table = node[0];
if (typeof node[0] === 'object') {
n.table = node[0].table;
n.expression = node[0].expression;
}
else {
n.table = node[0];
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
}
n.alias = (node[1] !== null) ? node[1].alias : null;
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
return n;
});

Expand Down
2 changes: 1 addition & 1 deletion dist/simpleSqlParser.min.js

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions dist/simpleSqlParser.withoutDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,13 @@ var argListExpression = expression.map(function(node) {
var tableListExpression = seq(
alt(
tableAndColumn.map(mkString),
colName
colName,
regex(/"([^"\\]*(?:\\.[^"\\]*)*)"/, 1).map(function(node) {
return {
table: node,
expression: '"' + node + '"',
};
})
),
opt( // Alias
seq(
Expand All @@ -452,9 +458,15 @@ var tableListExpression = seq(
)
).map(function(node) {
var n = {};
n.table = node[0];
if (typeof node[0] === 'object') {
n.table = node[0].table;
n.expression = node[0].expression;
}
else {
n.table = node[0];
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
}
n.alias = (node[1] !== null) ? node[1].alias : null;
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
return n;
});

Expand Down
2 changes: 1 addition & 1 deletion dist/simpleSqlParser.withoutDeps.min.js

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

18 changes: 15 additions & 3 deletions src/sql2ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,13 @@ var argListExpression = expression.map(function(node) {
var tableListExpression = seq(
alt(
tableAndColumn.map(mkString),
colName
colName,
regex(/"([^"\\]*(?:\\.[^"\\]*)*)"/, 1).map(function(node) {
return {
table: node,
expression: '"' + node + '"',
};
})
),
opt( // Alias
seq(
Expand All @@ -299,9 +305,15 @@ var tableListExpression = seq(
)
).map(function(node) {
var n = {};
n.table = node[0];
if (typeof node[0] === 'object') {
n.table = node[0].table;
n.expression = node[0].expression;
}
else {
n.table = node[0];
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
}
n.alias = (node[1] !== null) ? node[1].alias : null;
n.expression = node[0] + ((node[1] !== null) ? node[1].expression : '');
return n;
});

Expand Down
18 changes: 18 additions & 0 deletions tests/tests-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ var Select = [
limit: null,
},
},
{
c: 'Quoted table name',
q: 'SELECT * FROM "quoted.table"',
a: {
type: 'select',
select: [
{ expression: '*', column: '*', table: null, alias: null, position: { start: 7, end: 8 } },
],
from: [
{ expression: '"quoted.table"', table: 'quoted.table', alias: null, position: { start: 14, end: 28 } },
],
join: [],
where: null,
group: [],
order: [],
limit: null,
},
},
{
c: 'Column quotes',
q: 'SELECT col1, `col2` FROM table',
Expand Down

0 comments on commit 189b5c0

Please sign in to comment.