Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: failed to compile SQL for float/double columns #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

semigodking
Copy link

Visitor's name must contain only characters for Python symbols.

Visitor's name must contain only characters for Python symbols.
@MitchellWeg
Copy link
Member

Do you have an example of what this PR fixes? The test-suite does not have any more passing/failing tests.

@semigodking
Copy link
Author

Yes. Here is code to reproduce.

(base) root@c5a28fb7edc6:/home/nia# python
Python 3.8.12 (default, Oct 12 2021, 13:49:34)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy as sqla
>>> url = "monetdb://monetdb:password@monetdb:50000/db"
>>> engine = sqla.create_engine(url)
>>> engine.execute("create table test1 (col1 double)");
<sqlalchemy.engine.cursor.LegacyCursorResult object at 0x7fd2c2897370>
>>> meta = sqla.MetaData(bind=engine)
>>> table = sqla.Table("test1", meta, autoload=True)
>>> table.columns
<sqlalchemy.sql.base.ImmutableColumnCollection object at 0x7fd2c2620900>
>>> table.columns["col1"]
Column('col1', DOUBLE_PRECISION(), table=<test1>)
>>> table.columns["col1"].type
DOUBLE_PRECISION()
>>> table.columns["col1"].type.compile(dialect=engine.dialect)
Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py", line 77, in _compiler_dispatch
    meth = getter(visitor)
AttributeError: 'MonetTypeCompiler' object has no attribute 'visit_DOUBLE PRECISION'

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

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/sql/type_api.py", line 692, in compile
    return dialect.type_compiler.process(self)
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/sql/compiler.py", line 518, in process
    return type_._compiler_dispatch(self, **kw)
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py", line 79, in _compiler_dispatch
    return visitor.visit_unsupported_compilation(self, err, **kw)
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/sql/compiler.py", line 521, in visit_unsupported_compilation
    util.raise_(
  File "/opt/conda/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
    raise exception
sqlalchemy.exc.UnsupportedCompilationError: Compiler <sqlalchemy_monetdb.compiler.MonetTypeCompiler object at 0x7fd2c267d2e0> can't render element of type DOUBLE_PRECISION (Background on this error at: https://sqlalche.me/e/14/l7de)

@gijzelaerr
Copy link
Collaborator

can you add your example as a unittest to the PR? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants