Michael Bayer ha scritto: > > On Nov 16, 2007, at 1:54 PM, Manlio Perillo wrote: > >> There is an error in the schema, b.id is of type String instead of >> type >> Integer. >> >> Unfortunately PostgreSQL does not raises an error, but just a warning. >> >> In fact I have found such a problem in one of my programs only after a >> pg_dump + pg_restore: >> >> WARNING: foreign key constraint "b_id_fkey" will require costly >> sequential scans >> DETAIL: Key columns "id" and "id" are of different types: text and >> integer. >> >> >> What's the best method to avoid these bugs? >> >> It would be nice to have something like `salint`, that can scan a >> metadata searching for problems. >> >> Also, it would help if PostgreSQL warnings messages can be reported by >> psycopg/SQLAlchemy. >> Better if warnings can be considered like errors, thus raising an >> exception (something like the Werror option in GCC). > > if the warning is issued by Psycopg2, you can turn warnings into > exceptions using the warnings filter, > http://www.python.org/doc/lib/warning-filter.html > . If its not, then SA can't do anything about it, you'd have to > post on the psycopg2 list for this behavior to be supported. >
I have asked on the psycopg2 list. psycopg2 connection has a notices attribute. try: conn = db.connect() metadata.create_all(bind=conn) print conn.connection.connection.notices finally: metadata.drop_all() ['NOTICE: CREATE TABLE will create implicit sequence "a_id_seq" for serial column "a.id"\n', 'NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "a_pkey" for table "a"\n', 'NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "b_pkey" for table "b"\n', 'WARNING: foreign key constraint "b_id_fkey" will require costly sequential scans\nDETAIL: Key columns "id" and "id" are of different types: text and integer.\n'] So SQLAlchemy can process it, if this is reasonable. Manlio Perillo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---