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

Client's Schema config does nothing #15

Closed
brandur opened this issue Nov 12, 2023 · 4 comments · Fixed by #18
Closed

Client's Schema config does nothing #15

brandur opened this issue Nov 12, 2023 · 4 comments · Fixed by #18

Comments

@brandur
Copy link
Contributor

brandur commented Nov 12, 2023

Unless I'm mistaken, the Schema option that can be sent to a client doesn't do anything.

I think all we need to do is to make sure to run SET SCHEMA 'xxx' on every new connection?

Also, even if this feature did work, the migration tool doesn't currently support an alternate schema, so that needs to be corrected too.

cc @bgentry

@bgentry
Copy link
Contributor

bgentry commented Nov 12, 2023

Ah, yeah we never got around to implementing this. We can either nuke the setting for now, or try to make the required fixes to make it work. I expect it will come up as a requested setting.

Even without explicit support for this, the user could already be setting a search_path in the pgx.ConnConfig RuntimeParams and any conns we check out will already be configured to use the specified schema. So I'm not actually clear whether we need a setting for this even if we support it.

@brandur
Copy link
Contributor Author

brandur commented Nov 12, 2023

Actually, good point on using pgx to configure it — I kinda like that, although we'd definitely need a section in the docs explaining how to do it because it wouldn't be obvious.

The CLI migrator would probably still need to support a --schema option, but the eventual more flexible rivermigrate package that takes a pgx connection could use the pgx technique.

@bgentry
Copy link
Contributor

bgentry commented Nov 12, 2023

@brandur you can actually set search_path as part of the connection URL if desired: jackc/pgx#1013 (comment)

So maybe the CLI already works with it too?

@brandur
Copy link
Contributor Author

brandur commented Nov 12, 2023

Oh awesome! Another thing we'll have to document because it's pretty non-obvious, but yes, that should solve our problems for now.

brandur added a commit that referenced this issue Nov 13, 2023
As discussed in #15, the `Schema` configuration parameter doesn't
actually do anything, and we realized that it's possible to support this
feature by using an alternate configuration for pgxpool in `search_path`.

Here, drop `Schema` and add a test that verifies that this technique
works. So as to not have to create and migrate an alternate schema, we
cheat a little bit by repointing the schema and then just verifying that
we can't find a `river_job` table there.

I'm finding the test hierarchy in `client_test.go` to be pretty
confusing in determining on what best practice is for what should go
where, so I'm starting out with a new `Test_Client` which I'm hoping we
can start using as a base for most of the general tests in here in a
more reusable way. I leverage `JobArgsReflectKind` and `WorkFunc` in its
subtests so that it's not dependent on our various global job args that
are defined all over the place. Instead, args and the work routine are
colocated right inside the test.

Configuring an alternate schema is definitely going to need its own
documentation page somewhere because it's not obvious, but that'll come
separately.
brandur added a commit that referenced this issue Nov 13, 2023
As discussed in #15, the `Schema` configuration parameter doesn't
actually do anything, and we realized that it's possible to support this
feature by using an alternate configuration for pgxpool in `search_path`.

Here, drop `Schema` and add a test that verifies that this technique
works. So as to not have to create and migrate an alternate schema, we
cheat a little bit by repointing the schema and then just verifying that
we can't find a `river_job` table there.

I'm finding the test hierarchy in `client_test.go` to be pretty
confusing in determining on what best practice is for what should go
where, so I'm starting out with a new `Test_Client` which I'm hoping we
can start using as a base for most of the general tests in here in a
more reusable way. I leverage `JobArgsReflectKind` and `WorkFunc` in its
subtests so that it's not dependent on our various global job args that
are defined all over the place. Instead, args and the work routine are
colocated right inside the test.

Configuring an alternate schema is definitely going to need its own
documentation page somewhere because it's not obvious, but that'll come
separately.

Fixes #15.
brandur added a commit that referenced this issue Nov 13, 2023
As discussed in #15, the `Schema` configuration parameter doesn't
actually do anything, and we realized that it's possible to support this
feature by using an alternate configuration for pgxpool in `search_path`.

Here, drop `Schema` and add a test that verifies that this technique
works. So as to not have to create and migrate an alternate schema, we
cheat a little bit by repointing the schema and then just verifying that
we can't find a `river_job` table there.

I'm finding the test hierarchy in `client_test.go` to be pretty
confusing in determining on what best practice is for what should go
where, so I'm starting out with a new `Test_Client` which I'm hoping we
can start using as a base for most of the general tests in here in a
more reusable way. I leverage `JobArgsReflectKind` and `WorkFunc` in its
subtests so that it's not dependent on our various global job args that
are defined all over the place. Instead, args and the work routine are
colocated right inside the test.

Configuring an alternate schema is definitely going to need its own
documentation page somewhere because it's not obvious, but that'll come
separately.

Fixes #15.
brandur added a commit that referenced this issue Nov 13, 2023
As discussed in #15, the `Schema` configuration parameter doesn't
actually do anything, and we realized that it's possible to support this
feature by using an alternate configuration for pgxpool in `search_path`.

Here, drop `Schema` and add a test that verifies that this technique
works. So as to not have to create and migrate an alternate schema, we
cheat a little bit by repointing the schema and then just verifying that
we can't find a `river_job` table there.

I'm finding the test hierarchy in `client_test.go` to be pretty
confusing in determining on what best practice is for what should go
where, so I'm starting out with a new `Test_Client` which I'm hoping we
can start using as a base for most of the general tests in here in a
more reusable way. I leverage `JobArgsReflectKind` and `WorkFunc` in its
subtests so that it's not dependent on our various global job args that
are defined all over the place. Instead, args and the work routine are
colocated right inside the test.

Configuring an alternate schema is definitely going to need its own
documentation page somewhere because it's not obvious, but that'll come
separately.

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

Successfully merging a pull request may close this issue.

2 participants