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

Logging: Make it possible to parse params in the query event #16451

Open
tmtron opened this issue Nov 25, 2022 Discussed in #14158 · 1 comment
Open

Logging: Make it possible to parse params in the query event #16451

tmtron opened this issue Nov 25, 2022 Discussed in #14158 · 1 comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: logging

Comments

@tmtron
Copy link

tmtron commented Nov 25, 2022

Discussed in #14158

Originally posted by tmtron July 5, 2022
In the query event we get the query which can include ? placeholders and the params which is an array-like string: e.g. [\"abc2\",2022-07-05 14:18:03.680719400 UTC,2]

We'd like to write a convenience function to replace the ? with the actual param values - just for readability of the log-messages during development (It can be quite difficult to understand a long query with multiple parameters)

I tried to write a simple parsing logic for the params, but I think, currently there is no reliable way to parse that string (i.e. to get the individual items), because quotes and commas within a string are not escaped

  • e.g. when the first parameter is a "," in a string, and the 2nd parameter is p2 the params array is [\"a \",\" in a string\",\"p2\"]
  • from the number of question marks in the query, we know that there must be 2 parameters , but it's not possible to know if these are
    1. a "," in a string and p2
    2. or a " and " in a string","p2"

Notes:

  • we use SQLite
  • Maybe, there there is already a function to do that?
  • Or is there a way to tell prisma to JSON encode the params?
@mhio
Copy link

mhio commented Nov 25, 2022

Also #12441

@eviefp eviefp added team/client Issue for team Client. kind/feature A request for a new feature. topic: logging tech/engines/query engine Issue in the Query Engine labels Nov 28, 2022
@janpio janpio changed the title [Feature Request]: Make it possible to parse params in the query event? Logging: Make it possible to parse params in the query event Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature. team/client Issue for team Client. tech/engines/query engine Issue in the Query Engine topic: logging
Projects
None yet
Development

No branches or pull requests

3 participants