Browse Source

fix autocomplete of tags

Daniel Sheffield 2 years ago
parent
commit
98c5ff0b62
2 changed files with 4 additions and 2 deletions
  1. 1 1
      app/data/QueryManager.py
  2. 3 1
      app/data/TransactionView.py

+ 1 - 1
app/data/QueryManager.py

@@ -97,7 +97,7 @@ def unique_suggestions(cur, statement, name, display, exclude=NON_IDENTIFIER_COL
     if len(ret) > 0 or name not in tables:
         return ret
 
-    items = (i for i in filter(lambda x: record_matches(x, **{ name: kwargs[name] }),
+    items = (i for i in filter(lambda x: record_matches(x, **{ name: kwargs[name] }) if name in kwargs else True,
         get_data(cur, get_table_statement(name), display)))
     ret = sorted(set(map(lambda x: x[name], items)))
     return ret

+ 3 - 1
app/data/TransactionView.py

@@ -49,7 +49,9 @@ def get_transactions_statement(name, **kwargs):
             value=Literal(f'%{v}%' if k == name else v),
         ) if k in ALIAS_TO_TABLE and (k not in NON_IDENTIFIER_COLUMNS or k == name) and v else SQL('TRUE'))
     statement = SQL('\n').join([
-        get_select(dict([ (k,v) for k,v in SELECT.items() if k != 'tags'])),
+        get_select(dict([('tags', Identifier('tags','name')), *[
+            (k,v) for k,v in SELECT.items() if k != 'tags'
+        ]])),
         get_from("transactions", JOINS),
         SQL('').join([SQL('WHERE '), SQL('\n    AND ').join(where)]),
     ])