X-Git-Url: https://git.jsancho.org/?p=datasette-pytables.git;a=blobdiff_plain;f=datasette_pytables%2F__init__.py;h=a1f11d91e3fb2e8b142068703fd4a8181e49ac33;hp=094710b517ee27d50dbd2341952b4144fa2d082e;hb=24c552a5f4d88eaf4eb30a8a9fb06b0d7ec75bc8;hpb=3b77ff8064a87213d72b14c0f7acdd77c88c05c4 diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 094710b..a1f11d9 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -107,8 +107,12 @@ class Connection: operator = list(where)[0] if operator in ['and', 'or']: - subexpr = ["({})".format(_translate_where(q)) for q in where[operator]] + subexpr = [_translate_where(e) for e in where[operator]] + subexpr = filter(lambda e: e, subexpr) + subexpr = ["({})".format(e) for e in subexpr] expr = " {} ".format(_operators[operator]).join(subexpr) + elif operator == 'exists': + pass elif where == {'eq': ['rowid', 'p0']}: nonlocal start, end start = int(params['p0']) @@ -150,16 +154,19 @@ class Connection: for table_row in table_rows: row = Row() for field in fields: - if field['value'] == 'rowid': + field_name = field['value'] + if type(field_name) is dict and 'distinct' in field_name: + field_name = field_name['distinct'] + if field_name == 'rowid': row['rowid'] = int(table_row.nrow) - elif field['value'] == '*': + elif field_name == '*': for col in table.colnames: value = table_row[col] if type(value) is bytes: value = value.decode('utf-8') row[col] = value else: - row[field['value']] = table_row[field['value']] + row[field_name] = table_row[field_name] rows.append(row) # Prepare query description