ydbi 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/ChangeLog +3699 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/Rakefile +8 -0
  7. data/TODO +44 -0
  8. data/bench/bench.rb +79 -0
  9. data/bin/dbi +518 -0
  10. data/bin/test_broken_dbi +37 -0
  11. data/build/Rakefile.dbi.rb +60 -0
  12. data/build/rake_task_lib.rb +187 -0
  13. data/doc/DBD_SPEC.rdoc +88 -0
  14. data/doc/DBI_SPEC.rdoc +157 -0
  15. data/doc/homepage/contact.html +62 -0
  16. data/doc/homepage/development.html +124 -0
  17. data/doc/homepage/index.html +83 -0
  18. data/doc/homepage/ruby-dbi.css +91 -0
  19. data/examples/test1.pl +39 -0
  20. data/examples/test1.rb +20 -0
  21. data/examples/xmltest.rb +8 -0
  22. data/lib/dbd/Mysql.rb +137 -0
  23. data/lib/dbd/ODBC.rb +89 -0
  24. data/lib/dbd/Pg.rb +188 -0
  25. data/lib/dbd/SQLite.rb +97 -0
  26. data/lib/dbd/SQLite3.rb +124 -0
  27. data/lib/dbd/mysql/database.rb +405 -0
  28. data/lib/dbd/mysql/driver.rb +125 -0
  29. data/lib/dbd/mysql/statement.rb +188 -0
  30. data/lib/dbd/odbc/database.rb +128 -0
  31. data/lib/dbd/odbc/driver.rb +38 -0
  32. data/lib/dbd/odbc/statement.rb +137 -0
  33. data/lib/dbd/pg/database.rb +516 -0
  34. data/lib/dbd/pg/exec.rb +47 -0
  35. data/lib/dbd/pg/statement.rb +160 -0
  36. data/lib/dbd/pg/tuples.rb +121 -0
  37. data/lib/dbd/pg/type.rb +209 -0
  38. data/lib/dbd/sqlite/database.rb +151 -0
  39. data/lib/dbd/sqlite/statement.rb +125 -0
  40. data/lib/dbd/sqlite3/database.rb +201 -0
  41. data/lib/dbd/sqlite3/statement.rb +78 -0
  42. data/lib/dbi.rb +336 -0
  43. data/lib/dbi/base_classes.rb +12 -0
  44. data/lib/dbi/base_classes/database.rb +135 -0
  45. data/lib/dbi/base_classes/driver.rb +47 -0
  46. data/lib/dbi/base_classes/statement.rb +171 -0
  47. data/lib/dbi/binary.rb +25 -0
  48. data/lib/dbi/columninfo.rb +107 -0
  49. data/lib/dbi/exceptions.rb +65 -0
  50. data/lib/dbi/handles.rb +49 -0
  51. data/lib/dbi/handles/database.rb +241 -0
  52. data/lib/dbi/handles/driver.rb +60 -0
  53. data/lib/dbi/handles/statement.rb +408 -0
  54. data/lib/dbi/row.rb +269 -0
  55. data/lib/dbi/sql.rb +22 -0
  56. data/lib/dbi/sql/preparedstatement.rb +115 -0
  57. data/lib/dbi/sql_type_constants.rb +75 -0
  58. data/lib/dbi/trace.rb +91 -0
  59. data/lib/dbi/types.rb +218 -0
  60. data/lib/dbi/typeutil.rb +109 -0
  61. data/lib/dbi/utils.rb +60 -0
  62. data/lib/dbi/utils/date.rb +59 -0
  63. data/lib/dbi/utils/tableformatter.rb +112 -0
  64. data/lib/dbi/utils/time.rb +52 -0
  65. data/lib/dbi/utils/timestamp.rb +96 -0
  66. data/lib/dbi/utils/xmlformatter.rb +73 -0
  67. data/lib/dbi/version.rb +3 -0
  68. data/prototypes/types2.rb +237 -0
  69. data/readme.md +274 -0
  70. data/setup.rb +1585 -0
  71. data/test/DBD_TESTS +50 -0
  72. data/test/TESTING +16 -0
  73. data/test/dbd/general/test_database.rb +206 -0
  74. data/test/dbd/general/test_statement.rb +326 -0
  75. data/test/dbd/general/test_types.rb +296 -0
  76. data/test/dbd/mysql/base.rb +26 -0
  77. data/test/dbd/mysql/down.sql +19 -0
  78. data/test/dbd/mysql/test_blob.rb +18 -0
  79. data/test/dbd/mysql/test_new_methods.rb +7 -0
  80. data/test/dbd/mysql/test_patches.rb +111 -0
  81. data/test/dbd/mysql/up.sql +28 -0
  82. data/test/dbd/odbc/base.rb +30 -0
  83. data/test/dbd/odbc/down.sql +19 -0
  84. data/test/dbd/odbc/test_new_methods.rb +12 -0
  85. data/test/dbd/odbc/test_ping.rb +10 -0
  86. data/test/dbd/odbc/test_statement.rb +44 -0
  87. data/test/dbd/odbc/test_transactions.rb +58 -0
  88. data/test/dbd/odbc/up.sql +33 -0
  89. data/test/dbd/postgresql/base.rb +31 -0
  90. data/test/dbd/postgresql/down.sql +31 -0
  91. data/test/dbd/postgresql/test_arrays.rb +179 -0
  92. data/test/dbd/postgresql/test_async.rb +121 -0
  93. data/test/dbd/postgresql/test_blob.rb +36 -0
  94. data/test/dbd/postgresql/test_bytea.rb +87 -0
  95. data/test/dbd/postgresql/test_ping.rb +10 -0
  96. data/test/dbd/postgresql/test_timestamp.rb +77 -0
  97. data/test/dbd/postgresql/test_transactions.rb +58 -0
  98. data/test/dbd/postgresql/testdbipg.rb +307 -0
  99. data/test/dbd/postgresql/up.sql +60 -0
  100. data/test/dbd/sqlite/base.rb +32 -0
  101. data/test/dbd/sqlite/test_database.rb +30 -0
  102. data/test/dbd/sqlite/test_driver.rb +68 -0
  103. data/test/dbd/sqlite/test_statement.rb +112 -0
  104. data/test/dbd/sqlite/up.sql +25 -0
  105. data/test/dbd/sqlite3/base.rb +32 -0
  106. data/test/dbd/sqlite3/test_database.rb +77 -0
  107. data/test/dbd/sqlite3/test_driver.rb +67 -0
  108. data/test/dbd/sqlite3/test_statement.rb +88 -0
  109. data/test/dbd/sqlite3/up.sql +33 -0
  110. data/test/dbi/tc_columninfo.rb +94 -0
  111. data/test/dbi/tc_date.rb +88 -0
  112. data/test/dbi/tc_dbi.rb +184 -0
  113. data/test/dbi/tc_row.rb +256 -0
  114. data/test/dbi/tc_sqlbind.rb +168 -0
  115. data/test/dbi/tc_statementhandle.rb +29 -0
  116. data/test/dbi/tc_time.rb +77 -0
  117. data/test/dbi/tc_timestamp.rb +142 -0
  118. data/test/dbi/tc_types.rb +268 -0
  119. data/test/ts_dbd.rb +131 -0
  120. data/test/ts_dbi.rb +16 -0
  121. data/ydbi.gemspec +24 -0
  122. metadata +224 -0
@@ -0,0 +1,131 @@
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
@@ -0,0 +1,16 @@
1
+ # Test suite for the DBI tests. No DBD tests are run as part of this
2
+ # test suite.
3
+ Dir.chdir("..") if File.basename(Dir.pwd) == "test"
4
+ $LOAD_PATH.unshift(Dir.pwd + "/lib")
5
+ Dir.chdir("test") rescue nil
6
+ $: << '.'
7
+
8
+ require 'dbi/tc_columninfo'
9
+ require 'dbi/tc_date'
10
+ require 'dbi/tc_dbi'
11
+ require 'dbi/tc_row'
12
+ require 'dbi/tc_sqlbind'
13
+ require 'dbi/tc_statementhandle'
14
+ require 'dbi/tc_time'
15
+ require 'dbi/tc_timestamp'
16
+ require 'dbi/tc_types'
@@ -0,0 +1,24 @@
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']
9
+ gem.email = 'ruby-dbi-users@rubyforge.org'
10
+ gem.homepage = 'http://www.rubyforge.org/projects/ruby-dbi'
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.has_rdoc = true
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.test_file = 'test/ts_dbi.rb'
17
+ gem.executables = ['dbi', 'test_broken_dbi']
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency "rake"
21
+ gem.add_development_dependency "minitest"
22
+ gem.add_development_dependency "test-unit"
23
+ gem.add_runtime_dependency 'deprecated', '= 2.0.1'
24
+ end
metadata ADDED
@@ -0,0 +1,224 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ydbi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Erik Hollensbe
8
+ - Christopher Maujean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-05-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: minitest
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: test-unit
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: deprecated
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 2.0.1
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.1
70
+ description: Branch by ywesee com, as our patches were never accepted by upstream
71
+ email: ruby-dbi-users@rubyforge.org
72
+ executables:
73
+ - dbi
74
+ - test_broken_dbi
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ChangeLog
80
+ - Gemfile
81
+ - LICENSE
82
+ - Rakefile
83
+ - TODO
84
+ - bench/bench.rb
85
+ - bin/dbi
86
+ - bin/test_broken_dbi
87
+ - build/Rakefile.dbi.rb
88
+ - build/rake_task_lib.rb
89
+ - doc/DBD_SPEC.rdoc
90
+ - doc/DBI_SPEC.rdoc
91
+ - doc/homepage/contact.html
92
+ - doc/homepage/development.html
93
+ - doc/homepage/index.html
94
+ - doc/homepage/ruby-dbi.css
95
+ - examples/test1.pl
96
+ - examples/test1.rb
97
+ - examples/xmltest.rb
98
+ - lib/dbd/Mysql.rb
99
+ - lib/dbd/ODBC.rb
100
+ - lib/dbd/Pg.rb
101
+ - lib/dbd/SQLite.rb
102
+ - lib/dbd/SQLite3.rb
103
+ - lib/dbd/mysql/database.rb
104
+ - lib/dbd/mysql/driver.rb
105
+ - lib/dbd/mysql/statement.rb
106
+ - lib/dbd/odbc/database.rb
107
+ - lib/dbd/odbc/driver.rb
108
+ - lib/dbd/odbc/statement.rb
109
+ - lib/dbd/pg/database.rb
110
+ - lib/dbd/pg/exec.rb
111
+ - lib/dbd/pg/statement.rb
112
+ - lib/dbd/pg/tuples.rb
113
+ - lib/dbd/pg/type.rb
114
+ - lib/dbd/sqlite/database.rb
115
+ - lib/dbd/sqlite/statement.rb
116
+ - lib/dbd/sqlite3/database.rb
117
+ - lib/dbd/sqlite3/statement.rb
118
+ - lib/dbi.rb
119
+ - lib/dbi/base_classes.rb
120
+ - lib/dbi/base_classes/database.rb
121
+ - lib/dbi/base_classes/driver.rb
122
+ - lib/dbi/base_classes/statement.rb
123
+ - lib/dbi/binary.rb
124
+ - lib/dbi/columninfo.rb
125
+ - lib/dbi/exceptions.rb
126
+ - lib/dbi/handles.rb
127
+ - lib/dbi/handles/database.rb
128
+ - lib/dbi/handles/driver.rb
129
+ - lib/dbi/handles/statement.rb
130
+ - lib/dbi/row.rb
131
+ - lib/dbi/sql.rb
132
+ - lib/dbi/sql/preparedstatement.rb
133
+ - lib/dbi/sql_type_constants.rb
134
+ - lib/dbi/trace.rb
135
+ - lib/dbi/types.rb
136
+ - lib/dbi/typeutil.rb
137
+ - lib/dbi/utils.rb
138
+ - lib/dbi/utils/date.rb
139
+ - lib/dbi/utils/tableformatter.rb
140
+ - lib/dbi/utils/time.rb
141
+ - lib/dbi/utils/timestamp.rb
142
+ - lib/dbi/utils/xmlformatter.rb
143
+ - lib/dbi/version.rb
144
+ - prototypes/types2.rb
145
+ - readme.md
146
+ - setup.rb
147
+ - test/DBD_TESTS
148
+ - test/TESTING
149
+ - test/dbd/general/test_database.rb
150
+ - test/dbd/general/test_statement.rb
151
+ - test/dbd/general/test_types.rb
152
+ - test/dbd/mysql/base.rb
153
+ - test/dbd/mysql/down.sql
154
+ - test/dbd/mysql/test_blob.rb
155
+ - test/dbd/mysql/test_new_methods.rb
156
+ - test/dbd/mysql/test_patches.rb
157
+ - test/dbd/mysql/up.sql
158
+ - test/dbd/odbc/base.rb
159
+ - test/dbd/odbc/down.sql
160
+ - test/dbd/odbc/test_new_methods.rb
161
+ - test/dbd/odbc/test_ping.rb
162
+ - test/dbd/odbc/test_statement.rb
163
+ - test/dbd/odbc/test_transactions.rb
164
+ - test/dbd/odbc/up.sql
165
+ - test/dbd/postgresql/base.rb
166
+ - test/dbd/postgresql/down.sql
167
+ - test/dbd/postgresql/test_arrays.rb
168
+ - test/dbd/postgresql/test_async.rb
169
+ - test/dbd/postgresql/test_blob.rb
170
+ - test/dbd/postgresql/test_bytea.rb
171
+ - test/dbd/postgresql/test_ping.rb
172
+ - test/dbd/postgresql/test_timestamp.rb
173
+ - test/dbd/postgresql/test_transactions.rb
174
+ - test/dbd/postgresql/testdbipg.rb
175
+ - test/dbd/postgresql/up.sql
176
+ - test/dbd/sqlite/base.rb
177
+ - test/dbd/sqlite/test_database.rb
178
+ - test/dbd/sqlite/test_driver.rb
179
+ - test/dbd/sqlite/test_statement.rb
180
+ - test/dbd/sqlite/up.sql
181
+ - test/dbd/sqlite3/base.rb
182
+ - test/dbd/sqlite3/test_database.rb
183
+ - test/dbd/sqlite3/test_driver.rb
184
+ - test/dbd/sqlite3/test_statement.rb
185
+ - test/dbd/sqlite3/up.sql
186
+ - test/dbi/tc_columninfo.rb
187
+ - test/dbi/tc_date.rb
188
+ - test/dbi/tc_dbi.rb
189
+ - test/dbi/tc_row.rb
190
+ - test/dbi/tc_sqlbind.rb
191
+ - test/dbi/tc_statementhandle.rb
192
+ - test/dbi/tc_time.rb
193
+ - test/dbi/tc_timestamp.rb
194
+ - test/dbi/tc_types.rb
195
+ - test/ts_dbd.rb
196
+ - test/ts_dbi.rb
197
+ - ydbi.gemspec
198
+ homepage: http://www.rubyforge.org/projects/ruby-dbi
199
+ licenses: []
200
+ metadata: {}
201
+ post_install_message:
202
+ rdoc_options: []
203
+ require_paths:
204
+ - lib
205
+ required_ruby_version: !ruby/object:Gem::Requirement
206
+ requirements:
207
+ - - ">="
208
+ - !ruby/object:Gem::Version
209
+ version: '0'
210
+ required_rubygems_version: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - ">="
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ requirements: []
216
+ rubyforge_project:
217
+ rubygems_version: 2.4.5
218
+ signing_key:
219
+ specification_version: 4
220
+ summary: A vendor independent interface for accessing databases, similar to Perl's
221
+ DBI
222
+ test_files:
223
+ - test/ts_dbi.rb
224
+ has_rdoc: true