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

Allow DB host with characters #457

Closed
AliOsm opened this issue Nov 21, 2023 · 5 comments
Closed

Allow DB host with characters #457

AliOsm opened this issue Nov 21, 2023 · 5 comments

Comments

@AliOsm
Copy link

AliOsm commented Nov 21, 2023

Thanks for this great gem, I'm really happy with it :)

I faced a problem recently in a new project that is deployed on a single server with docker using Kamal.

The URI parser is raising an exception when I pass the DB host as the container name like "myapp-postgres".

Is it possible to change the parser or provide a configuration based integration with postgres like Rails? As Rails is accepting the docker name with no issues.

@ankane
Copy link
Owner

ankane commented Nov 21, 2023

Hi @AliOsm, myapp-postgres should be fine for the hostname, so think it's probably another issue.

@ankane ankane closed this as completed Nov 21, 2023
@AliOsm
Copy link
Author

AliOsm commented Nov 21, 2023

@ankane Actually there is a problem, when I set:

BLAZER_DATABASE_URL=postgres://mypp:myapp@myapp-postgres:5432/myapp_production

And run a query, I get the following error:

URI::InvalidURIError (the scheme postgres does not accept registry part: myapp:myapp@myapp-postgres:5432 (or bad hostname?))

Which leads to:

lib/blazer/adapters/sql_adapter.rb:14:in `block in initialize'
lib/blazer/adapters/sql_adapter.rb:10:in `initialize'
lib/blazer/adapters/sql_adapter.rb:10:in `new'
lib/blazer/adapters/sql_adapter.rb:10:in `initialize'
lib/blazer/data_source.rb:215:in `new'
lib/blazer/data_source.rb:215:in `adapter_instance'
lib/blazer/data_source.rb:224:in `parameter_binding'
lib/blazer/data_source.rb:173:in `bind_params'
lib/blazer/statement.rb:65:in `bind'
lib/blazer/run_statement.rb:7:in `perform'
app/controllers/blazer/queries_controller.rb:150:in `run'

@AliOsm
Copy link
Author

AliOsm commented Nov 21, 2023

The same configs are working fine with Rails.

@ankane
Copy link
Owner

ankane commented Nov 21, 2023

Hostnames can't contain underscores. You'll see the same error with Rails if you pass the same URL as the DATABASE_URL.

@AliOsm
Copy link
Author

AliOsm commented Nov 21, 2023

You are right, it works now! Thanks for your helpful response :)

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

No branches or pull requests

2 participants