SOCI / soci

Official repository of the SOCI - The C++ Database Access Library
http://soci.sourceforge.net/
Boost Software License 1.0
1.4k stars 477 forks source link

Metadata and schemas other than public #1155

Open cstiborg opened 1 month ago

cstiborg commented 1 month ago

The metadata code introduced by #480 hardcodes the used schema to public. This is not great if you want to investigate any other schema than the public schema. I've created test in my own fork of SOCI - and I'm ready to make a PR with that code - which stores the schema on the session object (default is public) and allows backends to change this based on whatever, but most likely a type of connection string.

E.g. for postgres "user=postgres host=127.0.0.1 port=5432 dbname=postgres options='--search_path=my_schema' password=mypwd" will select my_schema for the metadata instead of forcing public, or for mysql the database name will be used for the schema name - which is also quite sensical.

I have only implemented this in the mysql and postgresql backends as I don't have experience with- or any test DBs for any of the other supported DBs.

vadz commented 1 month ago

As this seems to be backwards compatible (right?), I see no reason not to add support for specifying a different schema — please submit your PR and I'll try to merge it soon.

TIA!

cstiborg commented 1 month ago

The api does not change, but the sematics of the connection string changes for the two databases I have implemented the change for.

Everything else is unchanged.

PR in #1156