|
@@ -66,17 +66,20 @@ def get_session_transactions(cursor, statement, display):
|
|
|
|
|
|
|
|
|
def record_matches(record, strict=None, **kwargs):
|
|
|
- strict = strict or []
|
|
|
- for k,v in kwargs.items():
|
|
|
- if not v:
|
|
|
+ strict = [ x.lower() for x in (strict or []) ]
|
|
|
+ for key, query, candidate in (
|
|
|
+ (k.lower(), v.lower(), record[k].lower()) for k, v in kwargs.items()
|
|
|
+ ):
|
|
|
+ if not query:
|
|
|
continue
|
|
|
|
|
|
- if k in strict and v.lower() != record[k].lower():
|
|
|
- return False
|
|
|
-
|
|
|
- if v.lower() not in record[k].lower():
|
|
|
+ if key in strict and query != candidate:
|
|
|
return False
|
|
|
|
|
|
+ for term in query.split():
|
|
|
+ if term not in candidate:
|
|
|
+ return False
|
|
|
+
|
|
|
return True
|
|
|
|
|
|
def unique_suggestions(cur, statement, name, display, exclude=NON_IDENTIFIER_COLUMNS, **kwargs):
|
|
@@ -152,4 +155,4 @@ class QueryManager(object):
|
|
|
return unique_suggestions(self.cursor, statement, name, self.display, **kwargs)
|
|
|
|
|
|
def insert_new_product(self, product, category, group):
|
|
|
- self.cursor.execute(get_insert_product_statement(product, category, group))
|
|
|
+ self.cursor.execute(get_insert_product_statement(product, category, group))
|