the generative method on Select is select_from(): http://www.sqlalchemy.org/docs/core/expression_api.html?highlight=select_from#sqlalchemy.sql.expression.Select.select_from
Copying a select() is best performed via myselect._generate(). its a shallow copy and the select() tries to make sure it never mutates the state of internals - but also select's _generate() clears out a series of "cached" values that are derived from the internal state and that is definitely needed. I also spent 8 hours on an obscure bug involving all of this yesterday but that's unlikely to affect you. On Sep 6, 2011, at 4:47 AM, Torsten Landschoff wrote: > Hello *, > > (Using SQLAlchemy 0.6.8, but planning to move to 0.7 soon) > > I am trying to build queries dynamically and I have to add joins on the > primary table to be able to create my where-clauses. > > To add the join clause on my instance of Select, I found this > discussion: > > http://thread.gmane.org/gmane.comp.python.sqlalchemy.user/5910/focus=5917 > > Now I need to retain the original Select untouched (as it can be used to > derive other Select instances). I found out that all the interesting > methods on Select deliver a new copy using the @_generative decorator. > > For append_from, there does not seem to be a generative equivalent. > Therefore I want to roll it manually, but I don't really want to call > the private _generate method. > > Therefore I am wondering if there is a canonical way to copy an instance > of Select. It seems that pickling is supported (__getstate__ and > __setstate__ are provided). > > However, the class 'sqlalchemy.sql.expression._SelectBaseMixin overrides > _generate to "to also clear out exported collections". However, the > __getstate__ implementation comes from ClauseElement. > > > My question: Is it supported to do > > from copy import copy > new_select = copy(old_select) > > where old_select is an instance of Select? Are there any plans to add a > generative way to extend the froms of a Select? ;-) > > > Thanks and Greetings, Torsten > > -- > DYNAmore Gesellschaft fuer Ingenieurdienstleistungen mbH > Torsten Landschoff > > Office Dresden > Tel: +49-(0)351-4519587 > Fax: +49-(0)351-4519561 > > mailto:torsten.landsch...@dynamore.de > http://www.dynamore.de > > Registration court: Mannheim, HRB: 109659, based in Karlsruhe, > Managing director: Prof. Dr. K. Schweizerhof, Dipl.-Math. U. Franz > > -- > 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. > -- 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.