ydbi 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +4 -0
  3. data/lib/dbi/version.rb +1 -1
  4. data/readme.md +4 -3
  5. data/test/dbi/tc_dbi.rb +1 -1
  6. metadata +7 -125
  7. data/.github/workflows/ruby.yml +0 -35
  8. data/.gitignore +0 -8
  9. data/.travis.yml +0 -15
  10. data/Gemfile +0 -5
  11. data/Rakefile +0 -10
  12. data/TODO +0 -44
  13. data/bench/bench.rb +0 -79
  14. data/build/rake_task_lib.rb +0 -186
  15. data/doc/DBD_SPEC.rdoc +0 -88
  16. data/doc/DBI_SPEC.rdoc +0 -157
  17. data/doc/homepage/contact.html +0 -62
  18. data/doc/homepage/development.html +0 -124
  19. data/doc/homepage/index.html +0 -83
  20. data/doc/homepage/ruby-dbi.css +0 -91
  21. data/lib/dbd/Mysql.rb +0 -137
  22. data/lib/dbd/ODBC.rb +0 -89
  23. data/lib/dbd/Pg.rb +0 -188
  24. data/lib/dbd/SQLite.rb +0 -97
  25. data/lib/dbd/SQLite3.rb +0 -124
  26. data/lib/dbd/mysql/database.rb +0 -405
  27. data/lib/dbd/mysql/driver.rb +0 -125
  28. data/lib/dbd/mysql/statement.rb +0 -188
  29. data/lib/dbd/odbc/database.rb +0 -128
  30. data/lib/dbd/odbc/driver.rb +0 -38
  31. data/lib/dbd/odbc/statement.rb +0 -137
  32. data/lib/dbd/pg/database.rb +0 -504
  33. data/lib/dbd/pg/exec.rb +0 -47
  34. data/lib/dbd/pg/statement.rb +0 -160
  35. data/lib/dbd/pg/tuples.rb +0 -121
  36. data/lib/dbd/pg/type.rb +0 -209
  37. data/lib/dbd/sqlite/database.rb +0 -151
  38. data/lib/dbd/sqlite/statement.rb +0 -125
  39. data/lib/dbd/sqlite3/database.rb +0 -201
  40. data/lib/dbd/sqlite3/statement.rb +0 -78
  41. data/prototypes/types2.rb +0 -237
  42. data/setup.rb +0 -1585
  43. data/test/DBD_TESTS +0 -50
  44. data/test/TESTING +0 -16
  45. data/test/dbd/general/test_database.rb +0 -206
  46. data/test/dbd/general/test_statement.rb +0 -326
  47. data/test/dbd/general/test_types.rb +0 -296
  48. data/test/dbd/mysql/base.rb +0 -26
  49. data/test/dbd/mysql/down.sql +0 -19
  50. data/test/dbd/mysql/test_blob.rb +0 -18
  51. data/test/dbd/mysql/test_new_methods.rb +0 -7
  52. data/test/dbd/mysql/test_patches.rb +0 -111
  53. data/test/dbd/mysql/up.sql +0 -28
  54. data/test/dbd/odbc/base.rb +0 -30
  55. data/test/dbd/odbc/down.sql +0 -19
  56. data/test/dbd/odbc/test_new_methods.rb +0 -12
  57. data/test/dbd/odbc/test_ping.rb +0 -10
  58. data/test/dbd/odbc/test_statement.rb +0 -44
  59. data/test/dbd/odbc/test_transactions.rb +0 -58
  60. data/test/dbd/odbc/up.sql +0 -33
  61. data/test/dbd/postgresql/base.rb +0 -31
  62. data/test/dbd/postgresql/down.sql +0 -31
  63. data/test/dbd/postgresql/test_arrays.rb +0 -179
  64. data/test/dbd/postgresql/test_async.rb +0 -121
  65. data/test/dbd/postgresql/test_blob.rb +0 -36
  66. data/test/dbd/postgresql/test_bytea.rb +0 -87
  67. data/test/dbd/postgresql/test_ping.rb +0 -10
  68. data/test/dbd/postgresql/test_timestamp.rb +0 -77
  69. data/test/dbd/postgresql/test_transactions.rb +0 -58
  70. data/test/dbd/postgresql/testdbipg.rb +0 -307
  71. data/test/dbd/postgresql/up.sql +0 -60
  72. data/test/dbd/sqlite/base.rb +0 -32
  73. data/test/dbd/sqlite/test_database.rb +0 -30
  74. data/test/dbd/sqlite/test_driver.rb +0 -68
  75. data/test/dbd/sqlite/test_statement.rb +0 -112
  76. data/test/dbd/sqlite/up.sql +0 -25
  77. data/test/dbd/sqlite3/base.rb +0 -32
  78. data/test/dbd/sqlite3/test_database.rb +0 -77
  79. data/test/dbd/sqlite3/test_driver.rb +0 -67
  80. data/test/dbd/sqlite3/test_statement.rb +0 -88
  81. data/test/dbd/sqlite3/up.sql +0 -33
  82. data/test/ts_dbd.rb +0 -131
  83. data/ydbi.gemspec +0 -23
@@ -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
- )
@@ -1,77 +0,0 @@
1
- class TestDatabase < DBDConfig.testbase(:sqlite3)
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
- :sql_type => 100,
20
- :precision => 255,
21
- :type_name => "varchar"
22
- },
23
- {
24
- :name => "age",
25
- :default => nil,
26
- :nullable => true,
27
- :sql_type => 4,
28
- :type_name => "integer"
29
- }
30
- ], @dbh.columns("names")
31
-
32
- assert_equal [
33
- {
34
- :name => "name",
35
- :default => nil,
36
- :nullable => true,
37
- :sql_type => 100,
38
- :precision => 255,
39
- :type_name => "varchar"
40
- },
41
- {
42
- :name => "age",
43
- :default => nil,
44
- :nullable => true,
45
- :sql_type => 4,
46
- :type_name => "integer"
47
- }
48
- ], @dbh.columns("names_defined_with_spaces")
49
- end
50
-
51
- def test_parse_type
52
- # Some tests to ensure various whitespace and case styles don't confuse parse_type.
53
-
54
- match = DBI::DBD::SQLite3.parse_type( 'VARCHAR' )
55
- assert_equal 'VARCHAR', match[ 1 ]
56
-
57
- match = DBI::DBD::SQLite3.parse_type( 'VARCHAR(4096)' )
58
- assert_equal 'VARCHAR', match[ 1 ]
59
- assert_equal '4096', match[ 3 ]
60
-
61
- match = DBI::DBD::SQLite3.parse_type( 'varchar(4096)' )
62
- assert_equal 'varchar', match[ 1 ]
63
- assert_equal '4096', match[ 3 ]
64
-
65
- match = DBI::DBD::SQLite3.parse_type( 'VARCHAR( 4096 )' )
66
- assert_equal 'VARCHAR', match[ 1 ]
67
- assert_equal '4096', match[ 3 ]
68
-
69
- match = DBI::DBD::SQLite3.parse_type( 'VARCHAR ( 4096 )' )
70
- assert_equal 'VARCHAR', match[ 1 ]
71
- assert_equal '4096', match[ 3 ]
72
-
73
- match = DBI::DBD::SQLite3.parse_type( 'VARCHAR (4096)' )
74
- assert_equal 'VARCHAR', match[ 1 ]
75
- assert_equal '4096', match[ 3 ]
76
- end
77
- end