ydbi 0.5.0 → 0.5.1

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +4 -0
  3. data/build/Rakefile.dbi.rb +4 -4
  4. data/lib/dbi/version.rb +1 -1
  5. data/test/dbi/tc_dbi.rb +1 -1
  6. metadata +9 -124
  7. data/.gitignore +0 -6
  8. data/Gemfile +0 -4
  9. data/Rakefile +0 -8
  10. data/TODO +0 -44
  11. data/bench/bench.rb +0 -79
  12. data/build/rake_task_lib.rb +0 -187
  13. data/doc/DBD_SPEC.rdoc +0 -88
  14. data/doc/DBI_SPEC.rdoc +0 -157
  15. data/doc/homepage/contact.html +0 -62
  16. data/doc/homepage/development.html +0 -124
  17. data/doc/homepage/index.html +0 -83
  18. data/doc/homepage/ruby-dbi.css +0 -91
  19. data/lib/dbd/Mysql.rb +0 -137
  20. data/lib/dbd/ODBC.rb +0 -89
  21. data/lib/dbd/Pg.rb +0 -188
  22. data/lib/dbd/SQLite.rb +0 -97
  23. data/lib/dbd/SQLite3.rb +0 -124
  24. data/lib/dbd/mysql/database.rb +0 -405
  25. data/lib/dbd/mysql/driver.rb +0 -125
  26. data/lib/dbd/mysql/statement.rb +0 -188
  27. data/lib/dbd/odbc/database.rb +0 -128
  28. data/lib/dbd/odbc/driver.rb +0 -38
  29. data/lib/dbd/odbc/statement.rb +0 -137
  30. data/lib/dbd/pg/database.rb +0 -516
  31. data/lib/dbd/pg/exec.rb +0 -47
  32. data/lib/dbd/pg/statement.rb +0 -160
  33. data/lib/dbd/pg/tuples.rb +0 -121
  34. data/lib/dbd/pg/type.rb +0 -209
  35. data/lib/dbd/sqlite/database.rb +0 -151
  36. data/lib/dbd/sqlite/statement.rb +0 -125
  37. data/lib/dbd/sqlite3/database.rb +0 -201
  38. data/lib/dbd/sqlite3/statement.rb +0 -78
  39. data/prototypes/types2.rb +0 -237
  40. data/setup.rb +0 -1585
  41. data/test/DBD_TESTS +0 -50
  42. data/test/TESTING +0 -16
  43. data/test/dbd/general/test_database.rb +0 -206
  44. data/test/dbd/general/test_statement.rb +0 -326
  45. data/test/dbd/general/test_types.rb +0 -296
  46. data/test/dbd/mysql/base.rb +0 -26
  47. data/test/dbd/mysql/down.sql +0 -19
  48. data/test/dbd/mysql/test_blob.rb +0 -18
  49. data/test/dbd/mysql/test_new_methods.rb +0 -7
  50. data/test/dbd/mysql/test_patches.rb +0 -111
  51. data/test/dbd/mysql/up.sql +0 -28
  52. data/test/dbd/odbc/base.rb +0 -30
  53. data/test/dbd/odbc/down.sql +0 -19
  54. data/test/dbd/odbc/test_new_methods.rb +0 -12
  55. data/test/dbd/odbc/test_ping.rb +0 -10
  56. data/test/dbd/odbc/test_statement.rb +0 -44
  57. data/test/dbd/odbc/test_transactions.rb +0 -58
  58. data/test/dbd/odbc/up.sql +0 -33
  59. data/test/dbd/postgresql/base.rb +0 -31
  60. data/test/dbd/postgresql/down.sql +0 -31
  61. data/test/dbd/postgresql/test_arrays.rb +0 -179
  62. data/test/dbd/postgresql/test_async.rb +0 -121
  63. data/test/dbd/postgresql/test_blob.rb +0 -36
  64. data/test/dbd/postgresql/test_bytea.rb +0 -87
  65. data/test/dbd/postgresql/test_ping.rb +0 -10
  66. data/test/dbd/postgresql/test_timestamp.rb +0 -77
  67. data/test/dbd/postgresql/test_transactions.rb +0 -58
  68. data/test/dbd/postgresql/testdbipg.rb +0 -307
  69. data/test/dbd/postgresql/up.sql +0 -60
  70. data/test/dbd/sqlite/base.rb +0 -32
  71. data/test/dbd/sqlite/test_database.rb +0 -30
  72. data/test/dbd/sqlite/test_driver.rb +0 -68
  73. data/test/dbd/sqlite/test_statement.rb +0 -112
  74. data/test/dbd/sqlite/up.sql +0 -25
  75. data/test/dbd/sqlite3/base.rb +0 -32
  76. data/test/dbd/sqlite3/test_database.rb +0 -77
  77. data/test/dbd/sqlite3/test_driver.rb +0 -67
  78. data/test/dbd/sqlite3/test_statement.rb +0 -88
  79. data/test/dbd/sqlite3/up.sql +0 -33
  80. data/test/ts_dbd.rb +0 -131
  81. data/ydbi.gemspec +0 -24
@@ -1,307 +0,0 @@
1
- require 'dbd/Pg'
2
-
3
- module DBI
4
- class ForcedError < ::DBI::Error
5
- end
6
- end
7
-
8
- ######################################################################
9
- # Test the PostgreSql DBD driver. This test exercises options
10
- # difficult to test through the standard DBI interface.
11
- #
12
- class TestDbdPostgres < DBDConfig.testbase(:postgresql)
13
-
14
- # FIXME this is a feature that should be there, but currently isn't.
15
- # def test_connect
16
- # dbd = get_dbd
17
- # assert_not_nil dbd.connection
18
- # assert_equal 'localhost', dbd.connection.host
19
- # assert_equal 'erikh', dbd.connection.user
20
- # assert_equal 'rubytest', dbd.connection.db
21
- # assert_equal 5432, dbd.connection.port
22
- # ensure
23
- # dbd.disconnect if dbd
24
- # end
25
-
26
- # this monkeypatch is used for the following test... NEVER integrate this into DBI proper.
27
- class DBI::StatementHandle < DBI::Handle
28
- def stmt_name
29
- @handle.instance_variable_get(:@stmt_name)
30
- end
31
- end
32
-
33
- def test_database_name
34
- assert_nothing_raised do
35
- assert_equal DBDConfig.get_config[dbtype]['dbname'], @dbh.database_name
36
- end
37
- end
38
-
39
- def test_enum_type
40
- assert_nothing_raised do
41
- assert(@dbh.convert_types)
42
- @sth = @dbh.prepare("insert into enum_type_test values (?)")
43
- @sth.execute("one")
44
- @sth.finish
45
-
46
- @sth = @dbh.prepare("select foo from enum_type_test")
47
- @sth.execute
48
- assert_equal(@sth.fetch, ['one'])
49
- @sth.finish
50
- end
51
- end
52
-
53
- def test_statement_finish_deallocates_sth
54
- assert_nothing_raised do
55
- @sth = @dbh.prepare("select * from names")
56
- @sth.execute
57
- sth_internal_name = @sth.stmt_name
58
- assert(sth_internal_name)
59
- assert(!sth_internal_name.empty?)
60
- @sth.finish
61
-
62
- # at this point, the statement name should no longer exist
63
- #
64
- # XXX this is a potentially horrible way of doing it since it'll
65
- # create another prepared statement, but *at this time*, I don't
66
- # see any drawbacks and the alternative is considerably uglier.
67
-
68
- @sth = @dbh.prepare("select count(*) from pg_prepared_statements where name = ?")
69
- @sth.execute(sth_internal_name)
70
- assert_equal([0], @sth.fetch)
71
- @sth.finish
72
- end
73
- end
74
-
75
- def test_binding
76
- assert(@dbh["pg_native_binding"])
77
-
78
- assert_raises(DBI::ProgrammingError) do
79
- @sth = @dbh.prepare("select * from names where age IS NOT ?")
80
- @sth.execute("NULL")
81
- @sth.finish
82
- end
83
-
84
- assert_nothing_raised do
85
- @dbh["pg_native_binding"] = false
86
- @sth = @dbh.prepare("select * from names where age IS NOT ? order by age")
87
- @sth.execute("NULL")
88
- assert_equal(
89
- [
90
- ["Joe", 19],
91
- ["Bob", 21],
92
- ["Jim", 30],
93
- ],
94
- @sth.fetch_all
95
- )
96
-
97
- @sth.finish
98
-
99
- @sth = @dbh.prepare("select * from names where age = ?")
100
- @sth.execute(19)
101
- assert_equal(
102
- [
103
- ["Joe", 19]
104
- ],
105
- @sth.fetch_all
106
- )
107
-
108
- @sth.finish
109
- end
110
- end
111
-
112
- def test_function_multiple_return_values
113
- @sth = @dbh.prepare("SELECT age, select_subproperty(age, NULL), select_subproperty(age, 1) FROM names WHERE age = 19")
114
- @sth.execute
115
- assert_equal([[19, nil, 19]], @sth.fetch_all)
116
- @sth.finish
117
- end
118
-
119
- def test_columns
120
- assert_equal(
121
- [
122
- {
123
- :name =>"age",
124
- :default =>nil,
125
- :primary =>nil,
126
- :scale =>nil,
127
- :sql_type =>4,
128
- :nullable =>true,
129
- :indexed =>false,
130
- :precision =>4,
131
- :type_name =>"integer",
132
- :unique =>nil,
133
- :array_of_type =>nil
134
- },
135
- {
136
- :name =>"name",
137
- :default =>nil,
138
- :primary =>nil,
139
- :scale =>nil,
140
- :sql_type =>12,
141
- :nullable =>true,
142
- :indexed =>false,
143
- :precision =>255,
144
- :type_name =>"character varying",
145
- :unique =>nil,
146
- :array_of_type =>nil
147
- }
148
- ], @dbh.columns("names").sort_by { |x| x["name"] })
149
-
150
- assert_equal(2, @dbh.columns("names").size) # make sure this works before the search path change
151
-
152
- assert_equal(0, @dbh.columns("tbl").size) # tbl doesn't exist in public
153
-
154
- @dbh.do('SET search_path TO schema1,schema2,"$user",public')
155
-
156
- assert_equal(1, @dbh.columns('tbl').size);
157
- assert_equal(
158
- [
159
- {
160
- :name =>"foo",
161
- :default =>nil,
162
- :primary =>nil,
163
- :scale =>nil,
164
- :sql_type =>4,
165
- :nullable =>true,
166
- :indexed =>false,
167
- :precision =>4,
168
- :type_name =>"integer",
169
- :unique =>nil,
170
- :array_of_type =>nil
171
-
172
- }
173
- ],
174
- @dbh.columns('tbl')
175
- )
176
-
177
- end
178
-
179
- def test_statement_name_uniqueness
180
- 5000.times do
181
- begin
182
- @dbh.prepare('SELECT 1').execute()
183
- raise DBI::ForcedError
184
- sth.finish # never reached
185
- rescue DBI::ProgrammingError => e
186
- # ERROR: prepared statement "ruby-dbi:Pg:-604926268" already exists
187
- # This should never happen
188
- raise e
189
- rescue DBI::ForcedError
190
- # no-op
191
- end
192
- end
193
- end
194
-
195
- def test_connect_errors
196
- dbd = nil
197
- ex = assert_raises(DBI::OperationalError) {
198
- dbd = DBI::DBD::Pg::Database.new('rubytest:1234', 'jim', nil, {})
199
- }
200
- ex = assert_raises(DBI::OperationalError) {
201
- dbd = DBI::DBD::Pg::Database.new('bad_db_name', 'jim', nil, {})
202
- }
203
-
204
- # this corresponds to the test_parse_url_expected_errors test in tc_dbi.rb
205
- assert_raises(DBI::InterfaceError) do
206
- DBI.connect("dbi:Pg").disconnect
207
- end
208
-
209
- ensure
210
- dbd.disconnect if dbd
211
- end
212
-
213
- def skip_test_type_map
214
- dbd = get_dbd
215
- def dbd.type_map
216
- @type_map
217
- end
218
- assert dbd.type_map
219
- assert_equal 21, dbd.convert("21", 23)
220
- assert_equal "21", dbd.convert("21", 1043)
221
- assert_equal 21.5, dbd.convert("21.5", 701)
222
- end
223
-
224
- def test_simple_command
225
- dbd = get_dbd
226
- res = dbd.do("INSERT INTO names (name, age) VALUES('Dan', 16)")
227
- assert_equal 1, res
228
-
229
- @sth = get_dbi.prepare("SELECT name FROM names WHERE age=16")
230
- @sth.execute
231
- assert @sth.fetchable?
232
- # XXX FIXME This is a bug in the DBD. #rows should equal 1 for select statements.
233
- assert_equal 0, @sth.rows
234
- ensure
235
- dbd.do("DELETE FROM names WHERE age < 20")
236
- dbd.disconnect if dbd
237
- end
238
-
239
- def test_bad_command
240
- dbd = get_dbd
241
- assert_raises(DBI::ProgrammingError) {
242
- dbd.do("INSERT INTO bad_table (name, age) VALUES('Dave', 12)")
243
- }
244
- ensure
245
- dbd.disconnect if dbd
246
- end
247
-
248
- def test_query_single
249
- dbd = get_dbi
250
- res = dbd.prepare("SELECT name, age FROM names WHERE age=21;")
251
- assert res
252
- res.execute
253
- fields = res.column_info
254
- assert_equal 2, fields.length
255
- assert_equal 'name', fields[0]['name']
256
- assert_equal 'varchar', fields[0]['type_name']
257
- assert_equal 'age', fields[1]['name']
258
- assert_equal 'int4', fields[1]['type_name']
259
-
260
- row = res.fetch
261
-
262
- assert_equal 'Bob', row[0]
263
- assert_equal 21, row[1]
264
-
265
- row = res.fetch
266
- assert_nil row
267
-
268
- res.finish
269
- ensure
270
- dbd.disconnect if dbd
271
- end
272
-
273
- def test_query_multi
274
- dbd = get_dbd
275
- res = dbd.prepare("SELECT name, age FROM names WHERE age > 20;")
276
-
277
- expected_list = ['Jim', 'Bob', 'Charlie']
278
- res.execute
279
- while row=res.fetch
280
- expected = expected_list.shift
281
- assert_equal expected, row[0]
282
- end
283
-
284
- res.finish
285
- ensure
286
- dbd.disconnect if dbd
287
- end
288
-
289
- def test_tables_call
290
- # per bug #1082, views do not show up in tables listing.
291
- assert get_dbi.tables.include?("view_names")
292
- end
293
-
294
- def get_dbi
295
- config = DBDConfig.get_config
296
- DBI.connect("dbi:Pg:#{config['postgresql']['dbname']}", config['postgresql']['username'], config['postgresql']['password'])
297
- end
298
-
299
- def get_dbd
300
- config = DBDConfig.get_config['postgresql']
301
- result = DBI::DBD::Pg::Database.new(config['dbname'], config['username'], config['password'], {})
302
- result['AutoCommit'] = true
303
- result
304
- end
305
- end
306
-
307
- # --------------------------------------------------------------------
@@ -1,60 +0,0 @@
1
- create table names (
2
- name varchar(255),
3
- age integer
4
- );
5
- ---
6
- insert into names (name, age) values ('Joe', 19);
7
- ---
8
- insert into names (name, age) values ('Jim', 30);
9
- ---
10
- insert into names (name, age) values ('Bob', 21);
11
- ---
12
- 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));
13
- ---
14
- CREATE TABLE blob_test (name VARCHAR(30), data OID);
15
- ---
16
- create view view_names as select * from names;
17
- ---
18
- create or replace function test_insert (varchar(255), integer)
19
- returns integer
20
- language sql
21
- as 'insert into names (name, age) values ($1, $2); select age from names where name = $1';
22
- ---
23
- create table boolean_test (num integer, mybool boolean);
24
- ---
25
- create table time_test (mytime time);
26
- ---
27
- create table timestamp_test (mytimestamp timestamp);
28
- ---
29
- create table bit_test (mybit bit);
30
- ---
31
- create table field_types_test (foo integer not null primary key default 1);
32
- ---
33
- create type enum_test as ENUM ('one', 'two', 'three');
34
- ---
35
- create table enum_type_test (foo enum_test);
36
- ---
37
- create table db_specific_types_test (foo integer);
38
- ---
39
- create table array_test (foo integer[], bar integer[3], baz integer[3][3], quux varchar[2]);
40
- ---
41
- create table bytea_test (foo bytea);
42
- ---
43
- create schema schema1;
44
- ---
45
- create schema schema2;
46
- ---
47
- create table schema1.tbl (foo integer);
48
- ---
49
- create table schema2.tbl (bar integer);
50
- ---
51
- create or replace function
52
- select_subproperty(value names.age%TYPE, sub names.age%TYPE, out retval names.age%TYPE)
53
- as $$
54
- select
55
- case
56
- when $2 is not null
57
- then $1
58
- else null
59
- end
60
- $$ language sql;
@@ -1,32 +0,0 @@
1
- require 'fileutils'
2
-
3
- DBDConfig.set_testbase(:sqlite, Class.new(Test::Unit::TestCase) do
4
-
5
- def dbtype
6
- "sqlite"
7
- end
8
-
9
- def test_base
10
- if @dbh # FIXME for some reason, @dbh isn't initialized in some cases. investigate.
11
- assert_equal(@dbh.driver_name, "SQLite")
12
- assert_kind_of(DBI::DBD::SQLite::Database, @dbh.instance_variable_get(:@handle))
13
- end
14
- end
15
-
16
- def set_base_dbh
17
- config = DBDConfig.get_config['sqlite']
18
- @dbh = DBI.connect('dbi:SQLite:'+config['dbname'], nil, nil, { })
19
- end
20
-
21
- def setup
22
- set_base_dbh
23
- DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlite/up.sql")
24
- end
25
-
26
- def teardown
27
- @dbh.disconnect if @dbh.connected?
28
- config = DBDConfig.get_config['sqlite']
29
- FileUtils.rm_f(config['dbname'])
30
- end
31
- end
32
- )
@@ -1,30 +0,0 @@
1
- class TestSQLiteDatabase < DBDConfig.testbase(:sqlite)
2
- def test_database_name
3
- assert_nothing_raised do
4
- assert_equal DBDConfig.get_config[dbtype]['dbname'], @dbh.database_name
5
- end
6
- end
7
-
8
- def test_disconnect
9
- assert_nil @dbh.disconnect
10
- assert_nil @dbh.instance_variable_get("@db")
11
- end
12
-
13
- def test_columns
14
- assert_equal [
15
- {
16
- :name => "name",
17
- :default => nil,
18
- :nullable => true,
19
- :precision => 255,
20
- :type_name => "varchar"
21
- },
22
- {
23
- :name => "age",
24
- :default => nil,
25
- :nullable => true,
26
- :type_name => "integer"
27
- }
28
- ], @dbh.columns("names")
29
- end
30
- end
@@ -1,68 +0,0 @@
1
- class TestSQLiteDriver < DBDConfig.testbase(:sqlite)
2
- def test_require
3
- require 'dbd/SQLite'
4
- assert_kind_of Module, DBI
5
- assert_kind_of Module, DBI::DBD
6
- assert_kind_of Class, DBI::DBD::SQLite
7
- assert_kind_of Class, DBI::DBD::SQLite::Driver
8
- assert_kind_of Class, DBI::DBD::SQLite::Database
9
- assert_kind_of Class, DBI::DBD::SQLite::Statement
10
- end
11
-
12
- def test_connect
13
- config = DBDConfig.get_config['sqlite']
14
-
15
- # this tests DBI more than SQLite, but makes sure our chain works with it.
16
- dbh = DBI.connect("dbi:SQLite:" + config['dbname'], nil, nil, {})
17
- assert dbh
18
- assert_kind_of DBI::DatabaseHandle, dbh
19
-
20
- # first argument should be a string
21
- assert_raises(DBI::InterfaceError) do
22
- DBI::DBD::SQLite::Driver.new.connect(nil, nil, nil, { })
23
- end
24
-
25
- # that string should have some frackin' length
26
- assert_raises(DBI::InterfaceError) do
27
- DBI::DBD::SQLite::Driver.new.connect("", nil, nil, { })
28
- end
29
-
30
- # last argument should be a hash
31
- assert_raises(DBI::InterfaceError) do
32
- DBI::DBD::SQLite::Driver.new.connect(config['dbname'], nil, nil, nil)
33
- end
34
-
35
- dbh = nil
36
- driver = nil
37
- assert_nothing_raised do
38
- driver = DBI::DBD::SQLite::Driver.new
39
- dbh = driver.connect(config['dbname'], nil, nil, { })
40
- end
41
-
42
- assert_kind_of DBI::DBD::SQLite::Driver, driver
43
- assert_kind_of DBI::DBD::SQLite::Database, dbh
44
-
45
- assert !dbh.instance_variable_get("@autocommit")
46
-
47
- dbh = nil
48
- driver = nil
49
- assert_nothing_raised do
50
- dbh = DBI::DBD::SQLite::Driver.new.connect(config['dbname'], nil, nil, { "AutoCommit" => true, "sqlite_full_column_names" => true })
51
- end
52
-
53
- assert dbh
54
- assert dbh.instance_variable_get("@attr_hash")
55
- assert_equal 0, dbh.instance_variable_get("@open_handles")
56
- assert_kind_of SQLite::Database, dbh.instance_variable_get("@db")
57
-
58
- assert File.exists?(config['dbname'])
59
- end
60
-
61
- def setup
62
- end
63
-
64
- def teardown
65
- config = DBDConfig.get_config['sqlite']
66
- FileUtils.rm_f(config['dbname'])
67
- end
68
- end
@@ -1,112 +0,0 @@
1
- class TestSQLiteStatement < DBDConfig.testbase(:sqlite)
2
- def test_constructor
3
- sth = DBI::DBD::SQLite::Statement.new("select * from foo", @dbh.instance_variable_get("@handle"))
4
-
5
- assert_kind_of DBI::DBD::SQLite::Statement, sth
6
- assert sth.instance_variable_get("@dbh")
7
- assert_kind_of DBI::DBD::SQLite::Database, sth.instance_variable_get("@dbh")
8
- assert_equal(@dbh.instance_variable_get("@handle"), sth.instance_variable_get("@dbh"))
9
- assert_kind_of DBI::SQL::PreparedStatement, sth.instance_variable_get("@statement")
10
- assert_equal({ }, sth.instance_variable_get("@attr"))
11
- assert_equal([ ], sth.instance_variable_get("@params"))
12
- assert_nil(sth.instance_variable_get("@result_set"))
13
- assert_equal([ ], sth.instance_variable_get("@rows"))
14
-
15
- sth = @dbh.prepare("select * from foo")
16
-
17
- assert_kind_of DBI::StatementHandle, sth
18
- end
19
-
20
- def test_bind_param
21
- sth = DBI::DBD::SQLite::Statement.new("select * from foo", @dbh.instance_variable_get("@handle"))
22
-
23
- assert_raises(DBI::InterfaceError) do
24
- sth.bind_param(:foo, "monkeys")
25
- end
26
-
27
- # XXX this is fairly ugly, but...
28
- # what i've attempted to do here is normalize what is tested, even
29
- # though the data differs subtly. you'll notice that there are two
30
- # arrays that get passed to the each block for evaluation. the first
31
- # argument is the statment handle (raw from SQLite DBD or the facade
32
- # from DBI), the second is how we access the @params internally held
33
- # variable, and the third is how these params are scrubbed before we
34
- # assert against them.
35
- #
36
- # the @params variable is in different spots in both statement handles
37
- # and the values of the params are quoted differently. However, the
38
- # full pipe works and I'd like to ensure that both do their job as a
39
- # team.
40
- #
41
- [
42
- [
43
- sth,
44
- proc { |x| x.instance_variable_get("@params") },
45
- proc { |x| x }
46
- ],
47
- [
48
- @dbh.prepare("select * from foo"),
49
- proc { |x| x.instance_variable_get("@handle").instance_variable_get("@params") },
50
- proc { |x| x.gsub(/(^')|('$)/, '') }
51
- ]
52
- ].each do |sthpack|
53
- sthpack[0].bind_param(1, "monkeys", nil)
54
-
55
- params = sthpack[1].call(sthpack[0])
56
-
57
- assert_equal "monkeys", sthpack[2].call(params[0])
58
-
59
- # set a bunch of stuff.
60
- %w(I like monkeys).each_with_index { |x, i| sthpack[0].bind_param(i+1, x) }
61
-
62
- params = sthpack[1].call(sthpack[0])
63
-
64
- assert_equal %w(I like monkeys), params.collect { |x| sthpack[2].call(x) }
65
-
66
- # FIXME what to do with attributes? are they important in SQLite?
67
- end
68
- end
69
-
70
- def test_column_info
71
- sth = nil
72
-
73
- assert_nothing_raised do
74
- sth = @dbh.prepare("select * from names")
75
- sth.execute
76
- end
77
-
78
- assert_kind_of Array, sth.column_info
79
- assert_kind_of DBI::ColumnInfo, sth.column_info[0]
80
- assert_kind_of DBI::ColumnInfo, sth.column_info[1]
81
- assert_equal [
82
- {
83
- :name => "name",
84
- :sql_type => 12,
85
- :precision => 255,
86
- :type_name => "varchar"
87
- },
88
- {
89
- :name => "age",
90
- :sql_type => 4,
91
- :type_name => "integer"
92
- }
93
- ], sth.column_info
94
-
95
- sth.finish
96
- end
97
-
98
- def test_specific_types
99
- assert_nothing_raised do
100
- @sth = @dbh.prepare("insert into db_specific_types_test (dbl) values (?)")
101
- @sth.execute(11111111.111111)
102
- @sth.finish
103
- end
104
-
105
- assert_nothing_raised do
106
- @sth = @dbh.prepare("select * from db_specific_types_test")
107
- @sth.execute
108
- assert_equal([11111111.111111], @sth.fetch)
109
- @sth.finish
110
- end
111
- end
112
- end
@@ -1,25 +0,0 @@
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);
@@ -1,32 +0,0 @@
1
- require 'fileutils'
2
-
3
- DBDConfig.set_testbase(:sqlite3, Class.new(Test::Unit::TestCase) do
4
- def dbtype
5
- "sqlite3"
6
- end
7
-
8
- def test_base
9
- if @dbh # FIXME for some reason, @dbh isn't initialized in some cases. investigate.
10
- assert_equal(@dbh.driver_name, "SQLite3")
11
- assert_kind_of(DBI::DBD::SQLite3::Database, @dbh.instance_variable_get(:@handle))
12
- end
13
- end
14
-
15
- def set_base_dbh
16
- config = DBDConfig.get_config['sqlite3']
17
- @dbh = DBI.connect('dbi:SQLite3:'+config['dbname'], nil, nil, { })
18
- end
19
-
20
- def setup
21
- set_base_dbh
22
- DBDConfig.inject_sql(@dbh, dbtype, "dbd/sqlite3/up.sql")
23
- end
24
-
25
- def teardown
26
- @sth.finish if(@sth && !@sth.finished?)
27
- @dbh.disconnect if @dbh.connected?
28
- config = DBDConfig.get_config['sqlite3']
29
- FileUtils.rm_f(config['dbname'])
30
- end
31
- end
32
- )