Skip to content

Removing comments when calling conn.execute() #48

@stan-yu

Description

@stan-yu

Hi,

there is such a code example:

pgfe::Connection conn(pgfe::Connection_options{}.set(pgfe::Communication_mode::net).set_hostname( ...)....;
pgfe::Transaction_guard tg{*conn_};
conn.call("public.get_objects", start_of_interval, end_of_interval, "cr");
conn.execute([](pgfe::Row&& row) { std::cout << pgfe::to<std::string>(row[0]) << std::endl ; },
               "fetch /* pass my comment */ all from cr");
tg.commit();

In conn.execute() call, I want to pass comments to the server. In this case, the comments are multiline(but it doesn't matter, oneline one is removed too). But the library removes them forcibly. If you follow the call chain, this happens in pgfe/src/pgfe/statement.cpp in the Statement::to_query_string() function:

for (const auto& fragment : fragments_) {
    switch (fragment.type) {
    case Ft::text:
      result += fragment.str;
      break;
    case Ft::one_line_comment:
      [[fallthrough]];
    case Ft::multi_line_comment:
      break;
...

Is it possible to somehow control this behavior or use other methods of calling FETCH so that comments are passed to server?
pgfe version 2.2.3

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions