-
Notifications
You must be signed in to change notification settings - Fork 46
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
'PGDDLCompiler' object has no attribute '_bind_processors' #59
Comments
Interesting.. I use alembic for all my table creations and migrations, so I havent tested using sqlalchemy migration methods. Would you be willing to write a PR to fix this? |
You could try changing the dialect to psycopg dialect (slqalchemys default) and see if that helps: |
Closing as no more activity. Please reopen with a comment if this still needs to be looked at for some reason. Currently lacking actionable info for me. |
Ive never really used createTable outside of using alembic. So its possible there are just some things that are missing in this library. I would accept a PR that added support for this. |
I've noticed that query = CreateSchema(MyModel.__table_args__["schema"])
await db.execute(str(query)) works fine to me. So maybe you just need to cast an SQL expression to string. |
|
This snippet seems to work better (at least it compiled from sqlalchemy.dialects.postgresql.base import PGDialect
for table in models.Base.metadata.sorted_tables:
query = CreateTable(table)
query = str(query.compile(dialect=PGDialect()))
await conn.execute(query) |
DDL is actually broken in many ways. class Foo(Base):
__tablename__ = "foo"
id = sa.Column(TEXT, primary_key=True, nullable=False)
nodes = sa.Column(ARRAY(TEXT), nullable=True)
async def test_bug():
pool = await asyncpgsa.create_pool(database="test")
async with pool.transaction() as conn:
await conn.execute("DROP TABLE IF EXISTS foo")
for table in Base.metadata.sorted_tables:
await conn.execute(CreateTable(table)) will result in the following stack trace:
This error is trivially fixable (check for None), but even after the fix the error originally reported in this issue will manifest. Moreover, DDL is used to be not broken. The snippet above used to work as it is in |
Thats weird... Not sure why that commit would have broken DDL |
This might be fixed now thanks to #94 |
My envs
My code sample
The exception
My analysis
In sqlalchemy's source, only SQLCompiler has
_bind_processors
property.However
create_expr.compile(dialect=asyncpgsa.connection._dialect)
generates an instance of typePGDDLCompiler(DDLCompiler)
, of whichSQLCompiler
isn't a base class.The text was updated successfully, but these errors were encountered: