[sqlalchemy] before_create receives a list of tuples in the `tables` kwarg since 1.0

2015-04-27 Thread Adrian
I just tried updating from 0.9.9 to 1.0.2 and noticed that this code is now 
broken (tuple object has no attribute schema):

def _before_create(target, connection, **kw):
schemas = {table.schema for table in kw['tables']}
for schema in schemas:

CreateSchema(schema).execute_if(callable_=_should_create_schema).execute(connection)

listen(db.Model.metadata, 'before_create', _before_create)



Is this change intentional? I couldn't find anything about it in the 1.0 
changelog.

-- 
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.


Re: [sqlalchemy] before_create receives a list of tuples in the `tables` kwarg since 1.0

2015-04-27 Thread Mike Bayer



On 4/27/15 2:43 PM, Mike Bayer wrote:



On 4/27/15 2:09 PM, Adrian wrote:
I just tried updating from 0.9.9 to 1.0.2 and noticed that this code 
is now broken (tuple object has no attribute schema):


def _before_create(target, connection, **kw):
schemas = {table.schema for table in kw['tables']}
for schema in schemas:
CreateSchema(schema).execute_if(callable_=_should_create_schema).execute(connection)

listen(db.Model.metadata, 'before_create', _before_create)



Is this change intentional? I couldn't find anything about it in the 
1.0 changelog.


OK, I think I should change this back because that was not 
intentional, so it's a regression, and I've added 
https://bitbucket.org/zzzeek/sqlalchemy/issue/3391/tables-collection-passed-to-before-after. 
Though I looked at the docstring and it does give me some room to just 
make changes:


 additional keyword arguments relevant to the event. The contents of 
this dictionary may vary across releases, and include the list of 
tables being generated for a metadata-level event, the checkfirst 
flag, and other elements used by internal events.


But the tables list here is actually there just for the purpose of 
end-user event listening so that should probably be maintained as it was.


that is now fixed in 
https://bitbucket.org/zzzeek/sqlalchemy/commits/e25ef01fbb70







--
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 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.