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