userver-framework / userver

Production-ready C++ Asynchronous Framework with rich functionality
https://userver.tech
Apache License 2.0
2.39k stars 278 forks source link

postgres::Row::operator[] #494

Open SidorovichPavel opened 7 months ago

SidorovichPavel commented 7 months ago

postgres::Row::operator[] accepts a const std::string& as an argument. A more idiomatic approach would be to accept a std::string_view instead, as implemented in userver for json and e.t.

itrofimow commented 7 months ago

Row::operator[](const std::string&) eventually ends up in PQfnumber which expects a null-terminated string, so for now there's no way to improve the interface, unfortunately.

However, we are planning to vendor libpq at some point, and when it happens we could add a PQfnumber overload which accepts a string size.