[sqlalchemy] 0.8.x - can't get correlation to work with nested subquery in column property

2013-06-05 Thread Yap Sok Ann
I am getting stuck trying to upgrade to 0.8.x, as I can't get correlation to work with nested subquery in column property. Here's a slightly absurd example for illustration: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base =

[sqlalchemy] 0.8 - `q.filter(None)` used to do nothing, now generates WHERE NULL

2012-12-18 Thread Yap Sok Ann
There are a few places in my code that does `q.filter(None)`, e.g. something like this: def base_filter(self): # subclasses may set this, or not pass def base_query(self): q = self.model_cls.query q = q.filter(self.base_filter()) return q

Re: [sqlalchemy] [Q] SQLSoup and pymssql from Linux

2012-10-12 Thread Yap Sok Ann
On Tuesday, October 9, 2012 10:19:34 PM UTC+8, Michael Bayer wrote: yeah, the whole FreeTDS story is awful, I don't understand any of it either. I'm still at wave a dead chicken stage with FreeTDS ( http://dictionary.reference.com/browse/wave+a+dead+chicken). The ODBC Driver 1.0 for

[sqlalchemy] autocommit=False, autoflush on begin, after_flush event, unintended side effect?

2012-09-12 Thread Yap Sok Ann
This is semi-related to the latest post from Kent. I just noticed that I have been abusing the autoflush on begin behavior (by the _take_snapshot() method in orm/session.py) to create additional instances within the after_flush Session Event. Here's some sample code to illustrate that:

[sqlalchemy] Documentation for joined table inheritance - Engineer.id renders as people.id

2012-06-17 Thread Yap Sok Ann
In the documentation for joined table inheritance [1], it mentions that: Note that above, the Engineer.id attribute, since it shares the same attribute name as the Person.id attribute, will in fact represent the people.id and engineers.id columns together, and will render inside a query as

Re: [sqlalchemy] Column alias created by SQLAlchemy is exeeding max column length of db2.

2012-04-21 Thread Yap Sok Ann
On Wednesday, June 24, 2009 10:25:09 PM UTC+8, Michael Bayer wrote: Beeno wrote: Hello Sqlalchemy appears to be aliasing each column in a SELECT statement as a concatenation of the schema, table name and column name. The resulting alias exceeds DB2's 30 character limit for a column.

[sqlalchemy] Re: Something in Pyramid is preventing gc on SQLAlchemy objects

2012-02-24 Thread Yap Sok Ann
I too encountered the same problem that wasted me days, until I caught pdtb_sqla_queries with my very limited memory profiling skill. I have actually filed a bug here: https://github.com/Pylons/pyramid_debugtoolbar/issues/51 and there is a separate issue to make it less leaky:

[sqlalchemy] Get a contains_eager collection to follow order_by

2011-11-20 Thread Yap Sok Ann
Is it possible to get a contains_eager collection to follow the order_by defined in the relationship? It seems like with eager loading, the order_by defined will just be ignored (which I think make sense, just wondering if there is a better way than manual sorting). Here's some sample code to

[sqlalchemy] Mapping a Class against Multiple Tables - how to define relationship

2011-11-13 Thread Yap Sok Ann
Using the second example in http://www.sqlalchemy.org/docs/orm/mapper_config.html#mapping-a-class-against-multiple-tables, how should I define relationship properties KeywordUser.keyword and KeywordUser.user? I tried different primaryjoin's, but when used as filter, e.g.

[sqlalchemy] Re: using @declared_attr to define a column in an actual class (non-mixin)

2011-09-23 Thread Yap Sok Ann
__abstract__ = True on the class - the @declared_attr's on columns should be recognized in that case.   You wouldn't want to have __tablename__ = 'test' on such a class either since it isn't mapped. On Sep 23, 2011, at 12:48 AM, Yap Sok Ann wrote: With this code: from

[sqlalchemy] using @declared_attr to define a column in an actual class (non-mixin)

2011-09-22 Thread Yap Sok Ann
With this code: from sqlalchemy.ext.declarative import declarative_base, declared_attr from sqlalchemy.schema import Column from sqlalchemy.types import Integer, String Base = declarative_base() class Mixin(object): @declared_attr def attr2(cls): return Column(String(20),

[sqlalchemy] discriminator_on_association.py - creating a Customer instance without specifying the addresses attribute

2011-06-27 Thread Yap Sok Ann
Using the discriminator_on_association.py example, if I create a Customer instance without specifying the addresses attribute, the for- loop at the end will throw exception: AttributeError: 'NoneType' object has no attribute 'addresses' It works if I specify addresses=[], but that sounds like

[sqlalchemy] problem with nested column_property's label in subquery

2011-05-17 Thread Yap Sok Ann
With the following code: # from sqlalchemy.engine import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import column_property, relation from sqlalchemy.orm import scoped_session, sessionmaker from

[sqlalchemy] Examples for Index() in 07Migration wiki

2011-04-22 Thread Yap Sok Ann
In the 07Migration wiki, there is this line: Index('name', name=idx_name) which doesn't work for me. I have to change it to: Index('idx_name', 'name') Is it a typo or some python 3 only syntax? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To

[sqlalchemy] declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Yap Sok Ann
This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9d2ab0b9cca Prior to version 0.6, I use the following code to automatically add a primary key if the table doesn't have one defined: from sqlalchemy.ext.declarative

[sqlalchemy] Re: declarative - automatically add a primary key if the table doesn't have one

2010-09-22 Thread Yap Sok Ann
On Sep 22, 11:37 pm, Michael Bayer mike...@zzzcomputing.com wrote: On Sep 22, 2010, at 4:30 AM, Yap Sok Ann wrote: This is related to topic need 0.6_beta2-compat declarative meta http://groups.google.com/group/sqlalchemy/browse_thread/thread/ae7cb9... Prior to version 0.6, I use

[sqlalchemy] Re: declarative base - can a relationship be used within a column_property?

2010-08-21 Thread Yap Sok Ann
On Aug 22, 2:12 am, Michael Bayer mike...@zzzcomputing.com wrote: On Aug 21, 2010, at 1:38 PM, Michael Bayer wrote: On Aug 19, 2010, at 6:38 AM, Yap Sok Ann wrote: With declarative base, is it possible to use a relationship within a column_property? you mean, as I am seeing below

[sqlalchemy] declarative base - can a relationship be used within a column_property?

2010-08-19 Thread Yap Sok Ann
With declarative base, is it possible to use a relationship within a column_property? Here's some sample code to illustrate what I want to achieve: from sqlalchemy.engine import create_engine from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import column_property,

[sqlalchemy] Using MapperExtension for timestamp - how to avoid related instances from being pulled in

2008-11-05 Thread Yap Sok Ann
I use a MapperExtension to automatically put the current timestamp into a updated_at column for all entities. This works fine except when related entities get involved. Let's say I have a Many-To-One relation between employees and departments. If I switch the department for an employee, even