if filter_op contains a __ the value is set to the right hand side.
e.g.
?_filter_column=col&_filter_op=isnull__1&_filter_value=x
Redirects to:
?col__isnull=1
Refs #86
Part of implementing the filters UI (refs #86) - the following:
/trees/Trees?_filter_column=SiteOrder&_filter_op=gt&_filter_value=2
Now redirects to this;
/trees/Trees?SiteOrder__gt=2
The `datasette publish` and `datasette package` commands both now accept an
optional `--build` argument. If provided, this can be used to specify a branch
published to GitHub that should be built into the container.
This makes it easier to test code that has not yet been officially released to
PyPI, e.g.:
datasette publish now mydb.db --branch=master
If a table has foreign key columns, and those foreign key tables have
label_columns, the TableView will now query those other tables for the
corresponding values and display those values as links in the corresponding
table cells.
label_columns are currently detected by the inspect() function, which looks
for any table that has just two columns - an ID column and one other - and
sets the label_column to be that second non-ID column.
It turns out it is possible for a SQLite table to define a foreign key
relationship to a table that does not actually exist
We should still be able to handle these databases.
I tesed this by first building and running a container using the new
Dockerfile from #114:
docker build .
docker run -it -p 8001:8001 6c9ca7e29181 /bin/sh
Then I ran this inside the container itself:
apt update && apt-get install wget -y \
&& wget http://www.gaia-gis.it/spatialite-2.3.1/test-2.3.sqlite.gz \
&& gunzip test-2.3.sqlite.gz \
&& mv test-2.3.sqlite test23.sqlite \
&& datasette -h 0.0.0.0 test23.sqlite
I visited this URL to confirm I got an error due to spatialite not being
loaded:
http://localhost:8001/test23-c88bc35?sql=select+ST_AsText%28Geometry%29+from+HighWays+limit+1
Then I checked that loading it with `--load-extension` worked correctly:
datasette -h 0.0.0.0 test23.sqlite \
--load-extension=/usr/lib/x86_64-linux-gnu/mod_spatialite.so
Then, finally, I tested it with the new environment variable option:
SQLITE_EXTENSIONS=/usr/lib/x86_64-linux-gnu/mod_spatialite.so \
datasette -h 0.0.0.0 test23.sqlite
Running it with an invalid environment variable option shows an error:
$ SQLITE_EXTENSIONS=/usr/lib/x86_64-linux-gnu/blah.so datasette \
-h 0.0.0.0 test23.sqlite
Usage: datasette -h [OPTIONS] [FILES]...
Error: Invalid value for "--load-extension": Path "/usr/lib/x86_64-linux-gnu/blah.so" does not exist.
Closes#112
You can now run these commands like so:
datasette now publish mydb.db \
--title="My Title" \
--source="Source" \
--source_url="http://www.example.com/" \
--license="CC0" \
--license_url="https://creativecommons.org/publicdomain/zero/1.0/"
This will write those values into the metadata.json that is packaged with the
app. If you also pass --metadata= that file will be updated with the extra
values before being written into the Docker image.
Closes#92
Added a unit test for the sql_time_limit_ms option.
To test this, I needed to add a custom SQLite sleep() function. I've added a
simple mechanism to the Datasette class for registering custom functions.
I also had to modify the sqlite_timelimit() function. It makes use of a magic
value, N, which is the number of SQLite virtual machine instructions that
should execute in between calls to my termination decision function.
The value of N was not finely grained enough for my test to work - so I've
added logic that says that if the time limit is less than 50ms, N is set to 1.
This got the tests working.
Refs #95