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

Bug: pgdriver.WithConnParams search_path does not allow multiple parameters/schemas #611

Open
tomalaci opened this issue Jul 10, 2022 · 1 comment
Labels
enhancement New feature or request stale

Comments

@tomalaci
Copy link

The issue #214 and its PR #220 added ability to change search_path, however, it seems to only allow single schema/parameter. If you specify comma-separated string of multiple schemas then it constructs wrong kind of SET statement.

For example, suppose you have a schema "myschema" where you plan to have some tables and then you want to have a common schema "extensions" to store extensions in. A scenario described in this StackOverflow answer: https://stackoverflow.com/a/43937189

The above scenario should have following search_path set:

SET search_path = "myschema", "extensions";

Unfortunately bun's pgdriver.WithConnParams formats parameters as a single string. So this...

pgdriver.WithConnParams(map[string]interface{}{
	"search_path": "myschema, extensions",
})

... becomes this ...

SET search_path = "myschema, extensions";

... and that doesn't seem to work for correctly finding common extensions.

I also tried specifying search_path parameters with []string type but it failed with pgdriver: unexpected arg: []string.

Suggestion for solution

You should allow []string values in pgdriver.WithConnParams. So specifying this:

pgdriver.WithConnParams(map[string]interface{}{
	"search_path": []string{"myschema", "extensions"}
})

... would properly separate each string element into its own quoted element in SET statement like this ...

SET search_path = "myschema", "extensions";

Let me know if something is unclear! Thanks!

@tomalaci tomalaci changed the title Allow search_path to have multiple schemas Bug: pgdriver.WithConnParams search_path does not allow multiple parameters/schemas Jul 10, 2022
@vmihailenco vmihailenco added the enhancement New feature or request label Jul 22, 2022
Copy link

github-actions bot commented Nov 7, 2024

This issue has been automatically marked as stale because it has not had activity in the last 30 days. If there is no update within the next 7 days, this issue will be closed.

@github-actions github-actions bot added the stale label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale
Projects
None yet
Development

No branches or pull requests

2 participants