ydbi 0.5.7 → 0.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/lib/dbi/version.rb +1 -1
- data/readme.md +4 -3
- data/test/dbi/tc_dbi.rb +1 -1
- metadata +7 -125
- data/.github/workflows/ruby.yml +0 -35
- data/.gitignore +0 -8
- data/.travis.yml +0 -15
- data/Gemfile +0 -5
- data/Rakefile +0 -10
- data/TODO +0 -44
- data/bench/bench.rb +0 -79
- data/build/rake_task_lib.rb +0 -186
- data/doc/DBD_SPEC.rdoc +0 -88
- data/doc/DBI_SPEC.rdoc +0 -157
- data/doc/homepage/contact.html +0 -62
- data/doc/homepage/development.html +0 -124
- data/doc/homepage/index.html +0 -83
- data/doc/homepage/ruby-dbi.css +0 -91
- data/lib/dbd/Mysql.rb +0 -137
- data/lib/dbd/ODBC.rb +0 -89
- data/lib/dbd/Pg.rb +0 -188
- data/lib/dbd/SQLite.rb +0 -97
- data/lib/dbd/SQLite3.rb +0 -124
- data/lib/dbd/mysql/database.rb +0 -405
- data/lib/dbd/mysql/driver.rb +0 -125
- data/lib/dbd/mysql/statement.rb +0 -188
- data/lib/dbd/odbc/database.rb +0 -128
- data/lib/dbd/odbc/driver.rb +0 -38
- data/lib/dbd/odbc/statement.rb +0 -137
- data/lib/dbd/pg/database.rb +0 -504
- data/lib/dbd/pg/exec.rb +0 -47
- data/lib/dbd/pg/statement.rb +0 -160
- data/lib/dbd/pg/tuples.rb +0 -121
- data/lib/dbd/pg/type.rb +0 -209
- data/lib/dbd/sqlite/database.rb +0 -151
- data/lib/dbd/sqlite/statement.rb +0 -125
- data/lib/dbd/sqlite3/database.rb +0 -201
- data/lib/dbd/sqlite3/statement.rb +0 -78
- data/prototypes/types2.rb +0 -237
- data/setup.rb +0 -1585
- data/test/DBD_TESTS +0 -50
- data/test/TESTING +0 -16
- data/test/dbd/general/test_database.rb +0 -206
- data/test/dbd/general/test_statement.rb +0 -326
- data/test/dbd/general/test_types.rb +0 -296
- data/test/dbd/mysql/base.rb +0 -26
- data/test/dbd/mysql/down.sql +0 -19
- data/test/dbd/mysql/test_blob.rb +0 -18
- data/test/dbd/mysql/test_new_methods.rb +0 -7
- data/test/dbd/mysql/test_patches.rb +0 -111
- data/test/dbd/mysql/up.sql +0 -28
- data/test/dbd/odbc/base.rb +0 -30
- data/test/dbd/odbc/down.sql +0 -19
- data/test/dbd/odbc/test_new_methods.rb +0 -12
- data/test/dbd/odbc/test_ping.rb +0 -10
- data/test/dbd/odbc/test_statement.rb +0 -44
- data/test/dbd/odbc/test_transactions.rb +0 -58
- data/test/dbd/odbc/up.sql +0 -33
- data/test/dbd/postgresql/base.rb +0 -31
- data/test/dbd/postgresql/down.sql +0 -31
- data/test/dbd/postgresql/test_arrays.rb +0 -179
- data/test/dbd/postgresql/test_async.rb +0 -121
- data/test/dbd/postgresql/test_blob.rb +0 -36
- data/test/dbd/postgresql/test_bytea.rb +0 -87
- data/test/dbd/postgresql/test_ping.rb +0 -10
- data/test/dbd/postgresql/test_timestamp.rb +0 -77
- data/test/dbd/postgresql/test_transactions.rb +0 -58
- data/test/dbd/postgresql/testdbipg.rb +0 -307
- data/test/dbd/postgresql/up.sql +0 -60
- data/test/dbd/sqlite/base.rb +0 -32
- data/test/dbd/sqlite/test_database.rb +0 -30
- data/test/dbd/sqlite/test_driver.rb +0 -68
- data/test/dbd/sqlite/test_statement.rb +0 -112
- data/test/dbd/sqlite/up.sql +0 -25
- data/test/dbd/sqlite3/base.rb +0 -32
- data/test/dbd/sqlite3/test_database.rb +0 -77
- data/test/dbd/sqlite3/test_driver.rb +0 -67
- data/test/dbd/sqlite3/test_statement.rb +0 -88
- data/test/dbd/sqlite3/up.sql +0 -33
- data/test/ts_dbd.rb +0 -131
- data/ydbi.gemspec +0 -23
@@ -1,67 +0,0 @@
|
|
1
|
-
class TestDriver < DBDConfig.testbase(:sqlite3)
|
2
|
-
def test_require
|
3
|
-
require 'dbd/SQLite3'
|
4
|
-
assert_kind_of Module, DBI
|
5
|
-
assert_kind_of Module, DBI::DBD
|
6
|
-
assert_kind_of Module, DBI::DBD::SQLite3
|
7
|
-
assert_kind_of Class, DBI::DBD::SQLite3::Driver
|
8
|
-
assert_kind_of Class, DBI::DBD::SQLite3::Database
|
9
|
-
assert_kind_of Class, DBI::DBD::SQLite3::Statement
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_connect
|
13
|
-
config = DBDConfig.get_config['sqlite3']
|
14
|
-
|
15
|
-
# this tests DBI more than SQLite, but makes sure our chain works with it.
|
16
|
-
dbh = DBI.connect("dbi:SQLite3:" + 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::SQLite3::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::SQLite3::Driver.new.connect("", nil, nil, { })
|
28
|
-
end
|
29
|
-
|
30
|
-
# last argument should be a hash
|
31
|
-
assert_raises(DBI::InterfaceError) do
|
32
|
-
DBI::DBD::SQLite3::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::SQLite3::Driver.new
|
39
|
-
dbh = driver.connect(config['dbname'], nil, nil, { })
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_kind_of DBI::DBD::SQLite3::Driver, driver
|
43
|
-
assert_kind_of DBI::DBD::SQLite3::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::SQLite3::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")
|
55
|
-
assert_kind_of SQLite3::Database, dbh.instance_variable_get("@db")
|
56
|
-
|
57
|
-
assert File.exists?(config['dbname'])
|
58
|
-
end
|
59
|
-
|
60
|
-
def setup
|
61
|
-
end
|
62
|
-
|
63
|
-
def teardown
|
64
|
-
config = DBDConfig.get_config['sqlite3']
|
65
|
-
FileUtils.rm_f(config['dbname'])
|
66
|
-
end
|
67
|
-
end
|
@@ -1,88 +0,0 @@
|
|
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
|
data/test/dbd/sqlite3/up.sql
DELETED
@@ -1,33 +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);
|
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
DELETED
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem 'test-unit'
|
3
|
-
# figure out what tests to run
|
4
|
-
require 'yaml'
|
5
|
-
require 'test/unit/testsuite'
|
6
|
-
require 'test/unit/ui/console/testrunner'
|
7
|
-
|
8
|
-
if File.basename(Dir.pwd) == "test"
|
9
|
-
$:.unshift('../lib')
|
10
|
-
else
|
11
|
-
$:.unshift('lib')
|
12
|
-
end
|
13
|
-
|
14
|
-
module Test::Unit::Assertions
|
15
|
-
def build_message(head, template=nil, *arguments)
|
16
|
-
template += "\n" + "DATABASE: " + dbtype
|
17
|
-
template &&= template.chomp
|
18
|
-
return AssertionMessage.new(head, template, arguments)
|
19
|
-
end
|
20
|
-
end
|
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
|
-
|
32
|
-
module DBDConfig
|
33
|
-
@testbase = { }
|
34
|
-
@current_dbtype = nil
|
35
|
-
|
36
|
-
def self.get_config
|
37
|
-
config = nil
|
38
|
-
|
39
|
-
begin
|
40
|
-
config = YAML.load_file(File.join(ENV["HOME"], ".ruby-dbi.test-config.yaml"))
|
41
|
-
rescue Exception => e
|
42
|
-
config = { }
|
43
|
-
config["dbtypes"] = [ ]
|
44
|
-
end
|
45
|
-
|
46
|
-
return config
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.inject_sql(dbh, dbtype, file)
|
50
|
-
# splits by --- in the file, strips newlines and the semicolons.
|
51
|
-
# this way we can still manually import the file, but use it with our
|
52
|
-
# drivers for client-independent injection.
|
53
|
-
File.open(file).read.split(/\n*---\n*/, -1).collect { |x| x.gsub!(/\n/, ''); x.sub(/;\z/, '') }.each do |stmt|
|
54
|
-
tmp = STDERR.dup
|
55
|
-
STDERR.reopen('sql.log', 'a')
|
56
|
-
begin
|
57
|
-
dbh.commit rescue nil
|
58
|
-
dbh["AutoCommit"] = true rescue nil
|
59
|
-
dbh.do(stmt)
|
60
|
-
dbh.commit unless dbtype == 'sqlite3'
|
61
|
-
rescue Exception => e
|
62
|
-
tmp.puts "Error injecting '#{stmt}' for db #{dbtype}"
|
63
|
-
tmp.puts "Error: #{e.message}"
|
64
|
-
end
|
65
|
-
STDERR.reopen(tmp)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.current_dbtype
|
70
|
-
@current_dbtype
|
71
|
-
end
|
72
|
-
|
73
|
-
def self.current_dbtype=(setting)
|
74
|
-
@current_dbtype = setting
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.testbase(klass_name)
|
78
|
-
return @testbase[klass_name]
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.set_testbase(klass_name, klass)
|
82
|
-
@testbase[klass_name] = klass
|
83
|
-
klass.name = klass_name.to_s
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.suite
|
87
|
-
@suite ||= []
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
if __FILE__ == $0
|
92
|
-
Dir.chdir("..") if File.basename(Dir.pwd) == "test"
|
93
|
-
$LOAD_PATH.unshift(File.join(Dir.pwd, "lib"))
|
94
|
-
Dir.chdir("test") rescue nil
|
95
|
-
|
96
|
-
begin
|
97
|
-
require 'dbi'
|
98
|
-
rescue LoadError => e
|
99
|
-
begin
|
100
|
-
require 'rubygems'
|
101
|
-
gem 'dbi'
|
102
|
-
require 'dbi'
|
103
|
-
rescue LoadError => e
|
104
|
-
abort "DBI must already be installed or must come with this package for tests to work."
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
Deprecate.set_action(proc { })
|
109
|
-
|
110
|
-
config = DBDConfig.get_config
|
111
|
-
|
112
|
-
config["dbtypes"] = ENV["DBTYPES"].split(/\s+/) if ENV["DBTYPES"]
|
113
|
-
|
114
|
-
if config and config["dbtypes"]
|
115
|
-
config["dbtypes"].each do |dbtype|
|
116
|
-
unless config[dbtype]
|
117
|
-
warn "#{dbtype} is selected for testing but not configured; see test/DBD_TESTS"
|
118
|
-
next
|
119
|
-
end
|
120
|
-
|
121
|
-
# base.rb is special, see DBD_TESTS
|
122
|
-
require "dbd/#{dbtype}/base.rb"
|
123
|
-
Dir["dbd/#{dbtype}/test*.rb"].each { |file| require file }
|
124
|
-
# run the general tests
|
125
|
-
DBDConfig.current_dbtype = dbtype.to_sym
|
126
|
-
Dir["dbd/general/test*.rb"].each { |file| load file; @class.name = file; DBDConfig.suite << @class }
|
127
|
-
end
|
128
|
-
elsif !config["dbtypes"]
|
129
|
-
warn "Please see test/DBD_TESTS for information on configuring DBD tests."
|
130
|
-
end
|
131
|
-
end
|
data/ydbi.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'dbi/version'
|
5
|
-
Gem::Specification.new do |gem|
|
6
|
-
gem.name = 'ydbi'
|
7
|
-
gem.version = DBI::VERSION
|
8
|
-
gem.authors = ['Erik Hollensbe', 'Christopher Maujean', 'Niklaus Giger', 'Zeno Davatz']
|
9
|
-
gem.email = 'zdavatz@ywesee.com'
|
10
|
-
gem.homepage = 'https://github.com/zdavatz/ydbi'
|
11
|
-
gem.summary = 'A vendor independent interface for accessing databases, similar to Perl\'s DBI'
|
12
|
-
gem.description = 'Branch by ywesee com, as our patches were never accepted by upstream'
|
13
|
-
gem.licenses = ['MIT']
|
14
|
-
gem.files = `git ls-files`.split($/)
|
15
|
-
gem.test_file = 'test/ts_dbi.rb'
|
16
|
-
gem.executables = ['dbi', 'test_broken_dbi']
|
17
|
-
gem.require_paths = ['lib']
|
18
|
-
|
19
|
-
gem.add_dependency "pg", '>= 1.0.0'
|
20
|
-
gem.add_development_dependency "rake"
|
21
|
-
gem.add_development_dependency "test-unit"
|
22
|
-
gem.add_runtime_dependency 'deprecated', '= 2.0.1'
|
23
|
-
end
|