瀏覽代碼

Finish parameterize() for Text.

tags/v1.0^2
Ben Kurtovic 10 年之前
父節點
當前提交
91256b1384
共有 2 個文件被更改,包括 10 次插入3 次删除
  1. +1
    -1
      bitshift/database/__init__.py
  2. +9
    -2
      bitshift/query/nodes.py

+ 1
- 1
bitshift/database/__init__.py 查看文件

@@ -62,7 +62,7 @@ class Database(object):
base = """SELECT codelet_id
FROM codelets %s
WHERE %s
ORDER BY codelet_rank LIMIT 10"""
GROUP BY codelet_id ORDER BY codelet_rank DESC LIMIT 10"""
conditional, tables, args = query.parameterize()
joins = " ".join(tables)
qstring = base % (joins, conditional)


+ 9
- 2
bitshift/query/nodes.py 查看文件

@@ -84,8 +84,15 @@ class Text(_Node):

def parameterize(self, tables):
tables |= {"code", "symbols"}
# (FTS: codelet_name, =: symbol_name, FTS: code_code) vs. node.text (_Literal)
pass
if isinstance(self.text, Regex):
cols = ["codelet_name", "symbol_name", "code_code"]
cond = "((" + " REGEXP ?) OR (".join(cols) + " REGEXP ?))"
return cond, [self.text.regex] * 3
conds = ["MATCH(codelet_name) AGAINST (? IN BOOLEAN MODE)",
"MATCH(code_code) AGAINST (? IN BOOLEAN MODE)",
"symbol_name = ?"]
cond = "((" + ") OR (".join(conds) + "))"
return cond, tables, [self.text.string] * 3


class Language(_Node):


Loading…
取消
儲存