SQLAlchemy mangles identifiers that have dollar signs in them; in
particular, the regular expression in ANSICompiler.after_compile()
that searches a statement for positional parameters will take a
parameter like

  :foo$bar

and only snatch the "foo" out of it, instead of "foo$bar".  The error
that results is rather obscure, since the fact that the positional
parameters now contain "foo" while the "bind" list contains "foo$bar"
does not cause an error until the session is flushed and it attempts
to run the SQL statements; the error looks something like:

File ".../sqlalchemy/sql.py", line 845, in get_processed
  bind = self.binds[key]
KeyError: 'foo'

A patch that corrects the bug is attached.

-- 
Brandon Craig Rhodes   [EMAIL PROTECTED]   http://rhodesmill.org/brandon


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

--- ./sqlalchemy/ansisql.py.orig	2007-08-09 11:54:06.000000000 -0400
+++ ./sqlalchemy/ansisql.py	2007-08-09 11:53:37.000000000 -0400
@@ -170,7 +170,7 @@
         # this re will search for params like :param
         # it has a negative lookbehind for an extra ':' so that it doesnt match
         # postgres '::text' tokens
-        match = re.compile(r'(?<!:):([\w_]+)', re.UNICODE)
+        match = re.compile(r'(?<!:):([\w_$]+)', re.UNICODE)
         if self.paramstyle=='pyformat':
             self.strings[self.statement] = match.sub(lambda m:'%(' + m.group(1) +')s', self.strings[self.statement])
         elif self.positional:

Reply via email to