ydbi 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/.gitignore +8 -0
- data/.travis.yml +15 -0
- data/ChangeLog +321 -314
- data/Gemfile +5 -0
- data/Rakefile +10 -0
- data/TODO +44 -0
- data/bench/bench.rb +79 -0
- data/build/rake_task_lib.rb +186 -0
- data/doc/DBD_SPEC.rdoc +88 -0
- data/doc/DBI_SPEC.rdoc +157 -0
- data/doc/homepage/contact.html +62 -0
- data/doc/homepage/development.html +124 -0
- data/doc/homepage/index.html +83 -0
- data/doc/homepage/ruby-dbi.css +91 -0
- data/lib/dbd/Mysql.rb +137 -0
- data/lib/dbd/ODBC.rb +89 -0
- data/lib/dbd/Pg.rb +188 -0
- data/lib/dbd/SQLite.rb +97 -0
- data/lib/dbd/SQLite3.rb +124 -0
- data/lib/dbd/mysql/database.rb +405 -0
- data/lib/dbd/mysql/driver.rb +125 -0
- data/lib/dbd/mysql/statement.rb +188 -0
- data/lib/dbd/odbc/database.rb +128 -0
- data/lib/dbd/odbc/driver.rb +38 -0
- data/lib/dbd/odbc/statement.rb +137 -0
- data/lib/dbd/pg/database.rb +504 -0
- data/lib/dbd/pg/exec.rb +47 -0
- data/lib/dbd/pg/statement.rb +160 -0
- data/lib/dbd/pg/tuples.rb +121 -0
- data/lib/dbd/pg/type.rb +209 -0
- data/lib/dbd/sqlite/database.rb +151 -0
- data/lib/dbd/sqlite/statement.rb +125 -0
- data/lib/dbd/sqlite3/database.rb +201 -0
- data/lib/dbd/sqlite3/statement.rb +78 -0
- data/lib/dbi.rb +13 -17
- data/lib/dbi/utils/date.rb +7 -3
- data/lib/dbi/version.rb +1 -1
- data/prototypes/types2.rb +237 -0
- data/setup.rb +1585 -0
- data/test/DBD_TESTS +50 -0
- data/test/TESTING +16 -0
- data/test/dbd/general/test_database.rb +206 -0
- data/test/dbd/general/test_statement.rb +326 -0
- data/test/dbd/general/test_types.rb +296 -0
- data/test/dbd/mysql/base.rb +26 -0
- data/test/dbd/mysql/down.sql +19 -0
- data/test/dbd/mysql/test_blob.rb +18 -0
- data/test/dbd/mysql/test_new_methods.rb +7 -0
- data/test/dbd/mysql/test_patches.rb +111 -0
- data/test/dbd/mysql/up.sql +28 -0
- data/test/dbd/odbc/base.rb +30 -0
- data/test/dbd/odbc/down.sql +19 -0
- data/test/dbd/odbc/test_new_methods.rb +12 -0
- data/test/dbd/odbc/test_ping.rb +10 -0
- data/test/dbd/odbc/test_statement.rb +44 -0
- data/test/dbd/odbc/test_transactions.rb +58 -0
- data/test/dbd/odbc/up.sql +33 -0
- data/test/dbd/postgresql/base.rb +31 -0
- data/test/dbd/postgresql/down.sql +31 -0
- data/test/dbd/postgresql/test_arrays.rb +179 -0
- data/test/dbd/postgresql/test_async.rb +121 -0
- data/test/dbd/postgresql/test_blob.rb +36 -0
- data/test/dbd/postgresql/test_bytea.rb +87 -0
- data/test/dbd/postgresql/test_ping.rb +10 -0
- data/test/dbd/postgresql/test_timestamp.rb +77 -0
- data/test/dbd/postgresql/test_transactions.rb +58 -0
- data/test/dbd/postgresql/testdbipg.rb +307 -0
- data/test/dbd/postgresql/up.sql +60 -0
- data/test/dbd/sqlite/base.rb +32 -0
- data/test/dbd/sqlite/test_database.rb +30 -0
- data/test/dbd/sqlite/test_driver.rb +68 -0
- data/test/dbd/sqlite/test_statement.rb +112 -0
- data/test/dbd/sqlite/up.sql +25 -0
- data/test/dbd/sqlite3/base.rb +32 -0
- data/test/dbd/sqlite3/test_database.rb +77 -0
- data/test/dbd/sqlite3/test_driver.rb +67 -0
- data/test/dbd/sqlite3/test_statement.rb +88 -0
- data/test/dbd/sqlite3/up.sql +33 -0
- data/test/dbi/tc_columninfo.rb +4 -9
- data/test/dbi/tc_date.rb +2 -9
- data/test/dbi/tc_dbi.rb +3 -9
- data/test/dbi/tc_row.rb +17 -23
- data/test/dbi/tc_sqlbind.rb +6 -7
- data/test/dbi/tc_statementhandle.rb +3 -4
- data/test/dbi/tc_time.rb +2 -8
- data/test/dbi/tc_timestamp.rb +2 -16
- data/test/dbi/tc_types.rb +5 -11
- data/test/ts_dbd.rb +131 -0
- data/ydbi.gemspec +23 -0
- metadata +128 -10
@@ -0,0 +1,88 @@
|
|
1
|
+
class TestStatement < DBDConfig.testbase(:sqlite3)
|
2
|
+
def test_constructor
|
3
|
+
sth = DBI::DBD::SQLite3::Statement.new("select * from names", @dbh.instance_variable_get("@handle").instance_variable_get("@db"))
|
4
|
+
|
5
|
+
assert_kind_of DBI::DBD::SQLite3::Statement, sth
|
6
|
+
assert sth.instance_variable_get("@db")
|
7
|
+
assert_kind_of ::SQLite3::Database, sth.instance_variable_get("@db")
|
8
|
+
assert_equal(@dbh.instance_variable_get("@handle").instance_variable_get("@db"), sth.instance_variable_get("@db"))
|
9
|
+
assert_kind_of ::SQLite3::Statement, sth.instance_variable_get("@stmt")
|
10
|
+
assert_nil(@sth.instance_variable_get("@result"))
|
11
|
+
|
12
|
+
sth.finish
|
13
|
+
|
14
|
+
sth = @dbh.prepare("select * from names")
|
15
|
+
|
16
|
+
assert_kind_of DBI::StatementHandle, sth
|
17
|
+
sth.finish
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_bind_param
|
21
|
+
sth = DBI::DBD::SQLite3::Statement.new("select * from names", @dbh.instance_variable_get("@handle").instance_variable_get("@db"))
|
22
|
+
|
23
|
+
assert_raises(DBI::InterfaceError) do
|
24
|
+
sth.bind_param(:foo, "monkeys")
|
25
|
+
end
|
26
|
+
|
27
|
+
sth.finish
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_column_info
|
31
|
+
@sth = nil
|
32
|
+
|
33
|
+
assert_nothing_raised do
|
34
|
+
@sth = @dbh.prepare("select * from names")
|
35
|
+
@sth.execute
|
36
|
+
end
|
37
|
+
|
38
|
+
assert_kind_of Array, @sth.column_info
|
39
|
+
assert_kind_of DBI::ColumnInfo, @sth.column_info[0]
|
40
|
+
assert_kind_of DBI::ColumnInfo, @sth.column_info[1]
|
41
|
+
assert_equal [
|
42
|
+
{
|
43
|
+
:name => "name",
|
44
|
+
:sql_type => 12,
|
45
|
+
:precision => 255,
|
46
|
+
:type_name => "varchar"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
:name => "age",
|
50
|
+
:sql_type => 4,
|
51
|
+
:type_name => "integer"
|
52
|
+
}
|
53
|
+
], @sth.column_info
|
54
|
+
|
55
|
+
@sth.finish
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_specific_types
|
59
|
+
assert_nothing_raised do
|
60
|
+
@sth = @dbh.prepare("insert into db_specific_types_test (dbl) values (?)")
|
61
|
+
@sth.execute(11111111.111111)
|
62
|
+
@sth.execute(22)
|
63
|
+
@sth.finish
|
64
|
+
end
|
65
|
+
|
66
|
+
assert_nothing_raised do
|
67
|
+
@sth = @dbh.prepare("select * from db_specific_types_test")
|
68
|
+
@sth.execute
|
69
|
+
assert_equal([11111111.111111], @sth.fetch)
|
70
|
+
assert_equal([22], @sth.fetch)
|
71
|
+
@sth.finish
|
72
|
+
|
73
|
+
assert_equal([[11111111.111111], [22]], @dbh.select_all("select * from db_specific_types_test"))
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_nothing_raised do
|
77
|
+
@sth = @dbh.prepare("insert into names (name, age) values (?, ?)")
|
78
|
+
@sth.execute(:joseph, 20)
|
79
|
+
@sth.finish
|
80
|
+
|
81
|
+
@sth = @dbh.prepare("select name, age from names where name=?")
|
82
|
+
@sth.execute("joseph")
|
83
|
+
rows = @sth.fetch_all
|
84
|
+
@sth.finish
|
85
|
+
assert_equal(rows, [["joseph", 20]])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
create table names (name varchar(255), age integer);
|
2
|
+
---
|
3
|
+
insert into names (name, age) values ("Bob", 21);
|
4
|
+
---
|
5
|
+
insert into names (name, age) values ("Joe", 19);
|
6
|
+
---
|
7
|
+
insert into names (name, age) values ("Jim", 30);
|
8
|
+
---
|
9
|
+
create table precision_test (text_field varchar(20) primary key not null, integer_field integer, decimal_field decimal(2,1), numeric_field numeric(30,6));
|
10
|
+
---
|
11
|
+
create view view_names as select * from names;
|
12
|
+
---
|
13
|
+
create table blob_test (name varchar(255));
|
14
|
+
---
|
15
|
+
create table boolean_test (num integer, mybool boolean);
|
16
|
+
---
|
17
|
+
create table time_test (mytime time);
|
18
|
+
---
|
19
|
+
create table timestamp_test (mytimestamp timestamp);
|
20
|
+
---
|
21
|
+
create table bit_test (mybit bit);
|
22
|
+
---
|
23
|
+
create table field_types_test (foo integer not null primary key default 1);
|
24
|
+
---
|
25
|
+
create table db_specific_types_test (dbl double);
|
26
|
+
---
|
27
|
+
create table names_defined_with_spaces ( name varchar( 255 ), age integer );
|
28
|
+
---
|
29
|
+
insert into names_defined_with_spaces (name, age) values ("Bob", 21);
|
30
|
+
---
|
31
|
+
insert into names_defined_with_spaces (name, age) values ("Joe", 19);
|
32
|
+
---
|
33
|
+
insert into names_defined_with_spaces (name, age) values ("Jim", 30);
|
data/test/dbi/tc_columninfo.rb
CHANGED
@@ -3,17 +3,12 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the DBI::ColumnInfo class.
|
5
5
|
############################################################
|
6
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
7
|
-
$LOAD_PATH.unshift(File.dirname(Dir.pwd))
|
8
|
-
$LOAD_PATH.unshift("../../lib")
|
9
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
10
|
-
$LOAD_PATH.unshift("lib")
|
11
|
-
|
12
|
-
require "dbi/columninfo"
|
13
6
|
require "test/unit"
|
7
|
+
require_relative "../../lib/dbi/columninfo"
|
14
8
|
|
15
9
|
class TC_DBI_ColumnInfo < Test::Unit::TestCase
|
16
10
|
def setup
|
11
|
+
super
|
17
12
|
@colinfo = DBI::ColumnInfo.new(
|
18
13
|
"name" => "test",
|
19
14
|
"sql_type" => "numeric",
|
@@ -30,7 +25,7 @@ class TC_DBI_ColumnInfo < Test::Unit::TestCase
|
|
30
25
|
indexed primary unique
|
31
26
|
/
|
32
27
|
end
|
33
|
-
|
28
|
+
|
34
29
|
def test_constructor
|
35
30
|
assert_nothing_raised{ DBI::ColumnInfo.new }
|
36
31
|
|
@@ -81,7 +76,7 @@ class TC_DBI_ColumnInfo < Test::Unit::TestCase
|
|
81
76
|
assert_respond_to(@colinfo, :keys)
|
82
77
|
assert_equal(@keys.sort, @colinfo.keys.collect { |x| x.to_s }.sort)
|
83
78
|
end
|
84
|
-
|
79
|
+
|
85
80
|
def test_respond_to_hash_methods
|
86
81
|
assert_respond_to(@colinfo, :each)
|
87
82
|
assert_respond_to(@colinfo, :empty?)
|
data/test/dbi/tc_date.rb
CHANGED
@@ -3,15 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the DBI::Date class (currently) located in the utils.rb file.
|
5
5
|
##############################################################################
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift("../../lib")
|
9
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
10
|
-
$LOAD_PATH.unshift("lib")
|
11
|
-
|
12
|
-
require 'date'
|
13
|
-
require 'dbi'
|
14
|
-
require 'test/unit'
|
6
|
+
require "test/unit"
|
7
|
+
require_relative "../../lib/dbi"
|
15
8
|
|
16
9
|
Deprecate.set_action(proc { })
|
17
10
|
|
data/test/dbi/tc_dbi.rb
CHANGED
@@ -3,14 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the DBI module (dbi.rb).
|
5
5
|
######################################################################
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift("../../lib")
|
9
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
10
|
-
$LOAD_PATH.unshift("lib")
|
11
|
-
|
12
|
-
require 'dbi'
|
13
|
-
require 'test/unit'
|
6
|
+
require "test/unit"
|
7
|
+
require_relative "../../lib/dbi"
|
14
8
|
|
15
9
|
class TC_DBI < Test::Unit::TestCase
|
16
10
|
def setup
|
@@ -22,7 +16,7 @@ class TC_DBI < Test::Unit::TestCase
|
|
22
16
|
end
|
23
17
|
|
24
18
|
def test_dbi_version
|
25
|
-
assert_equal("0.5.
|
19
|
+
assert_equal("0.5.7", DBI::VERSION)
|
26
20
|
end
|
27
21
|
|
28
22
|
def test_dbd_module
|
data/test/dbi/tc_row.rb
CHANGED
@@ -1,16 +1,10 @@
|
|
1
1
|
######################################################################
|
2
2
|
# tc_row.rb
|
3
3
|
#
|
4
|
-
# Test case for the DBI::Row class.
|
4
|
+
# Test case for the DBI::Row class.
|
5
5
|
######################################################################
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift("../../lib")
|
9
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
10
|
-
$LOAD_PATH.unshift("lib")
|
11
|
-
|
12
|
-
require 'test/unit'
|
13
|
-
require 'dbi'
|
6
|
+
require "test/unit"
|
7
|
+
require_relative "../../lib/dbi"
|
14
8
|
|
15
9
|
class TC_DBI_Row < Test::Unit::TestCase
|
16
10
|
def setup
|
@@ -18,7 +12,7 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
18
12
|
@cols = %w/first last age/
|
19
13
|
@coltypes = [DBI::Type::Varchar, DBI::Type::Varchar, DBI::Type::Integer]
|
20
14
|
@row = DBI::Row.new(@cols, @coltypes, @data.clone)
|
21
|
-
@row_noconv = DBI::Row.new(@cols, @coltypes, @data.clone, false)
|
15
|
+
@row_noconv = DBI::Row.new(@cols, @coltypes, @data.clone, false)
|
22
16
|
end
|
23
17
|
|
24
18
|
def teardown
|
@@ -46,7 +40,7 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
46
40
|
assert_equal(@data, @row_noconv)
|
47
41
|
end
|
48
42
|
end
|
49
|
-
|
43
|
+
|
50
44
|
# Ensure that constructor only allows Integers or Arrays (or nil)
|
51
45
|
def test_row_constructor
|
52
46
|
assert_nothing_raised{ DBI::Row.new(@cols, @coltypes) }
|
@@ -67,14 +61,14 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
67
61
|
assert_equal(@data[2].to_s, @row.at(2).to_s)
|
68
62
|
assert_equal(@data[99].to_s, @row.at(99).to_s)
|
69
63
|
end
|
70
|
-
|
64
|
+
|
71
65
|
# Should respond to Array and Enumerable methods
|
72
66
|
def test_row_delegate
|
73
67
|
assert_respond_to(@row, :length)
|
74
68
|
assert_respond_to(@row, :each)
|
75
69
|
assert_respond_to(@row, :grep)
|
76
70
|
end
|
77
|
-
|
71
|
+
|
78
72
|
def test_row_length
|
79
73
|
assert_equal(3, @row.length)
|
80
74
|
assert_equal(3, DBI::Row.new(@cols, @coltypes).length)
|
@@ -86,14 +80,14 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
86
80
|
assert_equal(@data[2], @row.by_index(2).to_s)
|
87
81
|
assert_nil(@row.by_index(3))
|
88
82
|
end
|
89
|
-
|
83
|
+
|
90
84
|
def test_row_data_by_field
|
91
85
|
assert_equal @data[0], @row.by_field('first')
|
92
86
|
assert_equal @data[1], @row.by_field('last')
|
93
87
|
assert_equal @data[2], @row.by_field('age').to_s
|
94
88
|
assert_equal nil, @row.by_field('unknown')
|
95
89
|
end
|
96
|
-
|
90
|
+
|
97
91
|
def test_row_set_values
|
98
92
|
assert_respond_to(@row, :set_values)
|
99
93
|
assert_nothing_raised{ @row.set_values(["John", "Doe", 23]) }
|
@@ -101,14 +95,14 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
101
95
|
assert_equal("Doe", @row.by_index(1))
|
102
96
|
assert_equal(23, @row.by_index(2))
|
103
97
|
end
|
104
|
-
|
98
|
+
|
105
99
|
def test_row_to_h
|
106
100
|
assert_respond_to(@row, :to_h)
|
107
101
|
assert_nothing_raised{ @row.to_h }
|
108
102
|
assert_kind_of(Hash, @row.to_h)
|
109
103
|
assert_equal({"first"=>"Daniel", "last"=>"Berger", "age"=>36}, @row.to_h)
|
110
104
|
end
|
111
|
-
|
105
|
+
|
112
106
|
def test_row_column_names
|
113
107
|
assert_respond_to(@row, :column_names)
|
114
108
|
assert_nothing_raised{ @row.column_names }
|
@@ -123,13 +117,13 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
123
117
|
assert_kind_of(Array, @row.column_names)
|
124
118
|
assert_equal(["first", "last", "age"], @row.column_names)
|
125
119
|
end
|
126
|
-
|
120
|
+
|
127
121
|
def test_indexing_numeric
|
128
|
-
assert_equal(@data[0], @row[0])
|
129
|
-
assert_equal(@data[1], @row[1])
|
130
|
-
assert_equal(@data[2], @row[2].to_s)
|
122
|
+
assert_equal(@data[0], @row[0])
|
123
|
+
assert_equal(@data[1], @row[1])
|
124
|
+
assert_equal(@data[2], @row[2].to_s)
|
131
125
|
end
|
132
|
-
|
126
|
+
|
133
127
|
def test_indexing_string_or_symbol
|
134
128
|
assert_equal(@data[0], @row['first'])
|
135
129
|
assert_equal(@data[0], @row[:first])
|
@@ -137,7 +131,7 @@ class TC_DBI_Row < Test::Unit::TestCase
|
|
137
131
|
assert_equal(@data[2], @row['age'].to_s)
|
138
132
|
assert_equal(nil, @row['unknown'])
|
139
133
|
end
|
140
|
-
|
134
|
+
|
141
135
|
def test_indexing_regexp
|
142
136
|
assert_equal(["Daniel"], @row[/first/])
|
143
137
|
assert_equal(["Berger"], @row[/last/])
|
data/test/dbi/tc_sqlbind.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "dbi/sql"
|
1
|
+
require "test/unit"
|
2
|
+
require_relative "../../lib/dbi/sql"
|
4
3
|
|
5
4
|
# ====================================================================
|
6
5
|
class TestSqlBind < Test::Unit::TestCase
|
@@ -60,18 +59,18 @@ class TestSqlBind < Test::Unit::TestCase
|
|
60
59
|
def test_minus_bug
|
61
60
|
sql = "SELECT 1 - 3"
|
62
61
|
res = "SELECT 1 - 3"
|
63
|
-
assert_equal res, bind(self, sql, [])
|
62
|
+
assert_equal res, bind(self, sql, [])
|
64
63
|
end
|
65
64
|
|
66
65
|
def test_minus2
|
67
|
-
sql = "SELECT * from test --Dan's query"
|
68
|
-
assert_equal sql, bind(self, sql, [])
|
66
|
+
sql = "SELECT * from test --Dan's query"
|
67
|
+
assert_equal sql, bind(self, sql, [])
|
69
68
|
end
|
70
69
|
|
71
70
|
def test_slash
|
72
71
|
sql = "SELECT 5 / 4"
|
73
72
|
res = "SELECT 5 / 4"
|
74
|
-
assert_equal res, bind(self, sql, [])
|
73
|
+
assert_equal res, bind(self, sql, [])
|
75
74
|
end
|
76
75
|
|
77
76
|
def test_much
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'dbi'
|
1
|
+
require "test/unit"
|
2
|
+
require_relative "../../lib/dbi"
|
4
3
|
|
5
4
|
class TC_DBI_StatementHandle < Test::Unit::TestCase
|
6
5
|
def test_fetch
|
@@ -9,7 +8,7 @@ class TC_DBI_StatementHandle < Test::Unit::TestCase
|
|
9
8
|
def mock_handle.column_info; {}; end
|
10
9
|
def mock_handle.fetch; nil; end
|
11
10
|
sth = DBI::StatementHandle.new( mock_handle, true, true, false, true)
|
12
|
-
|
11
|
+
|
13
12
|
10.times do
|
14
13
|
assert_nil sth.fetch
|
15
14
|
end
|
data/test/dbi/tc_time.rb
CHANGED
@@ -3,14 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Test case for the DBI::Time class (currently) located in the utils.rb file.
|
5
5
|
##############################################################################
|
6
|
-
|
7
|
-
|
8
|
-
$LOAD_PATH.unshift("../../lib")
|
9
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
10
|
-
$LOAD_PATH.unshift("lib")
|
11
|
-
|
12
|
-
require 'dbi'
|
13
|
-
require 'test/unit'
|
6
|
+
require "test/unit"
|
7
|
+
require_relative "../../lib/dbi"
|
14
8
|
|
15
9
|
Deprecate.set_action(proc { })
|
16
10
|
|
data/test/dbi/tc_timestamp.rb
CHANGED
@@ -4,17 +4,8 @@
|
|
4
4
|
# Test case for the DBI::Timestamp class (currently) located in the
|
5
5
|
# utils.rb file.
|
6
6
|
##############################################################################
|
7
|
-
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift("../../lib")
|
10
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
11
|
-
$LOAD_PATH.unshift("lib")
|
12
|
-
|
13
|
-
require 'date'
|
14
|
-
require 'dbi'
|
15
|
-
require 'test/unit'
|
16
|
-
|
17
|
-
Deprecate.set_action(proc { })
|
7
|
+
require "test/unit"
|
8
|
+
require_relative "../../lib/dbi"
|
18
9
|
|
19
10
|
class TC_DBI_Date < Test::Unit::TestCase
|
20
11
|
def setup
|
@@ -134,9 +125,4 @@ class TC_DBI_Date < Test::Unit::TestCase
|
|
134
125
|
assert_equal(2006, @dbi_ts.year)
|
135
126
|
end
|
136
127
|
|
137
|
-
def teardown
|
138
|
-
@date = nil
|
139
|
-
@time = nil
|
140
|
-
@dbi_ts = nil
|
141
|
-
end
|
142
128
|
end
|
data/test/dbi/tc_types.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
2
|
-
$LOAD_PATH.unshift(File.dirname(Dir.pwd))
|
3
|
-
$LOAD_PATH.unshift("../../lib")
|
4
|
-
$LOAD_PATH.unshift("../../lib/dbi")
|
5
|
-
$LOAD_PATH.unshift("lib")
|
6
|
-
|
7
|
-
require "dbi"
|
8
1
|
require "test/unit"
|
2
|
+
require_relative "../../lib/dbi"
|
9
3
|
|
10
4
|
class MyType
|
11
5
|
def initialize(obj)
|
@@ -107,7 +101,7 @@ class TC_DBI_Type < Test::Unit::TestCase
|
|
107
101
|
# string coercion
|
108
102
|
dt = DateTime.now
|
109
103
|
assert_equal(dt.to_s, klass.parse(dt).to_s)
|
110
|
-
|
104
|
+
|
111
105
|
t = Time.now
|
112
106
|
assert_equal(DateTime.parse(t.to_s).to_s, klass.parse(t).to_s)
|
113
107
|
|
@@ -137,7 +131,7 @@ class TC_DBI_Type < Test::Unit::TestCase
|
|
137
131
|
)
|
138
132
|
|
139
133
|
# precision tests, related to ticket #27182
|
140
|
-
|
134
|
+
|
141
135
|
# iso8601 (bypasses regex)
|
142
136
|
[
|
143
137
|
'2009-09-27T19:41:00-05:00',
|
@@ -158,7 +152,7 @@ class TC_DBI_Type < Test::Unit::TestCase
|
|
158
152
|
)
|
159
153
|
|
160
154
|
# unix convention (uses regex)
|
161
|
-
|
155
|
+
|
162
156
|
[
|
163
157
|
'2009-09-27 19:41:00 -05:00',
|
164
158
|
'2009-09-27 19:41:00.123 -05:00'
|
@@ -208,7 +202,7 @@ class TC_DBI_TypeUtil < Test::Unit::TestCase
|
|
208
202
|
assert_kind_of(String, cast(Time.now))
|
209
203
|
assert_kind_of(String, cast(Date.today))
|
210
204
|
assert_kind_of(String, cast(DateTime.now))
|
211
|
-
|
205
|
+
|
212
206
|
obj = Time.now
|
213
207
|
assert_equal(datecast(obj), cast(obj))
|
214
208
|
obj = Date.today
|