diff options
author | Ryan Williams <rdw@lindenlab.com> | 2008-12-09 22:41:28 +0000 |
---|---|---|
committer | Ryan Williams <rdw@lindenlab.com> | 2008-12-09 22:41:28 +0000 |
commit | 14a5879c88497c05db452e52bc5ebe876368194f (patch) | |
tree | 5af21aef61ed32d81174bb0d11afb378154df9d4 | |
parent | 114497a7b60a6d6a42a5f530979f219c5adc9e32 (diff) |
svn merge -r104949:105037 svn+ssh://svn.lindenlab.com/svn/linden/branches/rad-chilies/rad-chilies-06-release-merge
QAR-1048: Distributed L$ Transactions > Rad Chilies 06 Indra items
-rw-r--r-- | indra/lib/python/indra/util/named_query.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/indra/lib/python/indra/util/named_query.py b/indra/lib/python/indra/util/named_query.py index e1f1ad2002..bb27730e9f 100644 --- a/indra/lib/python/indra/util/named_query.py +++ b/indra/lib/python/indra/util/named_query.py @@ -47,6 +47,8 @@ except NameError: from indra.base import llsd from indra.base import config +DEBUG = False + NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq') NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX) @@ -63,7 +65,9 @@ def _init_g_named_manager(sql_dir = None): # extra fallback directory in case config doesn't return what we want if sql_dir is None: - sql_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..", "..", "web", "dataservice", "sql") + sql_dir = os.path.abspath( + os.path.join( + os.path.realpath(os.path.dirname(__file__)), "..", "..", "..", "..", "web", "dataservice", "sql")) global _g_named_manager _g_named_manager = NamedQueryManager( @@ -188,6 +192,16 @@ class NamedQuery(object): ready them for use in LIKE statements""" if sql: #print >>sys.stderr, "sql:",sql + + # This first sub is to properly escape any % signs that + # are meant to be literally passed through to mysql in the + # query. It leaves any %'s that are used for + # like-expressions. + expr = re.compile("(?<=[^a-zA-Z0-9_-])%(?=[^:])") + sql = expr.sub('%%', sql) + + # This should tackle the rest of the %'s in the query, by + # converting them to LIKE clauses. expr = re.compile("(%?):([a-zA-Z][a-zA-Z0-9_-]*)%") sql = expr.sub(self._prepare_like, sql) expr = re.compile("#:([a-zA-Z][a-zA-Z0-9_-]*)") @@ -339,7 +353,8 @@ class NamedQuery(object): cursor = connection.cursor() statement = self.sql(connection, params) - #print "SQL:", statement + if DEBUG: + print "SQL:", statement rows = cursor.execute(statement) # *NOTE: the expect_rows argument is a very cheesy way to get some |