- changed status to resolved
patch for sqlalchemy mangling of dollar sign identifiers
Issue #719
resolved
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](key)
KeyError: 'foo'
A patch that corrects the bug is attached.
--
Brandon Craig Rhodes brandon@rhodesmill.org 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 sqlalchemy-unsubscribe@googlegroups.com
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_](\w_)+)', re.UNICODE)
+ match = re.compile(r'(?<!:):([\w_$](\w_$)+)', re.UNICODE)
if self.paramstyle=='pyformat':
self.strings[self.statement](self.statement) = match.sub(lambda m:'%(' + m.group(1) +')s', self.strings[self.statement](self.statement))
elif self.positional:
Comments (2)
-
-
reporter - removed milestone
Removing milestone: 0.4.0 (automated comment)
- Log in to comment
Applied this patch for 0.3.x in 4f8a560d6f02c60ac85e73ad90d2ffb4a183d9f0 (thanks!) and something similar for 0.4 in ce0d72e68aac6ad6c7569ffe76ca5c6c02d2718c.