Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-25 Thread Mike Bayer
On 6/25/15 1:34 PM, Kevin Qiu wrote: Thanks a lot. I assume you mean polymorphic_identity refers to the table name not the class name. It would be nice that the document can be point this out explicitly, because the example in the document shows both table name and class name are both small l

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-25 Thread Kevin Qiu
Thanks a lot. I assume you mean polymorphic_identity refers to the table name not the class name. It would be nice that the document can be point this out explicitly, because the example in the document shows both table name and class name are both small letter, can't tell the difference . In my hu

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-23 Thread Mike Bayer
On 6/23/15 6:06 AM, Kevin Qiu wrote: Thanks for response. How do you delete the joined table object of ProjApp. A direct delete won't do: mydb.session.delete(projApp) mydb.session.commit() the following error arises: "sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation "APPLICATION"

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-23 Thread Kevin Qiu
Thanks for response. How do you delete the joined table object of ProjApp. A direct delete won't do: mydb.session.delete(projApp) mydb.session.commit() the following error arises: "sqlalchemy.exc.ProgrammingError: (ProgrammingError) relation "APPLICATION" does not exist LINE 2: FROM "APPLICATION" J

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-21 Thread Mike Bayer
On 6/21/15 1:46 PM, Kevin Qiu wrote: It's a test db, there's only one record being added to the table. And I ensure that with a assertIn() test and it passes. The original code was: class Application(mydb.Model): __tablename__ = 'APPLICATION' app_id = mydb.Column(mydb.Integer, primary_key = Tr

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-21 Thread Mike Bayer
is it the same row? same primary key? otherwise what is the SQL being emitted, what are the results? try echo='debug'? On 6/21/15 1:46 PM, Kevin Qiu wrote: It's a test db, there's only one record being added to the table. And I ensure that with a assertIn() test and it passes. The original

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-21 Thread Kevin Qiu
It's a test db, there's only one record being added to the table. And I ensure that with a assertIn() test and it passes. The original code was: class Application(mydb.Model): __tablename__ = 'APPLICATION' app_id = mydb.Column(mydb.Integer, primary_key = True)#app_id = mydb.Column(mydb.String(30

Re: [sqlalchemy] joined table inheritance child table query return different object after insertion

2015-06-21 Thread Mike Bayer
did you try adding an ORDER BY to that query? calling query.first() will return only the first result in an unordered list. It is essentially random. On 6/21/15 12:45 PM, Kevin Qiu wrote: I create a unit test that add new ProjApp object to the database, but the returned object shows it is n

Re: [sqlalchemy] joined-table inheritance and ambiguous foreign keys

2013-07-24 Thread Seth P
Thank you. On Wed, Jul 24, 2013 at 5:51 PM, Michael Bayer wrote: > its a mapper arg called inherit_condition: __mapper_args__ = > {"inherit_condition": id==A.id} > > On Jul 24, 2013, at 3:42 PM, Seth P wrote: > > The code below produces the error message below. How do I tell SQLAlchemy > that

Re: [sqlalchemy] joined-table inheritance and ambiguous foreign keys

2013-07-24 Thread Michael Bayer
its a mapper arg called inherit_condition: __mapper_args__ = {"inherit_condition": id==A.id} On Jul 24, 2013, at 3:42 PM, Seth P wrote: > The code below produces the error message below. How do I tell SQLAlchemy > that the inheritance join condition should be b.id == a.id rather than > b.par

Re: Re: [sqlalchemy] joined table inheritance

2012-01-18 Thread Martijn Moeling
You are welcome, I get a lot of help from here, taking some load of Michael's back is the least I can do. I got the idea from your story that you needed to understand how the mechanics are. I'm blessed in having very complex polymorphic self relating setups with lots of mixins and Object funct

Re: [sqlalchemy] joined table inheritance

2012-01-18 Thread Martijn Moeling
That is not going to work. let me explain: Polymorphic inheritance uses tables and discriminators and some logic somewhere in the system. (As far as I can tell both SA and databases can do the job, i have to look into that) For each object there will be a table, including the "base" object.

Re: [sqlalchemy] Joined table inheritance and passive deletes

2011-12-15 Thread Michael Bayer
On Dec 15, 2011, at 4:06 AM, Pedro Romano wrote: > Hi! Tried searching around for information on this topic but couldn't > find anything, so here's the question: is it possible to use passive > deletes with joined table inheritance? Setting the > 'ondelete="CASCADE"' on the foreign key declaratio

Re: [sqlalchemy] Joined Table Inheritance question

2011-03-10 Thread Kontakt
> class EmployeeChecker(MapperExtension): >def before_insert(self, mapper, connection, target): >if type(target) != Employee: Must be == -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@

Re: [sqlalchemy] Joined Table Inheritance question

2011-03-10 Thread Tobias Müller
> However in my case I don't want to be able to persist some random Employee. > All my employees should be engineers or managers. Ideally some exception > should be thrown if I try to add an Employee object to my session. Maybe something like this. But I'm not sure if it's the right way. It fai

Re: [sqlalchemy] Joined Table Inheritance

2010-05-20 Thread Michael Bayer
On May 20, 2010, at 10:20 AM, bogun.dmit...@gmail.com wrote: > Hello. > > Is there any way I can use some expression for polymorphic_on mapper > attribute? You can get this behavior now with some effort if you create a SELECT statement that loads the full row, including your "discriminator",

Re: [sqlalchemy] Joined Table Inheritance and Mapping:Child classes do not pick up maps to other tables

2010-04-06 Thread Michael Bayer
On Apr 6, 2010, at 3:56 PM, Josh Winslow wrote: I'm attempting to use joined table polymorphism for various types of activities. Activities all share a few common features, a location, a reference number, time, etc. but some have some further attributes. When I set up my map like so: mapp

Re: [sqlalchemy] Joined table inheritance without a discriminator

2010-01-15 Thread Michael Bayer
Ian wrote: > All, > > I have two applications: one uses Python with Sqlalchemy and the other > uses Java with Hibernate. There is a slight mis-match between the > joined table inheritance strategy: with Hibernate a discriminator is > not required. > > The Sqlalchemy documentation says, in the Joine