dbd-sqlite3 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/dbd/SQLite3.rb +10 -10
- data/test/DBD_TESTS +2 -0
- data/test/dbd/general/test_database.rb +48 -12
- data/test/dbd/general/test_statement.rb +84 -7
- data/test/dbd/general/test_types.rb +30 -2
- data/test/dbd/sqlite3/base.rb +0 -1
- data/test/dbd/sqlite3/test_database.rb +46 -1
- data/test/dbd/sqlite3/test_driver.rb +3 -3
- data/test/dbd/sqlite3/test_statement.rb +5 -1
- data/test/dbd/sqlite3/up.sql +9 -1
- data/test/ts_dbd.rb +14 -1
- metadata +65 -56
data/lib/dbd/SQLite3.rb
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# DBD::SQLite3
|
|
3
|
-
#
|
|
3
|
+
#
|
|
4
4
|
# copyright (c) 2005 Jun Mukai <mukai@jmuk.org>
|
|
5
5
|
# Compatibility patches by Erik Hollensbe <erik@hollensbe.org>
|
|
6
|
-
#
|
|
6
|
+
#
|
|
7
7
|
# All rights reserved.
|
|
8
8
|
#
|
|
9
|
-
# Redistribution and use in source and binary forms, with or without
|
|
10
|
-
# modification, are permitted provided that the following conditions
|
|
9
|
+
# Redistribution and use in source and binary forms, with or without
|
|
10
|
+
# modification, are permitted provided that the following conditions
|
|
11
11
|
# are met:
|
|
12
|
-
# 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
13
13
|
# notice, this list of conditions and the following disclaimer.
|
|
14
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
|
15
|
-
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
15
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
16
16
|
# documentation and/or other materials provided with the distribution.
|
|
17
17
|
# 3. The name of the author may not be used to endorse or promote products
|
|
18
18
|
# derived from this software without specific prior written permission.
|
|
@@ -50,7 +50,7 @@ module DBI
|
|
|
50
50
|
# Only things that extend DBI's results are documented.
|
|
51
51
|
#
|
|
52
52
|
module SQLite3
|
|
53
|
-
VERSION = "1.2.
|
|
53
|
+
VERSION = "1.2.4"
|
|
54
54
|
DESCRIPTION = "SQLite 3.x DBD for DBI"
|
|
55
55
|
|
|
56
56
|
#
|
|
@@ -70,9 +70,9 @@ module DBI
|
|
|
70
70
|
# It will raise DBI::DatabaseError should it find any.
|
|
71
71
|
#
|
|
72
72
|
def self.parse_type(type_name)
|
|
73
|
-
# FIXME plucked from SQLite driver, this needs to be in DBI proper
|
|
73
|
+
# FIXME plucked from SQLite driver, this needs to be in DBI proper
|
|
74
74
|
return ['varchar'] unless type_name
|
|
75
|
-
type_name.match(/^([^\(]+)(\((\d+)(
|
|
75
|
+
type_name.match(/^([^\(\s]+)\s*(\(\s*(\d+)\s*(,\s*(\d+))?\s*\))?$/)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
#
|
data/test/DBD_TESTS
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Using DBD tests
|
|
3
3
|
================================================================================
|
|
4
4
|
|
|
5
|
+
Before you do anything, read the TESTING file.
|
|
6
|
+
|
|
5
7
|
Create a YAML file named .ruby-dbi.test-config.yaml in your home directory.
|
|
6
8
|
|
|
7
9
|
This file is a hash of keys that determine what you want to test and how you
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
@class = Class.new(DBDConfig.testbase(DBDConfig.current_dbtype)) do
|
|
2
|
+
|
|
3
|
+
def test_empty_query
|
|
4
|
+
["", " ", "\t"].each do |str|
|
|
5
|
+
[:do, :prepare, :execute, :select_one, :select_all].each do |call|
|
|
6
|
+
assert_raises(DBI::InterfaceError) do
|
|
7
|
+
@dbh.send(call, str)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
2
13
|
def test_ping
|
|
3
14
|
assert @dbh.ping
|
|
4
15
|
# XXX if it isn't obvious, this should be tested better. Not sure what
|
|
@@ -11,7 +22,7 @@
|
|
|
11
22
|
|
|
12
23
|
assert(cols)
|
|
13
24
|
assert_kind_of(Array, cols)
|
|
14
|
-
assert_equal(
|
|
25
|
+
assert_equal(4, cols.length)
|
|
15
26
|
|
|
16
27
|
# the first column should always be "text_field" and have the following
|
|
17
28
|
# properties:
|
|
@@ -30,19 +41,42 @@
|
|
|
30
41
|
end
|
|
31
42
|
|
|
32
43
|
assert_equal(
|
|
33
|
-
DBI::Type::Varchar,
|
|
34
|
-
DBI::TypeUtil.type_name_to_module(cols[0]["type_name"])
|
|
44
|
+
DBI::Type::Varchar.object_id,
|
|
45
|
+
DBI::TypeUtil.type_name_to_module(cols[0]["type_name"]).object_id
|
|
35
46
|
)
|
|
36
47
|
|
|
37
48
|
# the second column should always be "integer_field" and have the following
|
|
38
49
|
# properties:
|
|
39
50
|
assert_equal("integer_field", cols[1]["name"])
|
|
40
51
|
assert(cols[1]["nullable"])
|
|
41
|
-
assert_equal(1, cols[
|
|
42
|
-
assert_equal(2, cols[
|
|
52
|
+
assert_equal(1, cols[2]["scale"])
|
|
53
|
+
assert_equal(2, cols[2]["precision"])
|
|
54
|
+
|
|
55
|
+
assert_equal(
|
|
56
|
+
DBI::Type::Integer.object_id,
|
|
57
|
+
DBI::TypeUtil.type_name_to_module(cols[1]["type_name"]).object_id
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# the second column should always be "integer_field" and have the following
|
|
61
|
+
# properties:
|
|
62
|
+
assert_equal("decimal_field", cols[2]["name"])
|
|
63
|
+
assert(cols[2]["nullable"])
|
|
64
|
+
assert_equal(1, cols[2]["scale"])
|
|
65
|
+
assert_equal(2, cols[2]["precision"])
|
|
43
66
|
assert_equal(
|
|
44
|
-
DBI::Type::Decimal,
|
|
45
|
-
DBI::TypeUtil.type_name_to_module(cols[
|
|
67
|
+
DBI::Type::Decimal.object_id,
|
|
68
|
+
DBI::TypeUtil.type_name_to_module(cols[2]["type_name"]).object_id
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# the second column should always be "numeric_field" and have the following
|
|
72
|
+
# properties:
|
|
73
|
+
assert_equal("numeric_field", cols[3]["name"])
|
|
74
|
+
assert(cols[3]["nullable"])
|
|
75
|
+
assert_equal(6, cols[3]["scale"])
|
|
76
|
+
assert_equal(30, cols[3]["precision"])
|
|
77
|
+
assert_equal(
|
|
78
|
+
DBI::Type::Decimal.object_id,
|
|
79
|
+
DBI::TypeUtil.type_name_to_module(cols[3]["type_name"]).object_id
|
|
46
80
|
)
|
|
47
81
|
|
|
48
82
|
# finally, we ensure that every column in the array is a ColumnInfo
|
|
@@ -123,11 +157,13 @@
|
|
|
123
157
|
"views"
|
|
124
158
|
]
|
|
125
159
|
end
|
|
126
|
-
|
|
127
|
-
case dbtype
|
|
160
|
+
|
|
161
|
+
case dbtype
|
|
128
162
|
when "postgresql"
|
|
129
163
|
tables.reject! { |x| x =~ /^pg_/ }
|
|
130
|
-
assert_equal %w(array_test bit_test blob_test boolean_test bytea_test db_specific_types_test field_types_test names precision_test time_test timestamp_test view_names), tables
|
|
164
|
+
assert_equal %w(array_test bit_test blob_test boolean_test bytea_test db_specific_types_test enum_type_test field_types_test names precision_test time_test timestamp_test view_names), tables
|
|
165
|
+
when 'sqlite3'
|
|
166
|
+
assert_equal %w(bit_test blob_test boolean_test db_specific_types_test field_types_test names names_defined_with_spaces precision_test time_test timestamp_test view_names), tables
|
|
131
167
|
else
|
|
132
168
|
assert_equal %w(bit_test blob_test boolean_test db_specific_types_test field_types_test names precision_test time_test timestamp_test view_names), tables
|
|
133
169
|
end
|
|
@@ -142,13 +178,13 @@
|
|
|
142
178
|
assert !@dbh["AutoCommit"]
|
|
143
179
|
|
|
144
180
|
# test committing an outstanding transaction
|
|
145
|
-
|
|
181
|
+
|
|
146
182
|
@sth = @dbh.prepare("insert into names (name, age) values (?, ?)")
|
|
147
183
|
@sth.execute("Billy", 22)
|
|
148
184
|
@sth.finish
|
|
149
185
|
|
|
150
186
|
assert @dbh["AutoCommit"] = true # should commit at this point
|
|
151
|
-
|
|
187
|
+
|
|
152
188
|
@sth = @dbh.prepare("select * from names where name = ?")
|
|
153
189
|
@sth.execute("Billy")
|
|
154
190
|
assert_equal [ "Billy", 22 ], @sth.fetch
|
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
@class = Class.new(DBDConfig.testbase(DBDConfig.current_dbtype)) do
|
|
2
|
+
|
|
3
|
+
def prep_status_statement
|
|
4
|
+
@sth.finish if (@sth and !@sth.finished?)
|
|
5
|
+
@sth = @dbh.prepare("select * from names order by age")
|
|
6
|
+
@sth.raise_error = true
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def test_status
|
|
10
|
+
names_rc = 3
|
|
11
|
+
|
|
12
|
+
[:fetch, :fetch_hash, :each, :fetch_all].each do |call|
|
|
13
|
+
assert_raise(DBI::InterfaceError, DBI::NotSupportedError) do
|
|
14
|
+
prep_status_statement
|
|
15
|
+
@sth.send(call)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# for these next three, it doesn't really matter what the args are, it should fail
|
|
20
|
+
assert_raises(DBI::InterfaceError, DBI::NotSupportedError) do
|
|
21
|
+
prep_status_statement
|
|
22
|
+
@sth.fetch_many(1)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
assert_raises(DBI::InterfaceError, DBI::NotSupportedError) do
|
|
26
|
+
prep_status_statement
|
|
27
|
+
@sth.fetch_scroll(0, 0)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
assert_raises(DBI::InterfaceError, DBI::NotSupportedError) do
|
|
31
|
+
prep_status_statement
|
|
32
|
+
@sth.each { |x| }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
assert_raises(DBI::InterfaceError) do
|
|
36
|
+
prep_status_statement
|
|
37
|
+
@sth.execute
|
|
38
|
+
2.times { @sth.fetch_all }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
assert_raises(DBI::InterfaceError) do
|
|
42
|
+
prep_status_statement
|
|
43
|
+
@sth.execute
|
|
44
|
+
# XXX fetch_many won't know it can't fetch anything until the third time around.
|
|
45
|
+
3.times { @sth.fetch_many(names_rc) }
|
|
46
|
+
end
|
|
47
|
+
end
|
|
2
48
|
|
|
3
49
|
def test_execute
|
|
4
50
|
assert_nothing_raised do
|
|
@@ -44,7 +90,7 @@
|
|
|
44
90
|
|
|
45
91
|
assert(cols)
|
|
46
92
|
assert_kind_of(Array, cols)
|
|
47
|
-
assert_equal(
|
|
93
|
+
assert_equal(4, cols.length)
|
|
48
94
|
|
|
49
95
|
# the first column should always be "text_field" and have the following
|
|
50
96
|
# properties:
|
|
@@ -61,18 +107,49 @@
|
|
|
61
107
|
end
|
|
62
108
|
|
|
63
109
|
assert_equal(
|
|
64
|
-
DBI::Type::Varchar,
|
|
65
|
-
DBI::TypeUtil.type_name_to_module(cols[0]["type_name"])
|
|
110
|
+
DBI::Type::Varchar.object_id,
|
|
111
|
+
DBI::TypeUtil.type_name_to_module(cols[0]["type_name"]).object_id
|
|
66
112
|
)
|
|
67
113
|
|
|
68
114
|
# the second column should always be "integer_field" and have the following
|
|
69
115
|
# properties:
|
|
70
116
|
assert_equal("integer_field", cols[1]["name"])
|
|
71
|
-
|
|
72
|
-
|
|
117
|
+
# if these aren't set on the field, they should not exist
|
|
118
|
+
# FIXME mysql does not follow this rule, neither does ODBC
|
|
119
|
+
if dbtype == "mysql"
|
|
120
|
+
assert_equal(0, cols[1]["scale"])
|
|
121
|
+
assert_equal(11, cols[1]["precision"])
|
|
122
|
+
elsif dbtype == "odbc"
|
|
123
|
+
assert_equal(0, cols[1]["scale"])
|
|
124
|
+
assert_equal(10, cols[1]["precision"])
|
|
125
|
+
else
|
|
126
|
+
assert(!cols[1]["scale"])
|
|
127
|
+
assert(!cols[1]["precision"])
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
assert_equal(
|
|
131
|
+
DBI::Type::Integer.object_id,
|
|
132
|
+
DBI::TypeUtil.type_name_to_module(cols[1]["type_name"]).object_id
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# the second column should always be "integer_field" and have the following
|
|
136
|
+
# properties:
|
|
137
|
+
assert_equal("decimal_field", cols[2]["name"])
|
|
138
|
+
assert_equal(1, cols[2]["scale"])
|
|
139
|
+
assert_equal(2, cols[2]["precision"])
|
|
140
|
+
assert_equal(
|
|
141
|
+
DBI::Type::Decimal.object_id,
|
|
142
|
+
DBI::TypeUtil.type_name_to_module(cols[2]["type_name"]).object_id
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# the second column should always be "numeric_field" and have the following
|
|
146
|
+
# properties:
|
|
147
|
+
assert_equal("numeric_field", cols[3]["name"])
|
|
148
|
+
assert_equal(6, cols[3]["scale"])
|
|
149
|
+
assert_equal(30, cols[3]["precision"])
|
|
73
150
|
assert_equal(
|
|
74
|
-
DBI::Type::Decimal,
|
|
75
|
-
DBI::TypeUtil.type_name_to_module(cols[
|
|
151
|
+
DBI::Type::Decimal.object_id,
|
|
152
|
+
DBI::TypeUtil.type_name_to_module(cols[3]["type_name"]).object_id
|
|
76
153
|
)
|
|
77
154
|
|
|
78
155
|
cols.each { |col| assert_kind_of(DBI::ColumnInfo, col) }
|
|
@@ -25,6 +25,34 @@
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
def test_numeric_types
|
|
29
|
+
assert(@dbh.convert_types)
|
|
30
|
+
|
|
31
|
+
@sth = @dbh.prepare("insert into precision_test (text_field, integer_field, decimal_field, numeric_field) values (?, ?, ?, ?)")
|
|
32
|
+
assert(@sth.convert_types)
|
|
33
|
+
1.step(5) do |x|
|
|
34
|
+
@sth.execute("poop#{x}", x, x + 0.123, x + 0.234)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
@sth.finish
|
|
38
|
+
|
|
39
|
+
@sth = @dbh.prepare("select integer_field, decimal_field, numeric_field from precision_test")
|
|
40
|
+
@sth.execute
|
|
41
|
+
col_info = @sth.column_info
|
|
42
|
+
1.step(5) do |x|
|
|
43
|
+
row = @sth.fetch
|
|
44
|
+
|
|
45
|
+
assert_kind_of(Integer, row[0])
|
|
46
|
+
assert_kind_of(BigDecimal, row[1])
|
|
47
|
+
assert_kind_of(BigDecimal, row[2])
|
|
48
|
+
|
|
49
|
+
# FIXME BigDecimal requires a string and some databases will pad
|
|
50
|
+
# decimal/numeric with constrained precision. We should account for
|
|
51
|
+
# this, but I'm not quite sure how yet.
|
|
52
|
+
end
|
|
53
|
+
@sth.finish
|
|
54
|
+
end
|
|
55
|
+
|
|
28
56
|
# FIXME
|
|
29
57
|
# Ideally, this test should be split across the DBI tests and DBD, but for
|
|
30
58
|
# now testing against the DBDs really doesn't cost us anything other than
|
|
@@ -62,9 +90,9 @@
|
|
|
62
90
|
@sth = @dbh.prepare("select name, age from names order by age")
|
|
63
91
|
|
|
64
92
|
# can't bind_coltype before execute
|
|
65
|
-
|
|
93
|
+
assert_raises(DBI::InterfaceError) { @sth.bind_coltype(1, DBI::Type::Float) }
|
|
66
94
|
# can't index < 1
|
|
67
|
-
|
|
95
|
+
assert_raises(DBI::InterfaceError) { @sth.bind_coltype(0, DBI::Type::Float) }
|
|
68
96
|
end
|
|
69
97
|
|
|
70
98
|
def test_noconv
|
data/test/dbd/sqlite3/base.rb
CHANGED
|
@@ -21,6 +21,51 @@ class TestDatabase < DBDConfig.testbase(:sqlite3)
|
|
|
21
21
|
:sql_type => 4,
|
|
22
22
|
:type_name => "integer"
|
|
23
23
|
}
|
|
24
|
-
], @dbh.columns("names")
|
|
24
|
+
], @dbh.columns("names")
|
|
25
|
+
|
|
26
|
+
assert_equal [
|
|
27
|
+
{
|
|
28
|
+
:name => "name",
|
|
29
|
+
:default => nil,
|
|
30
|
+
:nullable => true,
|
|
31
|
+
:sql_type => 100,
|
|
32
|
+
:precision => 255,
|
|
33
|
+
:type_name => "varchar"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
:name => "age",
|
|
37
|
+
:default => nil,
|
|
38
|
+
:nullable => true,
|
|
39
|
+
:sql_type => 4,
|
|
40
|
+
:type_name => "integer"
|
|
41
|
+
}
|
|
42
|
+
], @dbh.columns("names_defined_with_spaces")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_parse_type
|
|
46
|
+
# Some tests to ensure various whitespace and case styles don't confuse parse_type.
|
|
47
|
+
|
|
48
|
+
match = DBI::DBD::SQLite3.parse_type( 'VARCHAR' )
|
|
49
|
+
assert_equal 'VARCHAR', match[ 1 ]
|
|
50
|
+
|
|
51
|
+
match = DBI::DBD::SQLite3.parse_type( 'VARCHAR(4096)' )
|
|
52
|
+
assert_equal 'VARCHAR', match[ 1 ]
|
|
53
|
+
assert_equal '4096', match[ 3 ]
|
|
54
|
+
|
|
55
|
+
match = DBI::DBD::SQLite3.parse_type( 'varchar(4096)' )
|
|
56
|
+
assert_equal 'varchar', match[ 1 ]
|
|
57
|
+
assert_equal '4096', match[ 3 ]
|
|
58
|
+
|
|
59
|
+
match = DBI::DBD::SQLite3.parse_type( 'VARCHAR( 4096 )' )
|
|
60
|
+
assert_equal 'VARCHAR', match[ 1 ]
|
|
61
|
+
assert_equal '4096', match[ 3 ]
|
|
62
|
+
|
|
63
|
+
match = DBI::DBD::SQLite3.parse_type( 'VARCHAR ( 4096 )' )
|
|
64
|
+
assert_equal 'VARCHAR', match[ 1 ]
|
|
65
|
+
assert_equal '4096', match[ 3 ]
|
|
66
|
+
|
|
67
|
+
match = DBI::DBD::SQLite3.parse_type( 'VARCHAR (4096)' )
|
|
68
|
+
assert_equal 'VARCHAR', match[ 1 ]
|
|
69
|
+
assert_equal '4096', match[ 3 ]
|
|
25
70
|
end
|
|
26
71
|
end
|
|
@@ -18,17 +18,17 @@ class TestDriver < DBDConfig.testbase(:sqlite3)
|
|
|
18
18
|
assert_kind_of DBI::DatabaseHandle, dbh
|
|
19
19
|
|
|
20
20
|
# first argument should be a string
|
|
21
|
-
|
|
21
|
+
assert_raises(DBI::InterfaceError) do
|
|
22
22
|
DBI::DBD::SQLite3::Driver.new.connect(nil, nil, nil, { })
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
# that string should have some frackin' length
|
|
26
|
-
|
|
26
|
+
assert_raises(DBI::InterfaceError) do
|
|
27
27
|
DBI::DBD::SQLite3::Driver.new.connect("", nil, nil, { })
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
# last argument should be a hash
|
|
31
|
-
|
|
31
|
+
assert_raises(DBI::InterfaceError) do
|
|
32
32
|
DBI::DBD::SQLite3::Driver.new.connect(config['dbname'], nil, nil, nil)
|
|
33
33
|
end
|
|
34
34
|
|
|
@@ -20,7 +20,7 @@ class TestStatement < DBDConfig.testbase(:sqlite3)
|
|
|
20
20
|
def test_bind_param
|
|
21
21
|
sth = DBI::DBD::SQLite3::Statement.new("select * from names", @dbh.instance_variable_get("@handle").instance_variable_get("@db"))
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
assert_raises(DBI::InterfaceError) do
|
|
24
24
|
sth.bind_param(:foo, "monkeys")
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -59,6 +59,7 @@ class TestStatement < DBDConfig.testbase(:sqlite3)
|
|
|
59
59
|
assert_nothing_raised do
|
|
60
60
|
@sth = @dbh.prepare("insert into db_specific_types_test (dbl) values (?)")
|
|
61
61
|
@sth.execute(11111111.111111)
|
|
62
|
+
@sth.execute(22)
|
|
62
63
|
@sth.finish
|
|
63
64
|
end
|
|
64
65
|
|
|
@@ -66,7 +67,10 @@ class TestStatement < DBDConfig.testbase(:sqlite3)
|
|
|
66
67
|
@sth = @dbh.prepare("select * from db_specific_types_test")
|
|
67
68
|
@sth.execute
|
|
68
69
|
assert_equal([11111111.111111], @sth.fetch)
|
|
70
|
+
assert_equal([22], @sth.fetch)
|
|
69
71
|
@sth.finish
|
|
72
|
+
|
|
73
|
+
assert_equal([[11111111.111111], [22]], @dbh.select_all("select * from db_specific_types_test"))
|
|
70
74
|
end
|
|
71
75
|
end
|
|
72
76
|
end
|
data/test/dbd/sqlite3/up.sql
CHANGED
|
@@ -6,7 +6,7 @@ insert into names (name, age) values ("Joe", 19);
|
|
|
6
6
|
---
|
|
7
7
|
insert into names (name, age) values ("Jim", 30);
|
|
8
8
|
---
|
|
9
|
-
create table precision_test (text_field varchar(20) primary key not null, integer_field decimal(2,1));
|
|
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
10
|
---
|
|
11
11
|
create view view_names as select * from names;
|
|
12
12
|
---
|
|
@@ -23,3 +23,11 @@ create table bit_test (mybit bit);
|
|
|
23
23
|
create table field_types_test (foo integer not null primary key default 1);
|
|
24
24
|
---
|
|
25
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/ts_dbd.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'test-unit'
|
|
1
3
|
# figure out what tests to run
|
|
2
4
|
require 'yaml'
|
|
3
5
|
require 'test/unit/testsuite'
|
|
@@ -17,6 +19,16 @@ module Test::Unit::Assertions
|
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
22
|
+
class Class
|
|
23
|
+
def name=(klass_name)
|
|
24
|
+
@name = klass_name
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def name
|
|
28
|
+
return @name || super
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
20
32
|
module DBDConfig
|
|
21
33
|
@testbase = { }
|
|
22
34
|
@current_dbtype = nil
|
|
@@ -68,6 +80,7 @@ module DBDConfig
|
|
|
68
80
|
|
|
69
81
|
def self.set_testbase(klass_name, klass)
|
|
70
82
|
@testbase[klass_name] = klass
|
|
83
|
+
klass.name = klass_name.to_s
|
|
71
84
|
end
|
|
72
85
|
|
|
73
86
|
def self.suite
|
|
@@ -110,7 +123,7 @@ if __FILE__ == $0
|
|
|
110
123
|
Dir["dbd/#{dbtype}/test*.rb"].each { |file| require file }
|
|
111
124
|
# run the general tests
|
|
112
125
|
DBDConfig.current_dbtype = dbtype.to_sym
|
|
113
|
-
Dir["dbd/general/test*.rb"].each { |file| load file; DBDConfig.suite << @class }
|
|
126
|
+
Dir["dbd/general/test*.rb"].each { |file| load file; @class.name = file; DBDConfig.suite << @class }
|
|
114
127
|
end
|
|
115
128
|
elsif !config["dbtypes"]
|
|
116
129
|
warn "Please see test/DBD_TESTS for information on configuring DBD tests."
|
metadata
CHANGED
|
@@ -1,43 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
|
-
rubygems_version: 0.9.4
|
|
3
|
-
specification_version: 1
|
|
4
2
|
name: dbd-sqlite3
|
|
5
3
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 1.2.
|
|
7
|
-
date: 2008-09-27 00:00:00 -07:00
|
|
8
|
-
summary: SQLite 3.x DBD for DBI
|
|
9
|
-
require_paths:
|
|
10
|
-
- lib
|
|
11
|
-
email: ruby-dbi-users@rubyforge.org
|
|
12
|
-
homepage: http://www.rubyforge.org/projects/ruby-dbi
|
|
13
|
-
rubyforge_project: ruby-dbi
|
|
14
|
-
description: SQLite 3.x DBD for DBI
|
|
15
|
-
autorequire:
|
|
16
|
-
default_executable:
|
|
17
|
-
bindir: bin
|
|
18
|
-
has_rdoc: true
|
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
20
|
-
requirements:
|
|
21
|
-
- - ">="
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: 1.8.0
|
|
24
|
-
version:
|
|
4
|
+
version: 1.2.4
|
|
25
5
|
platform: ruby
|
|
26
|
-
signing_key:
|
|
27
|
-
cert_chain:
|
|
28
|
-
post_install_message:
|
|
29
6
|
authors:
|
|
30
7
|
- Erik Hollensbe
|
|
31
8
|
- Christopher Maujean
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
|
|
13
|
+
date: 2008-12-15 00:00:00 -08:00
|
|
14
|
+
default_executable:
|
|
15
|
+
dependencies:
|
|
16
|
+
- !ruby/object:Gem::Dependency
|
|
17
|
+
name: dbi
|
|
18
|
+
type: :runtime
|
|
19
|
+
version_requirement:
|
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
21
|
+
requirements:
|
|
22
|
+
- - ">="
|
|
23
|
+
- !ruby/object:Gem::Version
|
|
24
|
+
version: 0.4.0
|
|
25
|
+
version:
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: sqlite3-ruby
|
|
28
|
+
type: :runtime
|
|
29
|
+
version_requirement:
|
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
31
|
+
requirements:
|
|
32
|
+
- - ">="
|
|
33
|
+
- !ruby/object:Gem::Version
|
|
34
|
+
version: "0"
|
|
35
|
+
version:
|
|
36
|
+
description: SQLite 3.x DBD for DBI
|
|
37
|
+
email: ruby-dbi-users@rubyforge.org
|
|
38
|
+
executables: []
|
|
39
|
+
|
|
40
|
+
extensions: []
|
|
41
|
+
|
|
42
|
+
extra_rdoc_files:
|
|
43
|
+
- README
|
|
44
|
+
- LICENSE
|
|
45
|
+
- ChangeLog
|
|
32
46
|
files:
|
|
33
|
-
- test/dbd/general/test_database.rb
|
|
34
|
-
- test/dbd/general/test_statement.rb
|
|
35
47
|
- test/dbd/general/test_types.rb
|
|
48
|
+
- test/dbd/general/test_statement.rb
|
|
49
|
+
- test/dbd/general/test_database.rb
|
|
36
50
|
- test/dbd/sqlite3/base.rb
|
|
37
|
-
- test/dbd/sqlite3/test_database.rb
|
|
38
51
|
- test/dbd/sqlite3/test_statement.rb
|
|
39
52
|
- test/dbd/sqlite3/test_driver.rb
|
|
40
53
|
- test/dbd/sqlite3/up.sql
|
|
54
|
+
- test/dbd/sqlite3/test_database.rb
|
|
41
55
|
- lib/dbd/SQLite3.rb
|
|
42
56
|
- lib/dbd/sqlite3/database.rb
|
|
43
57
|
- lib/dbd/sqlite3/statement.rb
|
|
@@ -45,36 +59,31 @@ files:
|
|
|
45
59
|
- README
|
|
46
60
|
- LICENSE
|
|
47
61
|
- ChangeLog
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
has_rdoc: true
|
|
63
|
+
homepage: http://www.rubyforge.org/projects/ruby-dbi
|
|
64
|
+
post_install_message:
|
|
50
65
|
rdoc_options: []
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
require_paths:
|
|
68
|
+
- lib
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: 1.8.0
|
|
74
|
+
version:
|
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: "0"
|
|
80
|
+
version:
|
|
60
81
|
requirements: []
|
|
61
82
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
- !ruby/object:Gem::Version
|
|
70
|
-
version: 0.4.0
|
|
71
|
-
version:
|
|
72
|
-
- !ruby/object:Gem::Dependency
|
|
73
|
-
name: sqlite3-ruby
|
|
74
|
-
version_requirement:
|
|
75
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
76
|
-
requirements:
|
|
77
|
-
- - ">"
|
|
78
|
-
- !ruby/object:Gem::Version
|
|
79
|
-
version: 0.0.0
|
|
80
|
-
version:
|
|
83
|
+
rubyforge_project: ruby-dbi
|
|
84
|
+
rubygems_version: 1.3.1
|
|
85
|
+
signing_key:
|
|
86
|
+
specification_version: 2
|
|
87
|
+
summary: SQLite 3.x DBD for DBI
|
|
88
|
+
test_files:
|
|
89
|
+
- test/ts_dbd.rb
|