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

Ability to target specific postgres schema / search path #512

Open
robertjpayne opened this issue Apr 3, 2023 · 0 comments
Open

Ability to target specific postgres schema / search path #512

robertjpayne opened this issue Apr 3, 2023 · 0 comments

Comments

@robertjpayne
Copy link

robertjpayne commented Apr 3, 2023

Is your feature request related to a problem? Please describe.

Currently pgtyped is using the connection default search path which means you need to pretty much have your schema defined in public otherwise it wont work.

We run a multi-tenanted platform and use postgres schema's to silo customers data effectively which means pgtyped cannot load the type information unless we load the schema into public which would potentially expose some leakage of data if a schema wasn't provided on a query.

Take a query such as this:

select * from users where id = :user_id

Without search path support we must write the query like

select * from <schema>.users where id = :user_id

During runtime its preferable to have queries be generic and the search path set exclusively to a single schema:

set search_path = <schema>;
select * from users where id = :user_id

Describe the solution you'd like

Allow one to configure the schema/search path to use to generate type data from. This allows queries to be written without schema/search path tagged to tables for code-gen but at run time each query can have it's search path set to ensure it goes to the right schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant