Skip to content
Snippets Groups Projects
Commit 14a5879c authored by Ryan Williams's avatar Ryan Williams
Browse files

svn merge -r104949:105037...

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
parent 114497a7
No related branches found
No related tags found
No related merge requests found
...@@ -47,6 +47,8 @@ ...@@ -47,6 +47,8 @@
from indra.base import llsd from indra.base import llsd
from indra.base import config from indra.base import config
DEBUG = False
NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq') NQ_FILE_SUFFIX = config.get('named-query-file-suffix', '.nq')
NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX) NQ_FILE_SUFFIX_LEN = len(NQ_FILE_SUFFIX)
...@@ -63,7 +65,9 @@ def _init_g_named_manager(sql_dir = None): ...@@ -63,7 +65,9 @@ def _init_g_named_manager(sql_dir = None):
# extra fallback directory in case config doesn't return what we want # extra fallback directory in case config doesn't return what we want
if sql_dir is None: 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 global _g_named_manager
_g_named_manager = NamedQueryManager( _g_named_manager = NamedQueryManager(
...@@ -188,6 +192,16 @@ def _convert_sql(self, sql): ...@@ -188,6 +192,16 @@ def _convert_sql(self, sql):
ready them for use in LIKE statements""" ready them for use in LIKE statements"""
if sql: if sql:
#print >>sys.stderr, "sql:",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_-]*)%") expr = re.compile("(%?):([a-zA-Z][a-zA-Z0-9_-]*)%")
sql = expr.sub(self._prepare_like, sql) sql = expr.sub(self._prepare_like, sql)
expr = re.compile("#:([a-zA-Z][a-zA-Z0-9_-]*)") expr = re.compile("#:([a-zA-Z][a-zA-Z0-9_-]*)")
...@@ -339,7 +353,8 @@ def run(self, connection, params, expect_rows = None, use_dictcursor = True): ...@@ -339,7 +353,8 @@ def run(self, connection, params, expect_rows = None, use_dictcursor = True):
cursor = connection.cursor() cursor = connection.cursor()
statement = self.sql(connection, params) statement = self.sql(connection, params)
#print "SQL:", statement if DEBUG:
print "SQL:", statement
rows = cursor.execute(statement) rows = cursor.execute(statement)
# *NOTE: the expect_rows argument is a very cheesy way to get some # *NOTE: the expect_rows argument is a very cheesy way to get some
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment