MonetDB / sqlalchemy-monetdb

A SQLAlchemy dialect for MonetDB
MIT License
41 stars 17 forks source link

test_group_by_composed test fail #21

Open gijzelaerr opened 7 years ago

gijzelaerr commented 7 years ago
Traceback (most recent call last):
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/cursors.py", line 164, in execute
    block = self.connection.execute(query)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/connections.py", line 135, in execute
    return self.command('s' + query + '\n;')
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/connections.py", line 140, in command
    return self.mapi.cmd(command)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/mapi.py", line 244, in cmd
    raise exception(string)
pymonetdb.exceptions.OperationalError: 42000!syntax error, unexpected '+', expecting SCOLON in: "select count(some_table.id) as count_1, some_table.x + some_table.y as lx 
!from "

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/testing/suite/test_select.py", line 95, in test_group_by_composed
    [(1, 3), (1, 5), (1, 7)]
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/testing/suite/test_select.py", line 44, in _assert_result
    config.db.execute(select).fetchall(),
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 2064, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 945, in execute
    return meth(self, multiparams, params)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/sql/elements.py", line 263, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1053, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1402, in _handle_dbapi_exception
    exc_info
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/cursors.py", line 164, in execute
    block = self.connection.execute(query)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/connections.py", line 135, in execute
    return self.command('s' + query + '\n;')
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/sql/connections.py", line 140, in command
    return self.mapi.cmd(command)
  File "/home/gijs/Work/sqlalchemy-monetdb/.venv3/lib/python3.5/site-packages/pymonetdb/mapi.py", line 244, in cmd
    raise exception(string)
sqlalchemy.exc.OperationalError: (pymonetdb.exceptions.OperationalError) 42000!syntax error, unexpected '+', expecting SCOLON in: "select count(some_table.id) as count_1, some_table.x + some_table.y as lx 
!from "
 [SQL: 'SELECT count(some_table.id) AS count_1, some_table.x + some_table.y AS lx \nFROM some_table GROUP BY some_table.x + some_table.y ORDER BY lx']
gijzelaerr commented 7 years ago

it looks like sqlalchemy.select().group_by(expr) doesnt use the label of an expression, while order_by(expr) does where expr = (table.c.x + table.c.y).label('lx')

gijzelaerr commented 7 years ago

reported issue upstream https://groups.google.com/forum/#!topic/sqlalchemy/r4X7ddN4rgA