-
Notifications
You must be signed in to change notification settings - Fork 4
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
Error when using tables beginning with capital letters #8
Comments
What version of Postgres are you on? Also please add your OS, Python version, and versions of pytest-postgresql and SQLAlchemy. |
For sure, thanks for your help: PostgreSQL 10.0 |
Minimum test case: from sqlalchemy import Table, MetaData, Column, String
device_table = Table('Device', MetaData(),
Column('device_id', String, primary_key=True))
def test1(postgresql_db):
postgresql_db.create_table(device_table)
def test2(postgresql_db):
postgresql_db.create_table(device_table) Changing 'Device' to 'device' returns no errors |
Could you try using the Anyway, I've found the problem. The issue is that we use SQLAlchemy to issue the DDL for creating tables in Since SQLAlchemy doesn't quote identifiers if it doesn't need to, the DDL looks like CREATE TABLE Device (device_id TEXT PRIMARY KEY); Postgres lowercases unquoted identifiers behind our back so the table created is actually named In the cleanup phase, we drop the tables ourselves, so the statement issued is DROP TABLE "Device" CASCADE; Here the name is quoted, so Postgres looks for a table named Not sure how to go about fixing this yet. Ideas? |
As for
This suggests to me that it's creating a capital "Device" but not dropping it properly rather the other way around. |
Unfortunately I haven't had much time to look at this. @wesleykendall do you have any thoughts on how we can fix this? |
I use
create_table
to create a table named "Device". It works fine for the setup but when pytest-pgsql goes to rollback the changes this error is thrown:Further down I see this:
This causes a problem in that the table is not rolled back, so when the next test runs and tries to create it again it fails.
Interestingly, the problem goes away when I change the name of the table to "device". Sadly, this is not something I can fix in our Postgres DB itself to rename these tables.
The text was updated successfully, but these errors were encountered: