diff --git a/spec/adapter/base_spec.cr b/spec/adapter/base_spec.cr index 2e3a6a94..14a953cc 100644 --- a/spec/adapter/base_spec.cr +++ b/spec/adapter/base_spec.cr @@ -461,6 +461,15 @@ describe Jennifer::Adapter::Base do adapter.connection_string(:root).should match(connection_string) end end + + context "without username or password" do + it do + config.user = "" + config.password = "" + connection_string = /^#{adapter.class.protocol}\:\/\/#{config.host}/ + adapter.connection_string(:root).should match(connection_string) + end + end end describe "#query_array" do diff --git a/src/jennifer/adapter/base.cr b/src/jennifer/adapter/base.cr index d7c3de84..a7935c8d 100644 --- a/src/jennifer/adapter/base.cr +++ b/src/jennifer/adapter/base.cr @@ -264,7 +264,7 @@ module Jennifer config.port.try(&.>(0)) ? config.port : nil, type.db? ? config.db : "", connection_query, - config.user, + config.user.blank? ? nil : config.user, config.password && !config.password.empty? ? config.password : nil ).to_s end