Skip to content

Commit 7c4afaf

Browse files
yahondaclaude
andcommitted
Raise ArgumentError when database and url are both missing
Prevents building a malformed JDBC URL like jdbc:oracle:thin:@//host:port/ when :database is nil and no :url is provided. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b7d3089 commit 7c4afaf

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/plsql/jdbc_connection.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def self.jdbc_connection_url(params)
5959
else
6060
return params[:url] if params[:url]
6161

62+
raise ArgumentError, "database or url option is required" if database.nil? || database.empty?
63+
6264
host = params[:host] || "localhost"
6365
port = params[:port] || 1521
6466

spec/plsql/connection_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,12 @@
526526
end
527527
end
528528

529+
it "should raise ArgumentError when database and url are not provided" do
530+
expect {
531+
PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost")
532+
}.to raise_error(ArgumentError, /database or url option is required/)
533+
end
534+
529535
it "should use custom URL when provided" do
530536
custom_url = "jdbc:oracle:thin:@//custom:1522/MYSERVICENAME"
531537
url = PLSQL::JDBCConnection.jdbc_connection_url(host: "myhost", database: "MYSERVICENAME", url: custom_url)

0 commit comments

Comments
 (0)