From 30d9dbfca20886a04bdbc6da0df77afb16e26436 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 24 Nov 2020 18:27:51 +0100 Subject: [PATCH 1/1] Fix entry point and some issues with sqlite glob operand --- datasette_pytables/__init__.py | 7 +++++-- setup.py | 3 ++- tests/test_html.py | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/datasette_pytables/__init__.py b/datasette_pytables/__init__.py index 7b4d33c..4c1cc0f 100644 --- a/datasette_pytables/__init__.py +++ b/datasette_pytables/__init__.py @@ -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: diff --git a/setup.py b/setup.py index d6ef38f..ff46863 100644 --- 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=[ diff --git a/tests/test_html.py b/tests/test_html.py index 3e1c9ed..a545fe5 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -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 -- 2.39.2