pg_query icon indicating copy to clipboard operation
pg_query copied to clipboard

Decode force quote all identifiers

Open jdenquin opened this issue 4 years ago • 1 comments

Hello There,

I'm having a issue with the deparse feature, I want to keep all quotes from my original request on each identifiers. Is there any way to do it by passing a params on the Ruby side?

I forked the repository and put the quote_all_identifiers variable to true on the C side to do it.

Cheers, Jeremy

jdenquin avatar Sep 23 '21 15:09 jdenquin

@jdenquin There is no way to do this today, but I can see that being a valid use case. Note that quote_all_identifiers does not keep the original quotes, but rather ensures all identifiers are quoted, regardless of how they presented in the initial query.

I would approach this by adding an optional parameter on the C side - i.e. by renaming the existing pg_query_deparse_protobuf method (https://github.com/pganalyze/libpg_query/blob/13-latest/src/pg_query_deparse.c#L9908) to pg_query_deparse_protobuf_with_opts (with an extra parameter for setting quote_all_identifiers), and then add a wrapper pg_query_deparse_protobuf method.

I personally don't have time to complete that thought and make the change, but a patch along these lines on the C library would be welcome!

lfittl avatar Oct 13 '21 08:10 lfittl