klahnakoski/mo-sql-parsing

Column alias in single quotation marks results in ParseException

Closed this issue · 4 comments

from mo_sql_parsing import parse_sqlserver as parse
parse('select 42 "my_col_alias"') # This works.
parse("select 42 'my_column_alias'") # This gives ParseException.

select 42 'my_col_alias' works on our instance of MS SQL Server. One of our systems is old and uses this single quotation syntax as well.

pip show mo-sql-parsing says: Version: 10.652.24214

Due to the apparent simplicity, I tried once again to create a patch. After finding myself digging through your other libraries, I decided to stop trying. I can at least send the test to save you one minute:

    def test_issue247(self):
        sql = "select 42 'some_alias'"
        result = parse(sql)
        expected = {'select': {'name': 'some_alias', 'value': 42}}
        self.assertEqual(result, expected)

Let me think about this more. I can not find any reference to allowing single-quotes to define column aliases.

@a1ea321 my apologies for taking so long on this. Thank you very much for this submission!

https://pypi.org/project/mo-sql-parsing/10.655.24251/