When you say "generative", do you mean it returns a new object, as
opposed to in-place changes?

Would it make sense to rename Insert.values to Insert.params? Or make
Insert.params call Insert.values.
It seems quite strange for an object to have functions that aren't
usable...


Different, but related question: How do I print out the statement in
"copy-paste-able" format? More specifically, how do i get an ordered
list of bound values out of the statement?

This code does what I want, but it's really clunky and fragile:

def print_statement(stmt):
    s = str(stmt).replace("?", "%s")
    from re import search
    args = search("\((.*?)\)", s).group(1).split(", ")
    print s % tuple(repr(stmt.params[arg]) for arg in args)


On Nov 20, 5:29 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Nov 20, 2008, at 6:16 PM, bukzor wrote:
>
>
>
> > The second crashes with:
> >  File "/tools/aticad/1.0/external/python-2.4.1/lib/python2.4/site-
> > packages/SQLAlchemy-0.5.0rc4-py2.4.egg/sqlalchemy/sql/expression.py",
> > line 3515, in _copy_internals
> >    self.parameters = self.parameters.copy()
> > AttributeError: 'NoneType' object has no attribute 'copy'
>
> insert.params() was not the intended usage of the params() feature.  
> In r5313 I've added NotImplementedError when params() is called on all  
> Insert/Update/Delete constructs, since this feature is intended for  
> generative modification of select() statements and other clause  
> fragments.
>
> In this case you almost certainly mean to say insert.values(**params).
>
> The feature can be implemented for I/U/D but would require test  
> coverage, but also is concerning since the params() method modifies  
> all clause elements and is much more expensive than just calling  
> values().  I'd be concerned that people would inadvertently use it  
> without realizing that they really want to be calling values().
>
>
>
> > Should I use 0.4 instead? Is it more stable / less broken?
>
> there is no difference in 0.4 with regards to this behavior (except  
> that in 0.5, now its covered).  0.5 is overall much more stable/
> performant than 0.4 and is very close to final release.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to