[ruby-oci8-commit] [271] trunk/ruby-oci8: * lib/oci8/oci8.rb: add OraNumber#to_json and OraDate#to_json.
nobody at rubyforge.org
nobody at rubyforge.org
Sat Jul 12 09:41:39 EDT 2008
Revision: 271
Author: kubo
Date: 2008-07-12 09:41:38 -0400 (Sat, 12 Jul 2008)
Log Message:
-----------
* lib/oci8/oci8.rb: add OraNumber#to_json and OraDate#to_json.
* lib/oci8/metadata.rb: define char_used?, char_size, fsprecision
and lfprecision methods to subclasses of OCI8::Metadata::Base
onln when Oracie 9i or upper. They ara unavailable on Oracle
8.1 or lower.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/lib/oci8/metadata.rb
trunk/ruby-oci8/lib/oci8/oci8.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2008-07-12 13:01:27 UTC (rev 270)
+++ trunk/ruby-oci8/ChangeLog 2008-07-12 13:41:38 UTC (rev 271)
@@ -1,3 +1,10 @@
+2008-07-12 KUBO Takehiro <kubo at jiubao.org>
+ * lib/oci8/oci8.rb: add OraNumber#to_json and OraDate#to_json.
+ * lib/oci8/metadata.rb: define char_used?, char_size, fsprecision
+ and lfprecision methods to subclasses of OCI8::Metadata::Base
+ onln when Oracie 9i or upper. They ara unavailable on Oracle
+ 8.1 or lower.
+
2008-07-06 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/oci8.h: add comments.
Modified: trunk/ruby-oci8/lib/oci8/metadata.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/metadata.rb 2008-07-12 13:01:27 UTC (rev 270)
+++ trunk/ruby-oci8/lib/oci8/metadata.rb 2008-07-12 13:41:38 UTC (rev 271)
@@ -998,14 +998,20 @@
__charset_form
end
- # The fractional seconds precision of a datetime or interval.
- def fsprecision
- __ub1(OCI_ATTR_FSPRECISION)
- end
+ if OCI8.oracle_client_version >= 900
+ # The fractional seconds precision of a datetime or interval.
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def fsprecision
+ __ub1(OCI_ATTR_FSPRECISION)
+ end
- # The leading field precision of an interval
- def lfprecision
- __ub1(OCI_ATTR_LFPRECISION)
+ # The leading field precision of an interval
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def lfprecision
+ __ub1(OCI_ATTR_LFPRECISION)
+ end
end
# character set name if the type attribute is of a string/character type.
@@ -1326,18 +1332,24 @@
## Table 6-13 Attributes Belonging to Columns of Tables or Views
- # returns the type of length semantics of the column.
- # [<tt>:byte</tt>] byte-length semantics
- # [<tt>:char</tt>] character-length semantics.
- def char_used?
- __ub4(OCI_ATTR_CHAR_USED) != 0
- end
+ if OCI8.oracle_client_version >= 900
+ # returns the type of length semantics of the column.
+ # [<tt>:byte</tt>] byte-length semantics
+ # [<tt>:char</tt>] character-length semantics.
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def char_used?
+ __ub4(OCI_ATTR_CHAR_USED) != 0
+ end
- # returns the column character length which is the number of
- # characters allowed in the column. It is the counterpart of
- # OCI8::Metadata::Column#data_size which gets the byte length.
- def char_size
- __ub2(OCI_ATTR_CHAR_SIZE)
+ # returns the column character length which is the number of
+ # characters allowed in the column. It is the counterpart of
+ # OCI8::Metadata::Column#data_size which gets the byte length.
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def char_size
+ __ub2(OCI_ATTR_CHAR_SIZE)
+ end
end
# The maximum size of the column. This length is
@@ -1418,14 +1430,20 @@
## Table 6-8 Attributes Belonging to Type Attributes
## But Column also have these.
- # The fractional seconds precision of a datetime or interval.
- def fsprecision
- __ub1(OCI_ATTR_FSPRECISION)
- end
+ if OCI8.oracle_client_version >= 900
+ # The fractional seconds precision of a datetime or interval.
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def fsprecision
+ __ub1(OCI_ATTR_FSPRECISION)
+ end
- # The leading field precision of an interval
- def lfprecision
- __ub1(OCI_ATTR_LFPRECISION)
+ # The leading field precision of an interval
+ #
+ # (unavailable on Oracle 8.1 or lower)
+ def lfprecision
+ __ub1(OCI_ATTR_LFPRECISION)
+ end
end
# The character set name, if the column is of a string/character type
Modified: trunk/ruby-oci8/lib/oci8/oci8.rb
===================================================================
--- trunk/ruby-oci8/lib/oci8/oci8.rb 2008-07-12 13:01:27 UTC (rev 270)
+++ trunk/ruby-oci8/lib/oci8/oci8.rb 2008-07-12 13:41:38 UTC (rev 271)
@@ -578,6 +578,10 @@
out.scalar(taguri, self.to_s, :plain)
end
end
+
+ def to_json(options=nil) # :nodoc:
+ to_datetime.to_json(options)
+ end
end
class OraNumber
@@ -590,6 +594,10 @@
out.scalar(taguri, self.to_s, :plain)
end
end
+
+ def to_json(options=nil) # :nodoc:
+ to_s
+ end
end
class Numeric
More information about the ruby-oci8-commit
mailing list