[sqlalchemy] Re: Assigning to a deferred column

2010-11-20 Thread Eoghan Murray
On Nov 19, 8:14 pm, Michael Bayer mike...@zzzcomputing.com wrote: The ORM uses attribute set events to flag changes.    It then uses the previous value, if present, to determine if a change has taken place at flush time, and if so issues an UPDATE.   If previous is not present, in most

[sqlalchemy] Longer tuple passed to query.get doesn't throw exception

2010-11-19 Thread Eoghan Murray
With a class with 3 primary key columns, e.g. class MyClass(Entity): a = Field(Unicode(64), primary_key=True) b = Field(Unicode(64), primary_key=True) c = Field(Unicode(64), primary_key=True) ... If you pass 4 values to query.get; MyClass.get(('a_val',

[sqlalchemy] Re: Assigning to a deferred column

2010-11-19 Thread Eoghan Murray
).  If so, the mutability flag should be disabled. On Nov 4, 2010, at 7:05 AM, Eoghan Murray wrote: I have the following:    objs = MyTable.query.options(defer(Table.potentially_very_long_str_column)).all()    for obj in objs:         obj.potentially_very_long_str_column

[sqlalchemy] Assigning to a deferred column

2010-11-04 Thread Eoghan Murray
I have the following: objs = MyTable.query.options(defer(Table.potentially_very_long_str_column)).all() for obj in objs: obj.potentially_very_long_str_column = '' At the moment, I'm seeing the assignment in the loop issue the `SELECT potentially_very_long_str_column`, even

[sqlalchemy] Augmenting Existing Types, 0.5-0.6

2010-10-22 Thread Eoghan Murray
Hi, I've the following code that works fine in 0.5.8 from sqlalchemy.types import Interval as SAInterval class Interval(SAInterval): def process_bind_param(self, value, engine): coerce to a timedelta if value is not None: value =

[sqlalchemy] Re: Augmenting Existing Types, 0.5-0.6

2010-10-22 Thread Eoghan Murray
, i think the contract of TypeDecorator is that you don't need to deal with super().   But the funny thing about Interval is its already a TypeDecorator, but the idea should be the same (in 0.5 too...) Ya, I just had a look at the 0.5.8 docs;

[sqlalchemy] Re: Renaming Columns and Union - possible bug

2009-01-03 Thread Eoghan Murray
On Jan 3, 2:44 am, Michael Bayer mike...@zzzcomputing.com wrote: I've made fixes to corresponding_column() to resolve this issue, and in the process uncovered (and also solved) a whole class of problems in that method which was, to my great surprise, also impacting some very nested Query

[sqlalchemy] Re: Renaming Columns and Union - possible bug

2009-01-02 Thread Eoghan Murray
On Dec 22 2008, 7:10 pm, Eoghan Murray eoghanomur...@gmail.com wrote: On Dec 22, 4:16 pm, Gaetan de Menten gdemen...@gmail.com wrote: I'm not sure what you are trying to do, but MyE.f_1 and MyE.f_2 are not column objects. f_1_id and f_2_id are. Sorry, I edited down my example from

[sqlalchemy] Re: Renaming Columns and Union - possible bug

2009-01-02 Thread Eoghan Murray
On Jan 2, 10:41 pm, Michael Bayer mike...@zzzcomputing.com wrote: It would help if you could illustrate with accurate code - the UNION   above does not have consistent numbers of columns in each select() and   I think what you're trying to do is reverse f_1 and f_2 in the second   select()

[sqlalchemy] Renaming Columns and Union - possible bug

2008-12-22 Thread Eoghan Murray
The following example uses an elixir class: class MyE(Entity): id = Field(Integer, primary_key=True) f_1 = ManyToOne('OtherE') f_2 = ManyToOne('OtherE') date = Field(Date) MyE.query.select_from(union(MyE.table.select(), select([MyE.id,

[sqlalchemy] Re: ProgrammingError and Catching an Exception

2008-09-12 Thread Eoghan Murray
this: session.begin() try:     ...     session.flush()     session.commit() except:     session.rollback() Eoghan Murray wrote: Hi, I've the following which generates an insert: try:     MyDBLog(         myfield='A too long string '     ) except Exception, e

[sqlalchemy] ProgrammingError and Catching an Exception

2008-09-11 Thread Eoghan Murray
Hi, I've the following which generates an insert: try: MyDBLog( myfield='A too long string ' ) except Exception, e: log.error(Exception occurred with database logging: %s % e) Unfortunately, 'myfield' is (for example) a string of only length 10, so the session

[sqlalchemy] Interval and mx.TimeDelta

2008-05-29 Thread Eoghan Murray
Hi, I'm trying to use mx.TimeDelta instead of datetime.timedelta on an Interval column (with Postgres). It seems to work fine until I get to intervals a day, at which point it fails with: ProgrammingError: (ProgrammingError) invalid input syntax for type interval: 1:00:00:00.00 'INSERT INTO

[sqlalchemy] ORM Join with explicit Alias

2008-01-20 Thread Eoghan Murray
Hi All, I wish to do an aliased join similar to the last example in the section http://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins session.query(User).\ ... join('addresses', aliased=True).filter(Address.email_address=='[EMAIL PROTECTED]').\ ... join('addresses',

[sqlalchemy] Re: ORM Join with explicit Alias

2008-01-20 Thread Eoghan Murray
On Jan 21, 12:12 am, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 20, 2008, at 6:52 PM, Eoghan Murray wrote: Hi All, I wish to do an aliased join similar to the last example in the sectionhttp://www.sqlalchemy.org/docs/04/ormtutorial.html#datamapping_joins session.query(User

[sqlalchemy] Re: in operator and literal list

2008-01-09 Thread Eoghan Murray
On Jan 8, 11:13 pm, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 8, 2008, at 5:40 PM, Eoghan Murray wrote: On Jan 8, 7:28 pm, Jonathan Gardner [EMAIL PROTECTED] wrote: Eoghan Murray wrote: Ideally this would be expressed as: MyTable.filter(MyTable.c.MyColumn.in(ls)) Try

[sqlalchemy] in operator and literal list

2008-01-08 Thread Eoghan Murray
Hi All, I'm wondering if there is a more elegant way to construct the following piece of SQL: SELECT * from MyTable where MyTable.MyColumn in ('foo', 'bar', 'baz'); The best I've come up with is the following: ls = ['foo', 'bar', 'baz'] ls_str = str(ls).replace('[', '(').replace(']',')')