On Oct 29, 9:33 pm, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
> Tvrtko wrote:
>
> >> transient objects can be merged.  They get added to the session and
> >> enter
> >> the pending state.
>
> > I get:
> > InvalidRequestError: merge() with dont_load=True option does not
> > support objects transient (i.e. unpersisted) objects.  flush() all
> > changes on mapped instances before merging with dont_load=True.
>
> right, if it were me I'd be caching things which I only loaded from the
> database entirely.  Or, if there are ad-hoc structures I'd like to cache,
> I'd construct that using non-ORM mapped constructs, or build it in such a
> way that I don't have to ever merge() it back, unless I'm doing a persist
> operation of some kind in which case I'd use full merge().

I agree. I am caching object loaded from database. This "transient"
problem is because of a workaround in which I create a copy of loaded
object to avoid merging entire object tree.

And, by the way, I had to add:

obj._state.commit(('user_id', 'name'))

to prevent sqlalchemy from issuing update :)

> >> dirty objects are also mergeable, but only if you allow the Session to
> >> load their existing state from the database (i.e. you dont use the
> >> 'dont_load' flag).   If you're playing with caching you shouldn't put
> >> dirty objects into a cache.
>
> > I need dont_load otherwise my caching isn't really caching.
>
> I need it too.  I just don't cache transient/dirty mapped objects.

Neither do I, normally :)

I'm still trying the cascade option, but I'm having some trouble
because I'm using Elixir on top of sqlalchemy. If I manage to do it
somehow, I'll post the update.

> However on the third digit, those are our point releases.  We're very
> careful not to introduce backwards incompatibility on those.    It's rare
> that we have regressions on those and when we do, we find out very quickly
> and another point release comes out almost immediately.  you can see
> 0.4.7p1 as evidence of that.   At most you might see some new deprecation
> warnings pop up.

I'm reluctant because I have a substantial amount of code which uses
sqlalchemy metadata to automatically generate CRUD operations, forms
and such.

I love sqlalhemy to the point of rejecting some frameworks for not
supporting it. The current version is working just fine and there is
so much other work to be done.

I', looking the changelog. There are some changes to merge(). I might
try 0.4.8 after all because I don't like to use underlined variables
like _state.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to