-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Returning generated SQL #3580
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
Comments
Big +1 on this. It would be very useful for debugging purposes. |
would really help out |
Now that we output part of the generated SQL on the logs:
We can implement this. The idea would be to output the generated SQL when This only when https://docs.postgrest.org/en/latest/references/configuration.html#db-plan-enabled is true. |
Portaling a comment from another issue about why this would be a great solution for my use case: |
@steve-chavez How should we implement only the
I think we might need a refactor for this but not sure. |
Every method that executes SQL. For example,
I think so, yes. Maybe, something like
For now, since just the My opinions, Steve can correct/add more to these. |
Hi all, sorry to suddenly comes in. @zachblume has notify me of this, and I'm currently actively working on getting the End goal for me would be to get the main, count, and also template values on the query as well. Just want to put it out here as well! |
The
By template values you mean the placeholder values ( |
Yes that's what @fauh45 was referring to, since we need them for our use-case of mutating queries a bit post-generation and then actually running them from application. Just read #3934 and couldnt immediately figure out the connection to template values. Would you clarify? I think we'll want to implement this narrowly but can expand to cover as much of #3934 as is needed for this |
Hi all, got the first WIP working where you can query using Read
Mutate
I had to add custom Media Type Also can you guys validate my understanding that all the mutate query (or queries that have body) the raw value of the body just got passed to postgres and parsed on Postgres itself? Currently what I've done to get the parametrized value is to just return I know my code might not be up to standard (last time I barely use Haskell was in University 3 years ago), so if you guys have some time, may you guys be able to critic my code? Any input would be amazing! |
To get feedback on your code, please open a PR. It doesn't need to be perfect right away, but giving feedback in the issue / on a branch without PR is harder than it needs to be. Also: Make sure you write some kind of tests. Not only for us, but also for you. Your development will be much faster (and you can refactor with more confidence), if you have some tests running along. |
Sounds good! I'll make a PR for the |
In issue #2354 it is discussed multiple times that displaying the generated SQL might be interesting too. It seems like this feature was in the end not implemented.
I unterstand that there are other ways to retrieve the SQL query (for example through logs and using EXPLAIN VERBOSE to get the query ID to make sure to find it easily...
However, any explain plan returned through the plan accept header implemented is always going to be easier to understand, judge and also act upon with the SQL query present in the same data without having to implement extra steps which enable logging queries. It seems a lot more efficient to have the option to just return the SQL query right before the plan in the same reply?
I understand security considerations need to be taken, but this could be implemented via an extra config as db-allow-generated-sql or db-allow-plan-sql if it is only usable in combination with plan.
The text was updated successfully, but these errors were encountered: