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

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

2015-06-21 Thread Kevin Qiu
I create a unit test that add new ProjApp object to the database, but the returned object shows it is not the same object inserted, I don't follow why it's like this because I have others tests on inserting a row to a different table, and returned shows the same row object. Test result:

[sqlalchemy] Joined table inheritance - get inherited class object

2014-09-26 Thread Alexey Vihorev
Hi! I got this class arrangement: class Document(Base): doc_number = Column(:) doc_date = Column(:) : class Invoice(Document) class CashOrder(Document) class BankTransaction(Document) It's joined table inheritance, Document has a table with discriminator etc. So,

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

[sqlalchemy] joined-table inheritance and ambiguous foreign keys

2013-07-24 Thread Seth P
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.parent_a_id == a.id? (I would think the primary_key=True could be a hint...) I can't figure it out from the documentation. class A(Base): __tab

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.

[sqlalchemy] joined table inheritance

2012-01-18 Thread Thierry
Hi I'm trying to mimick the example from the documentation (employee/ manager/engineer) I've been able to add employees, and engineers, and all works as expected now my next step would be, creating an 'Employee' object, and some time later, decide that he's in fact an engineer. so my first atte

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

[sqlalchemy] Joined table inheritance and passive deletes

2011-12-15 Thread Pedro Romano
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 declaration of the child class primary key is trivial, however there

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

[sqlalchemy] Joined Table Inheritance question

2011-03-10 Thread Franck
Hi, I read carefully the documentation at http://www.sqlalchemy.org/docs/orm/inheritance.html and I'd like to implement a similar joined table inheritance for my application. The following example is provided : *mapper(Employee, employees, polymorphic_on=employees.c.type, polymorphic_identity='e

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",

[sqlalchemy] Joined Table Inheritance

2010-05-20 Thread bogun . dmitriy
Hello. Is there any way I can use some expression for polymorphic_on mapper attribute? I have tried some ways, but not got what I want. # --- my tries import sqlalchemy as sa from sqlalchemy import * from sqlalchemy import orm from sqlalchemy.ext.declarative import declarative_base _decl = decl

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

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

2010-04-06 Thread Josh Winslow
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: mapper(Activity, activities, polymorphic_on=activities.c.typ

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

[sqlalchemy] Joined table inheritance without a discriminator

2010-01-15 Thread Ian
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 Joined Table Inheritance secti

[sqlalchemy] joined table inheritance + graph pattern

2009-10-02 Thread Thomas Drake
Hi, I'm struggling trying to merge two patterns which separately are no- brainers in sqa: joined tabled inheritance and (an arbitrary number of) graph relationships, here represented as connections and dependencies. I've run into quite a few different errors from the following code using version

[sqlalchemy] joined table inheritance, association object between base class

2009-06-26 Thread Sp
-Base entity is Party, which has sub-types Person and Organization. -Using joined table inheritance, with base table 'parties', and sub- tables 'people' and 'organizations' -Want to create association class to capture various types of relationships between parties. Let's say this association woul

[sqlalchemy] Joined table inheritance mapping issues

2009-05-18 Thread Nathan Harmston
Hi, I am playing with the mapping inheritance structures to my database. I have a the following hierarchy: class Tag(object): pass class NormalisedNameTag(Tag): pass class NormalisedPlaceTag(Tag): pass The idea is that a pre-processing step will produce a series of tags and then

[sqlalchemy] Joined Table inheritance with more than one Foreignkey from child to parent

2008-11-12 Thread tante
I'm working on a system that has a Base class called Object. Many other classes inherit from this one class via joined table inheritance and it's working great. But now there's a problem: The subclass "Comment" does reference "Object" twice, once for the inheritance and once as a ForeignKey to mar

[sqlalchemy] Joined Table Inheritance

2008-02-18 Thread Julien Cigar
Hello, I'm busy to play with (joinded) inheritance in SQLAlchemy. I have to design and implement a CMS-like app and my idea was to do something like (it's the SQL script) : http://pastebin.com/m35f5227d As you can see it's a classic inheritance situation: a base Content (abstract) which is of a

[sqlalchemy] Joined Table Inheritance and One-to-One headache

2007-11-13 Thread Alexandre Conrad
Hi, I've attached a test script as I'm confused with what I'm trying to do. I have the following scenario: - A Channel object is TV channel: class Channel: pass - A Playlist object is a piece of a channel's TV program. class Playlist: pass - A Playlist can be declined as different