codeschool / sqlite-parser

JavaScript implentation of SQLite 3 query parser
MIT License
331 stars 57 forks source link

Get full text of expression #40

Open aplarsen opened 8 years ago

aplarsen commented 8 years ago

In a select statement, reconstituting any expression that isn't aliased must take some recursion to drill down and glue it back together. Up at the statement[i].result[i] level, would it be too much to ask to see the full expression here?

For example, in this query:

select
    first_name || ' ' || last_name,
    grade_level
from
    students

I'd love to see this as the return:

{
    "statement": [
        {
            "result": [
                {
                    "type": "expression",
                    **"fullText": "first_name || ' ' || last_name",**
                    "left": "etc"
                    "right": "etc"
                },
                {
                    "type": "column",
                    "name": "grade_level"
                }
            ]
        }
    ]
}
karlb commented 6 years ago

If #23 gets done, you might be able pass the expression to the query generator in order to get the whole expression as a string.

aplarsen commented 6 years ago

Ooh, definitely. I like that.