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

42000!TODO: column names of level >= 3 #58

Open
aris-koning opened this issue Jun 16, 2022 · 0 comments
Open

42000!TODO: column names of level >= 3 #58

aris-koning opened this issue Jun 16, 2022 · 0 comments
Labels

Comments

@aris-koning
Copy link
Member

The following script fails spectacularly

from sqlalchemy import create_engine, schema, Column, Integer
from sqlalchemy.schema import MetaData, Table
from sqlalchemy.sql import select, insert

engine = create_engine('monetdb://monetdb:monetdb@localhost:50000/devdb', echo=True)
# engine = create_engine('postgresql+psycopg2://aris:aris@127.0.0.1/aris', echo=True)

connection = engine.connect() 
with connection.begin() as trans:
    connection.execute(schema.CreateSchema("foo"))
    foo = MetaData(schema="foo")
    bar = Table(
        "bar",
        foo,
        Column('c1', Integer),
        Column('c2', Integer)
    )
    foo.create_all(connection)

    connection.execute(insert(bar).values(c1=10, c2=10))

    result = connection.execute(select([bar]))
    for row in result:
        print(row)

    trans.rollback()

on the line containing result = connection.execute(select([bar])) with inner error message:

sqlalchemy.exc.OperationalError: (pymonetdb.exceptions.OperationalError) 42000!TODO: column names of level >= 3
[SQL: SELECT foo.bar.c1, foo.bar.c2 
FROM foo.bar]

The underlying issue is actually due to MonetDB itself not being able to handle fully qualified column names like foo.bar.c1. There is a corresponding MonetDB github issue for it: SQL: level 3 naming #2526 . And I have compared the query generation for the Postgres backend psycopg2 of sqlalchemy. This generates the same select query. So this gives the impression that sqlalchemy expects its SQL backends to be able handle 3 level names.

So essentially this is not a sqlalchemy-monetdb problem. However I think it is a good idea to keep this issue open for as long as the underlying MonetDB issue isn't solved. And it would be nice to have this example added to the test suite eventually. Either as reminder to have this fixed on the MonetDB side or hopefully to have it as a test ready for a fix on a future release of MonetDB. The underlying issue effects the Jan2022 release and older versons of MonetDB.

Python library versions used for testing this:

Name: sqlalchemy-monetdb
Version: 1.0.0
Name: SQLAlchemy
Version: 1.3.24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant