[ruby-oci8-commit] [321] trunk/ruby-oci8: * ext/oci8/ocidatetime.c: fix array DML and DateTime object problem.
nobody at rubyforge.org
nobody at rubyforge.org
Sun Feb 15 09:58:37 EST 2009
Revision: 321
Author: kubo
Date: 2009-02-15 09:58:37 -0500 (Sun, 15 Feb 2009)
Log Message:
-----------
* ext/oci8/ocidatetime.c: fix array DML and DateTime object problem.
OCI8::Cursor#bind_param_array(key, array_of_datetime) didn't
work. (Reported by Leo?\197?\161 Bitto)
* test/test_array_dml.rb: fix to test array DML and DateTime object.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/ocidatetime.c
trunk/ruby-oci8/test/test_array_dml.rb
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2009-02-10 13:50:40 UTC (rev 320)
+++ trunk/ruby-oci8/ChangeLog 2009-02-15 14:58:37 UTC (rev 321)
@@ -1,3 +1,9 @@
+2009-02-15 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/ocidatetime.c: fix array DML and DateTime object problem.
+ OCI8::Cursor#bind_param_array(key, array_of_datetime) didn't
+ work. (Reported by Leoš Bitto)
+ * test/test_array_dml.rb: fix to test array DML and DateTime object.
+
2009-02-10 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/bind.c, ext/oci8/oci8.h, ext/oci8/stmt.c: fix array DML
and DateTime object problem. It didn't work with bind classes
Modified: trunk/ruby-oci8/ext/oci8/ocidatetime.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocidatetime.c 2009-02-10 13:50:40 UTC (rev 320)
+++ trunk/ruby-oci8/ext/oci8/ocidatetime.c 2009-02-15 14:58:37 UTC (rev 321)
@@ -244,19 +244,19 @@
static void bind_ocitimestamp_set(oci8_bind_t *obind, void *data, void **null_structp, VALUE val)
{
- oci8_base_t *stmt;
+ oci8_base_t *parent;
oci8_base_t *svcctx;
- stmt = obind->base.parent;
- if (stmt == NULL || stmt->type != OCI_HTYPE_STMT) {
- rb_raise(rb_eRuntimeError, "oci8lib.so internal error [%s:%d, %p, %d]",
- __FILE__, __LINE__,
- stmt, stmt ? stmt->type : -1);
+ parent = obind->base.parent;
+ if (parent != NULL && parent->type == OCI_HTYPE_STMT) {
+ svcctx = parent->parent;
+ } else {
+ svcctx = parent;
}
- svcctx = stmt->parent;
if (svcctx == NULL || svcctx->type != OCI_HTYPE_SVCCTX) {
- rb_raise(rb_eRuntimeError, "oci8lib.so internal error [%s:%d, %p, %d]",
+ rb_raise(rb_eRuntimeError, "oci8lib.so internal error [%s:%d, %p, %d, %p, %d]",
__FILE__, __LINE__,
+ parent, parent ? parent->type : -1,
svcctx, svcctx ? svcctx->type : -1);
}
oci8_set_ocitimestamp(*(OCIDateTime **)data, val, svcctx->self);
@@ -266,6 +266,7 @@
{
oci8_bind_dsc_t *obind_dsc = (oci8_bind_dsc_t *)obind;
+ oci8_link_to_parent((oci8_base_t*)obind, (oci8_base_t*)oci8_get_svcctx(svc));
obind->value_sz = sizeof(OCIDateTime *);
obind->alloc_sz = sizeof(OCIDateTime *);
obind_dsc->type = OCI_DTYPE_TIMESTAMP_TZ;
Modified: trunk/ruby-oci8/test/test_array_dml.rb
===================================================================
--- trunk/ruby-oci8/test/test_array_dml.rb 2009-02-10 13:50:40 UTC (rev 320)
+++ trunk/ruby-oci8/test/test_array_dml.rb 2009-02-15 14:58:37 UTC (rev 321)
@@ -145,13 +145,15 @@
sql = <<-EOS
CREATE TABLE test_table
(N NUMBER(10, 2) NOT NULL,
- V VARCHAR(20))
+ V VARCHAR(20),
+ T TIMESTAMP)
EOS
@conn.exec(sql)
- cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V)")
+ cursor = @conn.parse("INSERT INTO test_table VALUES (:N, :V, :T)")
cursor.max_array_size = 3
cursor.bind_param_array(1, [1, 2, 3])
cursor.bind_param_array(2, ['happy', 'new', 'year'])
+ cursor.bind_param_array(3, [Time.gm(1990,1,1), Time.gm(2000,1,1), Time.gm(2010,1,1)])
assert_nothing_raised() { cursor.exec_array }
cursor.max_array_size = 2
assert_raise(RuntimeError) { cursor.exec_array }
More information about the ruby-oci8-commit
mailing list