-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Hi - love the library! I don't know if this is an issue per-se, but I got some output I wasn't expecting.
Given this is a "high-level" SQL parser, I was hoping to use it to tell me which columns of which tables queries referred to. It gets me closer, but further parsing is still needed. Example:
let sqlSurveyor = require("sql-surveyor")
let surveyor = new sqlSurveyor.SQLSurveyor(sqlSurveyor.SQLDialect.PLpgSQL)
let columns = surveyor.survey('select f.id from foo as f').getQueryAtLocation(0).outputColumns
console.log(columns)This prints:
[
OutputColumn {
columnName: 'f.id',
columnAlias: null,
tableName: 'f',
tableAlias: null
}
]Whereas I'd expect sql-surveyor to do the fiddly bits for me and figure out that f is an alias for the actual table foo, and that the implicit column alias (i.e. the column name that I'll get back from running this query on most clients) is id, so an output of
[
OutputColumn {
columnName: 'f.id',
columnAlias: 'id',
tableName: 'foo',
tableAlias: 'f'
}
]I can figure that stuff out myself, by looking up 'f' in referencedTables, and parsing 'f.id' by splitting on '.', but I was hoping sql-surveyor would do some of that for me. Just wanted to check a) it isn't already done in a feature I haven't come across yet or b) whether you'd be open to adding that functionality.