mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
This test was failing when run inside the Docker container:
`test_searchable[/fixtures/searchable.json?_search=te*+AND+do*&_searchmode=raw-expected_rows3]`,
with this error:
```
def test_searchable(app_client, path, expected_rows):
response = app_client.get(path)
> assert expected_rows == response.json["rows"]
E AssertionError: assert [[1, 'barry c...sel', 'puma']] == []
E Left contains 2 more items, first extra item: [1, 'barry cat', 'terry dog', 'panther']
E Full diff:
E + []
E - [[1, 'barry cat', 'terry dog', 'panther'],
E - [2, 'terry dog', 'sara weasel', 'puma']]
```
The issue was that the version of sqlite3 built inside the Docker
container was built with FTS3 and FTS4 enabled, but without the
`SQLITE_ENABLE_FTS3_PARENTHESIS` compile option passed, which adds
support for using `AND` and `NOT` within `match` expressions (see
https://sqlite.org/fts3.html#compiling_and_enabling_fts3_and_fts4 and
https://www.sqlite.org/compile.html).
Without this, the `AND` used in the search in this test was being
interpreted as a literal string, and so no matches were found. Adding
this compile option fixes this.
Thanks, @bobwhitelock
42 lines
1.8 KiB
Docker
42 lines
1.8 KiB
Docker
FROM python:3.7.10-slim-stretch as build
|
|
|
|
# Setup build dependencies
|
|
RUN apt update \
|
|
&& apt install -y python3-dev build-essential wget libxml2-dev libproj-dev libgeos-dev libsqlite3-dev zlib1g-dev pkg-config git \
|
|
&& apt clean
|
|
|
|
|
|
RUN wget "https://www.sqlite.org/2020/sqlite-autoconf-3310100.tar.gz" && tar xzf sqlite-autoconf-3310100.tar.gz \
|
|
&& cd sqlite-autoconf-3310100 && ./configure --disable-static --enable-fts5 --enable-json1 CFLAGS="-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_JSON1" \
|
|
&& make && make install
|
|
|
|
RUN wget "http://www.gaia-gis.it/gaia-sins/freexl-sources/freexl-1.0.5.tar.gz" && tar zxf freexl-1.0.5.tar.gz \
|
|
&& cd freexl-1.0.5 && ./configure && make && make install
|
|
|
|
RUN wget "http://www.gaia-gis.it/gaia-sins/libspatialite-sources/libspatialite-4.4.0-RC0.tar.gz" && tar zxf libspatialite-4.4.0-RC0.tar.gz \
|
|
&& cd libspatialite-4.4.0-RC0 && ./configure && make && make install
|
|
|
|
RUN wget "http://www.gaia-gis.it/gaia-sins/readosm-sources/readosm-1.1.0.tar.gz" && tar zxf readosm-1.1.0.tar.gz && cd readosm-1.1.0 && ./configure && make && make install
|
|
|
|
RUN wget "http://www.gaia-gis.it/gaia-sins/spatialite-tools-sources/spatialite-tools-4.4.0-RC0.tar.gz" && tar zxf spatialite-tools-4.4.0-RC0.tar.gz \
|
|
&& cd spatialite-tools-4.4.0-RC0 && ./configure && make && make install
|
|
|
|
|
|
# Add local code to the image instead of fetching from pypi.
|
|
COPY . /datasette
|
|
|
|
RUN pip install /datasette
|
|
|
|
FROM python:3.7.10-slim-stretch
|
|
|
|
# Copy python dependencies and spatialite libraries
|
|
COPY --from=build /usr/local/lib/ /usr/local/lib/
|
|
# Copy executables
|
|
COPY --from=build /usr/local/bin /usr/local/bin
|
|
# Copy spatial extensions
|
|
COPY --from=build /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
|
|
|
|
ENV LD_LIBRARY_PATH=/usr/local/lib
|
|
|
|
EXPOSE 8001
|
|
CMD ["datasette"]
|