Re: [sqlalchemy] Composite foreign keys which has common parent foreign key in SQLalchemy

2015-06-26 Thread Kevin Qiu
at 8:17 PM, Mike Bayer mike...@zzzcomputing.com wrote: On 6/25/15 2:08 PM, Kevin Qiu wrote: In the SQLalchemy documentation http://docs.sqlalchemy.org/en/latest/orm/inheritance.html#basic-control-of-which-tables-are-queried, it states It is standard practice that the same column is used

[sqlalchemy] Composite foreign keys which has common parent foreign key in SQLalchemy

2015-06-25 Thread Kevin Qiu
In the SQLalchemy documentation http://docs.sqlalchemy.org/en/latest/orm/inheritance.html#basic-control-of-which-tables-are-queried, it states It is standard practice that the same column is used for both the role of primary key as well as foreign key to the parent table, and that the

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

2015-06-23 Thread Kevin Qiu
...@zzzcomputing.com wrote: 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

[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:

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

2015-06-21 Thread Kevin Qiu
/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 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

[sqlalchemy] NameError: name 'Index' is not defined

2015-06-18 Thread Kevin Qiu
I try to define composite index on last_name, first_name on flask-sqlalchemy, the error says NameError: name 'Index' is not defined Code: class Student(mydb.Model): __tablename__ = 'STUDENT' __table_args__ = (Index('SearchNameIndices', last_name, first_name), ) study_no =

[sqlalchemy] relationship supersedes the same relationship on inherited mapper can cause dependency issues during flush

2015-06-18 Thread Kevin Qiu
Error: SAWarning: Warning: relationship 'staff_obj' on mapper 'Mapper|ProjectApp|PROJECT_APP' supersedes the same relationship on inherited mapper 'Mapper|Application|APPLICATION'; this can cause dependency issues during flush self._check_conflicts() Application is a parent class which can't

Re: [sqlalchemy] Detect whether a query already has a join on a table?

2012-11-22 Thread Kevin Qiu
In my example, the extra join was brought in by the relationship `Thing.user`. Because the query was on Thing, and the filtering criteria is on `User`, which, if I'm not mistaken, causes sqlalchemy to consult the mapper and bring in the relationship between `Thing` and `User`. Anyway, I think