[sqlalchemy] with_polymorphic query and parent attribute filtering

2012-11-13 Thread tonthon
Hi, I'm using polymorphism for some of my models and I'm wondering how I should use the with_polymorphic query method. Consider the following: class A(Base): type_ = Column(Integer, nullable=False) arg = Column(String(20)) __mapper_args__ = {'polymorphic_on': type_,

Re: [sqlalchemy] All column names renames: best practice?

2012-11-13 Thread Petr Blahos
the company I worked for has decided to change a RDBMS behind our ERP. The side effect of this is that the columns will no longer be prefixed with *t$* but with* t_* instead. I do not want to change all the occurences of column names in my code. I should also mention, that I use only

Re: [sqlalchemy] [Q] Move elements in one-to-many relationship to a new owner

2012-11-13 Thread Ladislav Lenart
Hello. I was unable to reproduce the problem on your test example. I THINK it does exactly what my problematic code does. It seems that either the problem is more elaborate (but I don't see it) or I have a bug somewhere in my code. However my simple workaround works, so I consider the problem

Re: [sqlalchemy] SQLAlchemy sending a rollback after each commit

2012-11-13 Thread ckv
Thanks, I will stick to the default as it is not causing too much trouble. One more thing I have been noticing in the last couple of days is that a row I'm querying in the database using filter_by() on three predicates and limited by first() is being returned as None. I turned on mysql query

[sqlalchemy] automatically casting a class to a subclass via polymorphic discriminator?

2012-11-13 Thread Gerald Thibault
I have a base class which has two subclasses specified via a polymorphic discriminator, and I'm wondering how to set things up so the returned results are instances of the subclass, when I create an instance of the base class and assign the relevant value to the discriminator column. Here's my

Re: [sqlalchemy] All column names renames: best practice?

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 5:18 AM, Petr Blahos wrote: I have been unlucky with mssql, where the first part - the table definition and making queries worked, but not accessing data in RowProxy using the key. I guess there is a bug in dialects/mssql/base.py in MSSQLCompiler.visit_column:

Re: [sqlalchemy] SQLAlchemy sending a rollback after each commit

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 12:28 PM, ckv wrote: Thanks, I will stick to the default as it is not causing too much trouble. One more thing I have been noticing in the last couple of days is that a row I'm querying in the database using filter_by() on three predicates and limited by first() is

Re: [sqlalchemy] automatically casting a class to a subclass via polymorphic discriminator?

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 7:59 PM, Gerald Thibault wrote: I have a base class which has two subclasses specified via a polymorphic discriminator, and I'm wondering how to set things up so the returned results are instances of the subclass, when I create an instance of the base class and assign

Re: [sqlalchemy] Backref confusion

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 11:03 PM, Bobby Impollonia wrote: I have constructed a sample program consisting of two mapped classes (using sqlalchemy.ext.declarative) that have a relationship/ backref between them. At runtime the program does the following: 1) Print whether the parent class has an

Re: [sqlalchemy] with_polymorphic query and parent attribute filtering

2012-11-13 Thread Michael Bayer
On Nov 13, 2012, at 3:34 AM, tonthon wrote: Hi, I'm using polymorphism for some of my models and I'm wondering how I should use the with_polymorphic query method. Consider the following: class A(Base): type_ = Column(Integer, nullable=False) arg = Column(String(20))

Re: [sqlalchemy] (SQLite) Outside auto-locking based on SQLAlchemy Events

2012-11-13 Thread Michael Bayer
On Nov 12, 2012, at 9:37 PM, Michael Bayer wrote: On Nov 12, 2012, at 5:33 PM, Torsten Landschoff wrote: BTW, I found one offender that breaks running database upgrades with my locking schemes: from sqlalchemy import * from sqlalchemy.pool import * engine =

Re: [sqlalchemy] Backref confusion

2012-11-13 Thread Bobby Impollonia
Thank you! That is exactly the function I needed. On Tuesday, November 13, 2012 9:16:47 PM UTC-8, Michael Bayer wrote: On Nov 13, 2012, at 11:03 PM, Bobby Impollonia wrote: I have constructed a sample program consisting of two mapped classes (using sqlalchemy.ext.declarative) that have a