Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on_success_message_sql option for writable canned queries #2138

Closed
simonw opened this issue Aug 10, 2023 · 2 comments
Closed

on_success_message_sql option for writable canned queries #2138

simonw opened this issue Aug 10, 2023 · 2 comments

Comments

@simonw
Copy link
Owner

simonw commented Aug 10, 2023

Or... how about if the on_success_message option could define a SQL query to be executed to generate that message? Maybe on_success_message_sql.

@simonw
Copy link
Owner Author

simonw commented Aug 10, 2023

Goal here is to customize the message displayed after a query has succeeded. e.g.

databases:
  mydatabase:
    queries:
      add_name:
        sql: INSERT INTO names (name) VALUES (:name)
        write: true
        on_success_message_sql: 'select ''Name inserted: '' || :name'
        on_success_redirect: /mydatabase/names

@simonw simonw closed this as completed in a3593c9 Aug 10, 2023
@simonw
Copy link
Owner Author

simonw commented Aug 10, 2023

Here's what it looks like when it works:

image

And here's what you get if there's a SQL error in the on_success_message_sql query itself:

CleanShot 2023-08-09 at 17 38 12@2x

@simonw simonw added this to the Datasette 1.0a4 milestone Aug 10, 2023
simonw added a commit that referenced this issue Aug 22, 2023
* API explorer requires view-instance permission

* Check database/table permissions on /-/api page

* Release notes for 1.0a4

Refs #2119, #2133, #2138, #2140

Refs GHSA-7ch3-7pp7-7cpq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant