I attached a script that reproduces the problem. It actually only happens 
if the metadata contains a schema, then the tablename in the INHERITS() 
clause get quoted, which causes the problem.

On Monday, November 23, 2015 at 7:13:27 PM UTC+1, Adrian wrote:
>
> I actually I just found the problem; the tables are in fact created in the 
> right order - the problem is that the DDL contains INHERITS ( "parent" ). 
> It gives the same error if I try to run the code in a GUI with the 
> inherited table name quoted, without (the quoting) though it works. 
>
> On Mon, Nov 23, 2015 at 6:55 PM Mike Bayer <mike...@zzzcomputing.com> 
> wrote:
>
>>
>>
>> On 11/23/2015 12:43 PM, Adrian wrote:
>> > Hello,
>> >
>> > I have the following problem - I recently upgraded to the 1.0+ branch
>> > from 0.9 and now the PostgreSQL table inheritance does not work properly
>> > any longer because the tables that inherit from the master table are
>> > sometimes created before (random) the actual table they inherit from,
>> > throwing (psycopg2.ProgrammingError) relation "<table>" does not exist
>> > errors. With the 0.9+ branch a simple add_is_dependent_on was working to
>> > solve this but it does not seem to be taken into account anymore.
>>
>> this is not the case, that API is still taken into account.  I can
>> remove the code that does so and the test which exercises this feature
>> then fails, so it is also tested.
>>
>> Can you please provide a full reproducing test case?    It needs to be
>> succinct, single file, and runnable by me, thanks.
>>
>>
>>
>>
>> Is
>> > there something that changed from 0.9 to 1.0 that needs to be done to
>> > get it to work? metadata.sorted_tables returns the proper table order
>> > (master table first, dependencies later) though but tables are not
>> > created in that order by metadata.create_all().
>> >
>> > Thanks,
>> >
>> > Adrian
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "sqlalchemy" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to sqlalchemy+unsubscr...@googlegroups.com
>> > <mailto:sqlalchemy+unsubscr...@googlegroups.com>.
>> > To post to this group, send email to sqlalchemy@googlegroups.com
>> > <mailto:sqlalchemy@googlegroups.com>.
>> > Visit this group at http://groups.google.com/group/sqlalchemy.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "sqlalchemy" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/sqlalchemy/k4Lhj7i5sBM/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> sqlalchemy+unsubscr...@googlegroups.com.
>> To post to this group, send email to sqlalchemy@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sqlalchemy.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
from sqlalchemy import create_engine
from sqlalchemy.types import String
from sqlalchemy.engine.url import URL
from sqlalchemy import MetaData, Table, Column

url = URL(drivername="postgresql+psycopg2", username="",
          password="", host="localhost", port=5432, database="")

engine = create_engine(url, echo=True)

metadata = MetaData(bind=engine, schema="myschema")

parent = Table(
    "parent", metadata,
    Column("foo", String(4), nullable=False),
    prefixes=["UNLOGGED"])

child = Table(
    "child", metadata,
    Column("bar", String(4), nullable=False),
    postgresql_inherits=parent.fullname,
    prefixes=["UNLOGGED"])

child.add_is_dependent_on(parent)

metadata.drop_all(checkfirst=True)
metadata.create_all(checkfirst=True)

Reply via email to