[sqlalchemy] Problems with merge relations

2008-01-30 Thread Paul-Michael Agapow
I'm using merge to push objects into a db. (Long story short: I have a set of objects that have to behave identically if they are persisted or not, and may be retrieved or sent to a set of databases. Hence the use of merge.) However, merged objects appear object joined by a relation and

[sqlalchemy] Re: odd question

2008-01-30 Thread Gaetan de Menten
On Jan 23, 2008 10:24 PM, Monty Taylor [EMAIL PROTECTED] wrote: This may or may not be elixir specific... If I have an auto-generated mapping table for a many-to-many relationship, is there a sensible way to add another column to it that's also has a foreign key relationship to a third

[sqlalchemy] Re: a way to share Session.mapper(SomeObject) across two scoped sessions?

2008-01-30 Thread Gaetan de Menten
On Jan 25, 2008 9:18 PM, Michael Bayer [EMAIL PROTECTED] wrote: On Jan 25, 2008, at 2:02 PM, Kumar McMillan wrote: On Jan 25, 2008 11:58 AM, Michael Bayer [EMAIL PROTECTED] wrote: The Session.mapper function is not worth it, in my opinion, it exists due to the sheer popularity of

[sqlalchemy] Re: a way to share Session.mapper(SomeObject) across two scoped sessions?

2008-01-30 Thread Jonathan LaCour
Gaetan de Menten wrote: The only thing, is that we still provide a default session, which is based on Session.mapper, for convenience and backward compatibility. Maybe we should state more prominently in the Elixir doc that this is only a default session and that you can use any session you

[sqlalchemy] Re: Problems with merge relations

2008-01-30 Thread Michael Bayer
its the backref. as a temporary workaround you can remove it for merge() to function properly. fix wil be out today and very possible release 0.4.3 will be today for this. On Jan 30, 2008, at 6:14 AM, Paul-Michael Agapow wrote: from sqlalchemy import * from sqlalchemy.orm import

[sqlalchemy] Re: Problems with merge relations

2008-01-30 Thread Michael Bayer
OK this issue is actually limited to transient objects only; that is, if you had flushed your session before doing the merge() it would have worked. The fix is in r4104. Im considering putting out 0.4.3 today as a mostly bugfix release but have not decided yet. On Jan 30, 2008, at 6:14

[sqlalchemy] Re: Problems with merge relations

2008-01-30 Thread Michael Bayer
On Jan 30, 2008, at 12:39 PM, Michael Bayer wrote: OK this issue is actually limited to transient objects only; that is, if you had flushed your session before doing the merge() it would have worked. The fix is in r4104. Im considering putting out 0.4.3 today as a mostly bugfix

[sqlalchemy] Questions on MapperExtension

2008-01-30 Thread Ross
Hello, I have recently converted a Pylons app from SQLObject to SQLAlchemy 0.3.10. Conversion went quite well. I need to serialize access to some of my objects, so I've looked into extending MapperExtension as described at [1] to add a mutex on load. First, I define an extension and

[sqlalchemy] Re: Questions on MapperExtension

2008-01-30 Thread Michael Bayer
sorry, the docstring is wrong. create_instance() should return EXT_CONTINUE if it would like to bypass creating the instance itself. However, self here is the MapperExtension instance, not the mapped instance. the method is called before anything is created. if you want to populate an

[sqlalchemy] Re: DPAPI Error

2008-01-30 Thread Michael Bayer
On Jan 30, 2008, at 2:10 PM, jon wrote: Thanks for getting back to me and apologies for the stacktrace barf ;-) One thing...I have the following line in my environment.py: config['pylons.g'].sa_engine = engine_from_config(config, 'sqlalchemy.', convert_unicode=True, pool_size=1,

[sqlalchemy] Re: Questions on MapperExtension

2008-01-30 Thread jason kirtland
On 0.3.x, use EXT_PASS rather than EXT_CONTINUE. Michael Bayer wrote: sorry, the docstring is wrong. create_instance() should return EXT_CONTINUE if it would like to bypass creating the instance itself. However, self here is the MapperExtension instance, not the mapped instance.

[sqlalchemy] Re: Questions on MapperExtension

2008-01-30 Thread Michael Bayer
oh, 0.3. well theres another question. If you just converted from SQLObject, why to SA 0.3 ? 0.4 is the currently supported version and is also vastly superior to 0.3. On Jan 30, 2008, at 2:40 PM, jason kirtland wrote: On 0.3.x, use EXT_PASS rather than EXT_CONTINUE. Michael Bayer

[sqlalchemy] Re: DPAPI Error

2008-01-30 Thread jon
Hi Mike, Thanks for your patience...here is the entry I have for that table in model/__init__.py role_table = Table('role', metadata, Column('roleseq', Integer, Sequence('roleseq'), primary_key=True), I know that I specifically didn't set things up for Unicode in this app

[sqlalchemy] Re: Questions on MapperExtension

2008-01-30 Thread Ross
Thanks - populate_instance does exactly what I was looking for! I went to SA 0.3 with SAContext because I was familiar with it. Porting from SQLObject was straightforward, but a fairly large task. From reading at pylonshq, converting 0.3 to 0.4 seemed to be much easier than converting SQLObject

[sqlalchemy] Re: DPAPI Error

2008-01-30 Thread Michael Bayer
hey jon - OK, I found an issue that is very likely to be what you are experiencing; easy to fix as always but unless you can run on SVN trunk r4106, you'll have to workaround it. There may be a schema identifier somewhere in your app that contains the identifier 'roleseq' as a unicode

[sqlalchemy] Re: select.count() vs MSSQL

2008-01-30 Thread Rick Morrison
...or is select.alias().count().scalar()the standard way to do this? On Jan 30, 2008 7:29 PM, Rick Morrison [EMAIL PROTECTED] wrote: Just noticed that select.count() doesn't work on MSSQL. The implementation wraps the select() in an outer query; MSSQL requires an alias for the inner

[sqlalchemy] Re: select.count() vs MSSQL

2008-01-30 Thread Michael Bayer
youd have to override visit_select() and pick up on compiler.is_subquery(). you could then do some tricks similar to what oracle.py does in visit_select() to create a wrapping layer. also i noticed the usage of a kwarg 'mssql_aliased' which seems to be referenced nowhere. On Jan 30,

[sqlalchemy] Re: SQLAlchemy advanced tutorial at PyCon

2008-01-30 Thread Tim Lesher
On Jan 28, 4:23 pm, Jonathan Ellis [EMAIL PROTECTED] wrote: What would you like to see covered in an advanced SQLAlchemy session? Something on association objects would be good. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

[sqlalchemy] Re: select.count() vs MSSQL

2008-01-30 Thread Rick Morrison
Thanks Mike, I've got my local visit_select() a bit munged-up right now with an implementation of OFFSET, so I'm going to wait a bit on this. In the meantime, a follow-up: Not every MSSQL subquery needs to be aliased, only when the subquery is used as a derived table, as the SA implementation of

[sqlalchemy] Re: select.count() vs MSSQL

2008-01-30 Thread Michael Bayer
On Jan 30, 2008, at 10:52 PM, Rick Morrison wrote: Thanks Mike, I've got my local visit_select() a bit munged-up right now with an implementation of OFFSET, so I'm going to wait a bit on this. In the meantime, a follow-up: Not every MSSQL subquery needs to be aliased, only when the

[sqlalchemy] Re: select.count() vs MSSQL

2008-01-30 Thread Michael Bayer
On Jan 30, 2008, at 11:08 PM, Michael Bayer wrote: you can in fact alias whatever select you want, i think. select.count() doesn't produce any kind of special construct that could be detected in the compiler. there is the notion that subqueries which are used as scalar subqueries, i.e.