kopia lustrzana https://github.com/simonw/datasette
Renamed ?_sql_time_limit_ms= to ?_timelimit, closes #242
rodzic
379caddccb
commit
8081ec7bb4
|
@ -358,8 +358,8 @@ class BaseView(RenderMixin):
|
|||
params[named_parameter] = ''
|
||||
|
||||
extra_args = {}
|
||||
if params.get('_sql_time_limit_ms'):
|
||||
extra_args['custom_time_limit'] = int(params['_sql_time_limit_ms'])
|
||||
if params.get('_timelimit'):
|
||||
extra_args['custom_time_limit'] = int(params['_timelimit'])
|
||||
rows, truncated, description = await self.execute(
|
||||
name, sql, params, truncate=True, **extra_args
|
||||
)
|
||||
|
@ -894,8 +894,8 @@ class TableView(RowTableShared):
|
|||
offset=offset,
|
||||
)
|
||||
|
||||
if request.raw_args.get('_sql_time_limit_ms'):
|
||||
extra_args['custom_time_limit'] = int(request.raw_args['_sql_time_limit_ms'])
|
||||
if request.raw_args.get('_timelimit'):
|
||||
extra_args['custom_time_limit'] = int(request.raw_args['_timelimit'])
|
||||
|
||||
rows, truncated, description = await self.execute(
|
||||
name, sql, params, truncate=True, **extra_args
|
||||
|
|
|
@ -154,7 +154,7 @@ The Datasette table view takes a number of special querystring arguments:
|
|||
You can pass multiple ``_group_count`` columns to return counts against
|
||||
unique combinations of those columns.
|
||||
|
||||
``?_sql_time_limit_ms=MS``
|
||||
``?_timelimit=MS``
|
||||
Sets a custom time limit for the query in ms. You can use this for optimistic
|
||||
queries where you would like Datasette to give up if the query takes too
|
||||
long, for example if you want to implement autocomplete search but only if
|
||||
|
|
|
@ -62,9 +62,9 @@ If this time limit is too short for you, you can customize it using the
|
|||
datasette mydatabase.db --sql_time_limit_ms=3500
|
||||
|
||||
You can optionally set a lower time limit for an individual query using the
|
||||
``_sql_time_limit_ms`` query string argument::
|
||||
``_timelimit`` query string argument::
|
||||
|
||||
/my-database/my-table?qSpecies=44&_sql_time_limit_ms=100
|
||||
/my-database/my-table?qSpecies=44&_timelimit=100
|
||||
|
||||
This would set the time limit to 100ms for that specific query. This feature
|
||||
is useful if you are working with databases of unknown size and complexity -
|
||||
|
|
|
@ -269,7 +269,7 @@ def test_custom_sql_time_limit(app_client):
|
|||
)
|
||||
assert 200 == response.status
|
||||
response = app_client.get(
|
||||
'/test_tables.json?sql=select+sleep(0.01)&_sql_time_limit_ms=5',
|
||||
'/test_tables.json?sql=select+sleep(0.01)&_timelimit=5',
|
||||
gather_request=False
|
||||
)
|
||||
assert 400 == response.status
|
||||
|
|
Ładowanie…
Reference in New Issue