On Mar 28, 8:05 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
> the error means the object was loaded from the database in some session.  
> it can't be sent to save().   if you send it to save_or_update() or add(),
> it's already INSERTed as far as SQLA is concerned.
>
> each test you create should not use any instances of your mapped entities
> from the previous test.  when you remove the session, all state which was
> associated with that session should be discarded.  you could alternatively
> try to re-add those objects back in but that's cumbersome.

Thanks Mike. I figured this is probably not the intended use. The
thing is, I'm trying to make a declarative template for test seed data
and declaring it all in a class like so makes for the easiest quickest
way of extending my fixture:

class SeedData1(SeedData):
  obj1 = ModelObject( ...kwargs... )
  obj2 = ModelObject2( ...kwargs...

This allows me to make new seed data fixtures by simply inheriting
from SeedData1, and makes typing up seed fixtures dead quick.

Sooo, even if it is cumbersome, if you could tell me how to bypass
SQLA's knowledge that these have already been persisted and readd the
objects in that would be great. The cumbersome jiggery pokery will all
be hidden in a test utility method so I'm fine with ugliness in there
in order to make writing the test fixtures as quick as possible. Or

Thanks for all the help
Iain

--~--~---------~--~----~------------~-------~--~----~
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 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to