Wykres commitów

973 Commity (main)

Autor SHA1 Wiadomość Data
Simon Willison 45e502aace Added unit tests for inspect() foreign key detection
Used them to fix a bug with it.

Refs #85
2017-11-17 08:08:11 -08:00
Simon Willison 084350b0f1 Switched to gather_request=False for Sanic tests
Gets rid of those ugly _, response = lines.
2017-11-17 06:53:37 -08:00
Ray N ed2b3f25be add support for ?field__isnull=1 (#107)
* add support for ?field__isnull=1

* Add unit test and conditional formatting for ?field__isnull
2017-11-17 05:29:22 -08:00
Simon Willison 9cb69cbd45 New ?_sql_time_limit_ms=10 argument to database and table page
Allows callers to opt for a lower time limit.

Closes #95
2017-11-14 18:55:10 -08:00
Simon Willison 0b8c1b0a6d Test for sql_time_limit_ms + sqlite_functions mechanism
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
2017-11-14 18:43:34 -08:00
Simon Willison cbb59e3801 Handle tables with names that start with digits 2017-11-14 18:03:21 -08:00
Simon Willison 50e817801f Fixed #83
Turns out we had a redirect bug as well.
2017-11-13 16:44:43 -08:00
Simon Willison 44a199a062 Stop using sqlite WITH RECURSIVE in our tests
The version of Python 3 running in Travis CI doesn't support this.
2017-11-13 14:15:21 -08:00
Simon Willison 847f3e0c92 Implemented offset/limit pagination for views
Closes #70
2017-11-13 13:10:55 -08:00
Simon Willison 7dac1c05cd Improved pagination
Closes #78
2017-11-13 12:34:56 -08:00
Simon Willison 8252e71da4 Limit on max rows returned, controlled by --max_returned_rows option
If someone executes 'select * from table' against a table with a million rows
in it, we could run into problems: just serializing that much data as JSON is
likely to lock up the server.

Solution: we now have a hard limit on the maximum number of rows that can be
returned by a query. If that limit is exceeded, the server will return a
`"truncated": true` field in the JSON.

This limit can be optionally controlled by the new `--max_returned_rows`
option. Setting that option to 0 disables the limit entirely.

Closes #69
2017-11-13 11:33:01 -08:00
Simon Willison 26370b14d8 Handle table names with slashes in them
e.g. https://datasette-wdlexdiaoz.now.sh/fivethirtyeight-75d605c/bob-ross%2Felements-by-episode.csv?CABIN=1&BUSHES=1&CLOUDS=1
2017-11-12 15:17:00 -08:00
Simon Willison 666aa03253 Improved error handling
Invalid SQL now shows a special error.html template, and is covered by tests.
2017-11-12 13:16:15 -08:00
Simon Willison ff2ab9dc7d Views now show their SQL, are handled a bit better
Refs #66
2017-11-12 12:32:25 -08:00
Simon Willison 8acdc2fd14 Test for table with space in name
Tests code in b51836f846
2017-11-12 12:08:32 -08:00
Simon Willison 59580d02da Implemented custom SQL via textarea
Closes #65
2017-11-11 18:35:35 -08:00
Simon Willison fa42a56c6a Bulked out table test a bit
I'm closing #50 - more tests will be added in the future, but the framework
is neatly in place for them now.
2017-11-11 14:22:47 -08:00
Simon Willison e9e1def4c0 Revised JSON design a bit
Closes #63
2017-11-11 14:20:00 -08:00
Simon Willison 407795b612 Initial unit tests against our Sanic app
Refs #50

I had to disable the build metadata function to get these tests to work
sensibly. I need to completely rethink how that mechanism works.
2017-11-11 09:47:59 -08:00
Simon Willison 3280972c89 Fixed tests I broke earlier
Broke these tests in 21c9c04310
2017-11-11 08:52:17 -08:00
Simon Willison 21c9c04310 Implemented cursor-based pagination for table view
Closes #5
2017-11-10 12:41:14 -08:00
Simon Willison a8a293cd71 Refactored util functions into new utils module 2017-11-10 11:25:54 -08:00
Simon Willison 40d3b3eae6 Refactored tests into new tests/ folder
Guided by https://docs.pytest.org/en/latest/goodpractices.html
2017-11-10 10:48:16 -08:00