[ruby-oci8-commit] [482] trunk/ruby-oci8: ENV['ORA_SDTZ'] instead of ' alter session set time_zone = ...'

nobody at rubyforge.org nobody at rubyforge.org
Sat Dec 10 01:50:38 EST 2011


Revision: 482
Author:   kubo
Date:     2011-12-10 01:50:37 -0500 (Sat, 10 Dec 2011)

Log Message:
-----------
ENV['ORA_SDTZ'] instead of 'alter session set time_zone = ...'

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/lib/oci8/oci8.rb
    trunk/ruby-oci8/lib/oci8/properties.rb
    trunk/ruby-oci8/lib/oci8.rb.in
    trunk/ruby-oci8/test/test_datetime.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2011-12-10 05:50:41 UTC (rev 481)
+++ trunk/ruby-oci8/ChangeLog	2011-12-10 06:50:37 UTC (rev 482)
@@ -1,4 +1,11 @@
 2011-12-10  KUBO Takehiro  <kubo at jiubao.org>
+	* lib/oci8/oci8.rb, lib/oci8/properties.rb, test/test_datetime.rb:
+	    revert OCI8.properties[:time_zone] which was added 5 days ago.
+	* lib/oci8.rb.in: use ENV['ORA_SDTZ'] instead of 'alter session set time_zone = ...'
+	    to set Oracle session time zone. On cygwin, explicitly set
+	    environments variables which start with 'ORA_' to WIN32 environments.
+
+2011-12-10  KUBO Takehiro  <kubo at jiubao.org>
 	* test/test_oci8.rb: fix test_select when TZ set to daylight saving time.
 	    (reported by Yasuo Honda)
 

Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb	2011-12-10 05:50:41 UTC (rev 481)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb	2011-12-10 06:50:37 UTC (rev 482)
@@ -140,9 +140,6 @@
 
     @prefetch_rows = nil
     @username = nil
-
-    time_zone = OCI8.properties[:time_zone] || ENV['TZ']
-    exec("alter session set time_zone = '#{time_zone}'") if time_zone and time_zone.length > 0
   end
 
   # call-seq:

Modified: trunk/ruby-oci8/lib/oci8/properties.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/properties.rb	2011-12-10 05:50:41 UTC (rev 481)
+++ trunk/ruby-oci8/lib/oci8/properties.rb	2011-12-10 06:50:37 UTC (rev 482)
@@ -5,7 +5,6 @@
 class OCI8
 
   @@properties = {
-    :time_zone => nil,
     :length_semantics => :byte,
     :bind_string_as_nchar => false,
     :float_conversion_type => :ruby,
@@ -19,8 +18,6 @@
   def @@properties.[]=(name, val)
     raise IndexError, "No such property name: #{name}" unless @@properties.has_key?(name)
     case name
-    when :time_zone
-      raise TypeError, "invalid property type #{val.class}" unless val.nil? or val.is_a? String
     when :length_semantic
       if val != :byte and val != :char
         raise ArgumentError, "Invalid property value #{val} for :length_semantics."
@@ -53,14 +50,6 @@
   #
   # Supported properties are listed below:
   #
-  # [:time_zone]
-  #     (new in 2.1.0)
-  #     
-  #     If your application runs in a time zone which adopt daylight saving time,
-  #     you should set the environment variable TZ or this +time_zone+ property.
-  #     Otherwise, Oracle session time zone is set with current constant
-  #     offset from GMT.
-  #
   # [:length_semantics]
   #     (new in 2.1.0)
   #     

Modified: trunk/ruby-oci8/lib/oci8.rb.in
===================================================================
--- trunk/ruby-oci8/lib/oci8.rb.in	2011-12-10 05:50:41 UTC (rev 481)
+++ trunk/ruby-oci8/lib/oci8.rb.in	2011-12-10 06:50:37 UTC (rev 482)
@@ -6,16 +6,21 @@
 #  ruby -r oci8 -e 'OCI8.new("scott", "tiger", nil).exec("select * from emp") do |r| puts r.join(","); end'
 #  # select all data from emp and print them as CVS format.
 
+ENV['ORA_SDTZ'] = ENV['TZ'] unless ENV['ORA_SDTZ']
+
 if RUBY_PLATFORM =~ /cygwin/
   # Cygwin manages environment variables by itself.
   # They don't synchroize with Win32's ones.
   # This set some Oracle's environment variables to win32's enviroment.
   require 'Win32API'
   win32setenv = Win32API.new('Kernel32.dll', 'SetEnvironmentVariableA', 'PP', 'I')
-  ['NLS_LANG', 'ORA_NLS10', 'ORA_NLS32', 'ORA_NLS33', 'ORACLE_BASE', 'ORACLE_HOME', 'ORACLE_SID', 'TNS_ADMIN', 'LOCAL'].each do |name|
+  ['NLS_LANG', 'TNS_ADMIN', 'LOCAL'].each do |name|
     val = ENV[name]
     win32setenv.call(name, val && val.dup)
   end
+  ENV.each do |name, val|
+    win32setenv.call(name, val && val.dup) if name =~ /^ORA/
+  end
 end
 
 so_basename = 'oci8lib_'

Modified: trunk/ruby-oci8/test/test_datetime.rb
===================================================================
--- trunk/ruby-oci8/test/test_datetime.rb	2011-12-10 05:50:41 UTC (rev 481)
+++ trunk/ruby-oci8/test/test_datetime.rb	2011-12-10 06:50:37 UTC (rev 482)
@@ -579,34 +579,4 @@
       end
     end
   end
-
-  def test_time_zone_property
-    orig_prop = OCI8.properties[:time_zone]
-    orig_env = ENV['TZ']
-    conn = nil
-    begin
-      assert_raise(TypeError) do
-        OCI8.properties[:time_zone] = 1
-      end
-
-      OCI8.properties[:time_zone] = 'America/New_York'
-      ENV['TZ'] = nil
-      conn = get_oci8_connection
-      assert_equal('America/New_York', conn.select_one('select sessiontimezone from dual')[0])
-      conn.logoff
-      conn = nil
-
-      OCI8.properties[:time_zone] = nil
-      ENV['TZ'] = 'Europe/Riga'
-      conn = get_oci8_connection
-      assert_equal('Europe/Riga', conn.select_one('select sessiontimezone from dual')[0])
-      conn.logoff
-      conn = nil
-
-    ensure
-      conn.logoff if conn
-      OCI8.properties[:time_zone] = orig_prop
-      ENV['TZ'] = orig_env
-    end
-  end
 end # TestOCI8




More information about the ruby-oci8-commit mailing list