Fix entry point and some issues with sqlite glob operand
authorJavier Sancho <jsf@jsancho.org>
Tue, 24 Nov 2020 17:27:51 +0000 (18:27 +0100)
committerJavier Sancho <jsf@jsancho.org>
Tue, 24 Nov 2020 17:27:51 +0000 (18:27 +0100)
datasette_pytables/__init__.py
setup.py
tests/test_html.py

index 7b4d33c..4c1cc0f 100644 (file)
@@ -122,6 +122,10 @@ class PyTablesConnector(dc.Connector):
         truncated = False
         description = ()
 
+        # Some Datasette queries uses glob operand, not supported by Pytables
+        if ' glob ' in sql:
+            return results, truncated, description
+
         parsed_sql = parse_sql(sql, params)
 
         while isinstance(parsed_sql['from'], dict):
@@ -231,8 +235,7 @@ class PyTablesConnector(dc.Connector):
 
         # Execute query
         if query:
-            if not ' glob ' in query:
-                table_rows = table.where(query, params, start, end)
+            table_rows = table.where(query, params, start, end)
         elif orderby:
             table_rows = table.itersorted(orderby, start=start, stop=end)
         else:
index d6ef38f..ff46863 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -19,12 +19,13 @@ setup(
     long_description=get_long_description(),
     long_description_content_type='text/markdown',
     author='Javier Sancho',
+    author_email='jsf@jsancho.org',
     url='https://github.com/jsancho-gpl/datasette-pytables',
     license='Apache License, Version 2.0',
     packages=['datasette_pytables'],
     entry_points={
         'datasette.connectors': [
-            'pytables = datasette_pytables'
+            'pytables = datasette_pytables:PyTablesConnector'
         ],
     },
     install_requires=[
index 3e1c9ed..a545fe5 100644 (file)
@@ -26,3 +26,7 @@ def test_array(app_client):
 def test_array_row(app_client):
     response = app_client.get('/test_tables/%group1%array2/1050')
     assert response.status == 200
+
+def test_table_exact_query(app_client):
+    response = app_client.get('/test_tables/%group2%table2/?idnumber__exact=0')
+    assert response.status == 200