From 8353c9e0abbe2c9e1e728e74077b181d3258cd53 Mon Sep 17 00:00:00 2001 From: Kubo Takehiro Date: Tue, 2 Jan 2024 16:32:47 +0900 Subject: [PATCH] Use two digits for ext part of Oracle 23 version string --- lib/oci8/oci8.rb | 2 +- lib/oci8/oracle_version.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/oci8/oci8.rb b/lib/oci8/oci8.rb index c7b9bb86..5dc1caae 100644 --- a/lib/oci8/oci8.rb +++ b/lib/oci8/oci8.rb @@ -349,7 +349,7 @@ def inspect # @see OCI8.oracle_client_version # @return [OCI8::OracleVersion] def oracle_server_version - @oracle_server_version ||= OCI8::OracleVersion.new(oracle_server_vernum) + @oracle_server_version ||= OCI8::OracleVersion.new(oracle_server_vernum, is_server_version: true) end # Returns the Oracle database character set name such as AL32UTF8. diff --git a/lib/oci8/oracle_version.rb b/lib/oci8/oracle_version.rb index 7203046e..50c45022 100644 --- a/lib/oci8/oracle_version.rb +++ b/lib/oci8/oracle_version.rb @@ -61,7 +61,7 @@ class OracleVersion # oraver.port_update # => 0 # # @return [OCI8::OracleVersion] - def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil) + def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil, is_server_version: false) if arg.is_a? String major, minor, update, patch, port_update = arg.split('.').collect do |v| v.to_i @@ -91,6 +91,7 @@ def initialize(arg, minor = nil, update = nil, patch = nil, port_update = nil) else (@major << 24) | (@minor << 20) | (@update << 12) | (@patch << 8) | @port_update end + @is_server_version = is_server_version end # Compares +self+ and +other+. @@ -127,7 +128,11 @@ def to_i # # @return [String] def to_s - format('%d.%d.%d.%d.%d', @major, @minor, @update, @patch, @port_update) + if @is_server_version && @major >= 23 + format('%d.%d.%d.%d.%02d', @major, @minor, @update, @patch, @port_update) + else + format('%d.%d.%d.%d.%d', @major, @minor, @update, @patch, @port_update) + end end # Returns true if +self+ and +other+ are the same type and have