Ticket #6 (assigned enhancement)

Opened 10 months ago

Last modified 9 months ago

Support for creating tables strictly sequentially.

Reported by: kgi Assigned to: edsuom (accepted)
Priority: major Milestone:
Component: sAsync Version:
Keywords: Cc:

Description

This patch optionally allows the user to create tables in strict sequence.

When using the usual table() method to create lots of tables with foreign keys, I have sometimes seen table creation fail with a message saying the referenced table does not exist. This is using PostgreSQL 8.2; other DBs may not exhibit this behaviour.

This appears to be a rare race condition somewhere in the interaction between the DB, the access library, SQLAlchemy and sAsync. Once the tables are created successfully, everything seems to work normally.

This patch adds two new methods to the AccessBroker object: autoTable() and finishedCreatingTables().

One uses autoTable() exactly as one uses table() within startup(), but one appends a call to finishedCreatingTables() at the end of the method. This returns a deferred which fires with a list of 2-tuples, much as using a DeferredList? would.

For example:

def startup ( self ):
    self.autoTable (
            'foo',
            C ( 'foo1', sa.Integer, primary_key = True ),
            C ( 'foo2', sa.String() ),
    )
    self.autoTable (
            'bar',
            C ( 'bar1', sa.Integer, primary_key = True ),
            C ( 'bar2', sa.String() ),
    )
    return self.finishedCreatingTables()

Attachments

sasync-tables.diff (2.9 kB) - added by kgi on 02/08/08 05:59:33.

Change History

02/08/08 05:59:33 changed by kgi

  • attachment sasync-tables.diff added.

03/22/08 21:07:58 changed by edsuom

  • status changed from new to assigned.

Thanks! I'll incorporate this and get some tests written for it.