Skip to content

BUG: sql_schema does not generate dialect-specific DDL #8827

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

Merged
merged 1 commit into from
Nov 17, 2014

Conversation

artemyk
Copy link
Contributor

@artemyk artemyk commented Nov 15, 2014

Closes #8697 .

sqlalchemy CreateTable needs to be called slightly differently to create dialect-specific SQL. See http://stackoverflow.com/questions/2128717/sqlalchemy-printing-raw-sql-from-create .

@artemyk artemyk force-pushed the get_schema_fix_8697 branch 2 times, most recently from 87a623f to 0213efe Compare November 15, 2014 23:14
@jorisvandenbossche jorisvandenbossche added the IO SQL to_sql, read_sql, read_sql_query label Nov 16, 2014
@jorisvandenbossche jorisvandenbossche added this to the 0.15.2 milestone Nov 16, 2014
@jorisvandenbossche
Copy link
Member

@artemyk Thanks! This seems indeed the fix.

I wanted to comment that we should maybe explicitely test for a certain dialect that a dialect-specific name is used (eg for postgresql that it used timestamp without time zone instead of datetime) to be sure it is dialect specific. But I was thinking now: does your test already cover that because the dialect-agnostic "create table" statement would fail to execute on the different dialects?

@artemyk artemyk force-pushed the get_schema_fix_8697 branch from 0213efe to 0ddbb0c Compare November 17, 2014 01:38
@artemyk
Copy link
Contributor Author

artemyk commented Nov 17, 2014

@jorisvandenbossche Yes, the CREATE TABLE is executed under the different dialects in the tests, and then we test that the created table is the same as the dataframe. I think this is the best way to check that the right schema is getting generated (as opposed to checking for specific strings, for example). Before this patch, for example, postgres fails the test.
Added a release note and squashed.

@jorisvandenbossche
Copy link
Member

Thanks a lot!

jorisvandenbossche added a commit that referenced this pull request Nov 17, 2014
BUG: sql_schema does not generate dialect-specific DDL
@jorisvandenbossche jorisvandenbossche merged commit 9d4963e into pandas-dev:master Nov 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO SQL to_sql, read_sql, read_sql_query
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: SQL get_schema generates incorrect DDL for specific dialect
2 participants