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
data/lib/dbd/ODBC.rb DELETED
@@ -1,89 +0,0 @@
1
- #--
2
- # DBD::ODBC
3
- #
4
- # Copyright (c) 2001-2004 Michael Neumann <mneumann@ntecs.de>
5
- #
6
- # All rights reserved.
7
- #
8
- # Redistribution and use in source and binary forms, with or without
9
- # modification, are permitted provided that the following conditions
10
- # are met:
11
- # 1. Redistributions of source code must retain the above copyright
12
- # notice, this list of conditions and the following disclaimer.
13
- # 2. Redistributions in binary form must reproduce the above copyright
14
- # notice, this list of conditions and the following disclaimer in the
15
- # documentation and/or other materials provided with the distribution.
16
- # 3. The name of the author may not be used to endorse or promote products
17
- # derived from this software without specific prior written permission.
18
- #
19
- # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
- # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
- # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
- # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
- # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25
- # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26
- # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27
- # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
- #
30
- # $Id$
31
- #++
32
-
33
- $:.delete(".") # FIXME oh for the love of pete..
34
- require "odbc"
35
- $: << "."
36
-
37
- begin
38
- require 'rubygems'
39
- gem 'dbi'
40
- rescue LoadError => e
41
- end
42
-
43
- require 'dbi'
44
-
45
- module DBI
46
- module DBD
47
- #
48
- # DBD::ODBC - ODBC Database Driver
49
- #
50
- # Requires DBI and the 'ruby-odbc' package to work, and unixodbc (iodbc
51
- # WILL NOT WORK).
52
- #
53
- # Only things that extend DBI's results are documented.
54
- #
55
- module ODBC
56
-
57
- VERSION = "0.2.5"
58
- DESCRIPTION = "ODBC DBI DBD"
59
-
60
- def self.driver_name
61
- "odbc"
62
- end
63
-
64
- DBI::TypeUtil.register_conversion(driver_name) do |obj|
65
- newobj = if obj.nil?
66
- nil
67
- else
68
- case obj
69
- when ::Date
70
- ::ODBC::Date.new(obj)
71
- when ::Time
72
- ::ODBC::Time.new(obj)
73
- when ::DateTime
74
- ::ODBC::Timestamp.new(obj)
75
- else
76
- obj.to_s
77
- end
78
- end
79
- [newobj, false]
80
- end
81
-
82
- ODBCErr = ::ODBC::Error
83
- end # module ODBC
84
- end # module DBD
85
- end # module DBI
86
-
87
- require 'dbd/odbc/driver'
88
- require 'dbd/odbc/database'
89
- require 'dbd/odbc/statement'
data/lib/dbd/Pg.rb DELETED
@@ -1,188 +0,0 @@
1
- #--
2
- # DBD::Pg
3
- #
4
- # Copyright (c) 2001, 2002, 2003 Jim Weirich, Michael Neumann <mneumann@ntecs.de>
5
- # Copyright (c) 2008 Erik Hollensbe, Christopher Maujean
6
- #
7
- # All rights reserved.
8
- #
9
- # Redistribution and use in source and binary forms, with or without
10
- # modification, are permitted provided that the following conditions
11
- # are met:
12
- # 1. Redistributions of source code must retain the above copyright
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
16
- # documentation and/or other materials provided with the distribution.
17
- # 3. The name of the author may not be used to endorse or promote products
18
- # derived from this software without specific prior written permission.
19
- #
20
- # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
- # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
- # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
- # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
- # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
- # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
- # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
- # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- #++
31
-
32
- begin
33
- require 'rubygems'
34
- gem 'pg'
35
- gem 'dbi'
36
- rescue Exception => e
37
- end
38
-
39
- require 'dbi'
40
- require 'pg'
41
-
42
- module DBI
43
- module DBD
44
- #
45
- # DBD::Pg - Database Driver for the PostgreSQL database system.
46
- #
47
- # Requires DBI and the 'pg' gem or package to work.
48
- #
49
- # Only things that extend DBI's results are documented.
50
- #
51
- module Pg
52
- VERSION = "0.3.9"
53
- DESCRIPTION = "PostgreSQL DBI DBD"
54
-
55
- #
56
- # returns 'Pg'
57
- #
58
- # See DBI::TypeUtil#convert for more information.
59
- #
60
- def self.driver_name
61
- "Pg"
62
- end
63
-
64
- #
65
- # This method takes a ruby Array and converts it to PostgreSQL array syntax.
66
- #
67
- def self.generate_array(obj)
68
- # XXX yarr, there be recursion here, and it's probably not a good idea.
69
- output = "{"
70
- obj.each do |item|
71
- case item
72
- when ::Array
73
- output += generate_array(item)
74
- else
75
- generated = DBI::TypeUtil.convert(driver_name, item)
76
- generated = case item
77
- when String
78
- # in strings, escapes are doubled and the quotes are different.
79
- # this gets *really* ugly and needs to be well-tested
80
- "\"#{generated.gsub(/\\/) { "\\\\" }}\""
81
- when Fixnum
82
- generated.to_s
83
- end
84
- output += generated
85
- end
86
- output += "," # FIXME technically, delimiters are variable
87
- end
88
-
89
- output.sub(/,$/, '}')
90
- end
91
-
92
- #
93
- # A quote helper, this uses the new syntax in PostgreSQL 8.2 and up.
94
- #
95
- def self.quote(value)
96
- "E'#{ value.gsub(/\\/){ '\\\\' }.gsub(/'/){ '\\\'' } }'"
97
- end
98
-
99
- #
100
- # Parse a postgresql type. Returns a hash with these fields (as Symbol)
101
- #
102
- # * ftype: the full type, as passed in to this method.
103
- # * type: the type stripped of all attribute information.
104
- # * size: the LHS of the attribute information, typically the precision.
105
- # * decimal: the RHS of the attribute information, typically the scale.
106
- # * array: true if this type is actually an array of that type.
107
- #
108
- def self.parse_type(ftype)
109
- type = ftype
110
- pos = ftype.index('(')
111
- decimal = nil
112
- size = nil
113
- array_of_type = nil
114
-
115
- if pos != nil
116
- type = ftype[0..pos-1]
117
- size = ftype[pos+1..-2]
118
- pos = size.index(',')
119
- if pos != nil
120
- size, decimal = size.split(',', 2)
121
- size = size.to_i
122
- decimal = decimal.to_i
123
- else
124
- size = size.to_i
125
- end
126
- end
127
-
128
- if type =~ /\[\]$/
129
- type.sub!(/\[\]$/, '')
130
- array_of_type = true
131
- end
132
-
133
- return {
134
- :ftype => ftype.dup,
135
- :type => type,
136
- :size => size,
137
- :decimal => decimal,
138
- :array => array_of_type
139
- }
140
- end
141
-
142
- #
143
- # See DBI::BaseDriver.
144
- #
145
- class Driver < DBI::BaseDriver
146
- def initialize
147
- super("0.4.0")
148
- end
149
-
150
- ## List of datasources for this database.
151
- def data_sources
152
- []
153
- end
154
-
155
- ## Connect to a database.
156
- def connect(dbname, user, auth, attr)
157
- Database.new(dbname, user, auth, attr)
158
- end
159
- end
160
- end # module Pg
161
- end # module DBD
162
- end # module DBI
163
-
164
- require 'dbd/pg/type'
165
- require 'dbd/pg/database'
166
- require 'dbd/pg/statement'
167
- require 'dbd/pg/tuples'
168
- require 'dbd/pg/exec'
169
-
170
- pg = DBI::DBD::Pg
171
-
172
- DBI::TypeUtil.register_conversion(pg.driver_name) do |obj|
173
- newobj = case obj
174
- when ::DateTime
175
- obj.strftime("%Y-%m-%dT%H:%M:%S.%N")
176
- when ::Time
177
- ::DateTime.parse(obj.to_s).strftime("%H:%M:%S.%N")
178
- when ::Date
179
- obj.strftime("%Y-%m-%d")
180
- when ::Array
181
- pg.generate_array(obj)
182
- when DBI::DBD::Pg::Type::ByteA
183
- obj.escaped
184
- else
185
- obj
186
- end
187
- [newobj, false]
188
- end
data/lib/dbd/SQLite.rb DELETED
@@ -1,97 +0,0 @@
1
- #--
2
- ###############################################################################
3
- #
4
- # DBD::SQLite - a DBD for SQLite for versions < 3
5
- #
6
- # Uses Jamis Buck's 'sqlite-ruby' driver to interface with SQLite directly
7
- #
8
- # (c) 2008 Erik Hollensbe & Christopher Maujean.
9
- #
10
- # TODO
11
- #
12
- # fetch_scroll implementation?
13
- # columns and column_info differ too much and have too much copied code, refactor
14
- # there are probably some edge cases with transactions
15
- #
16
- ################################################################################
17
- #++
18
-
19
- begin
20
- require 'rubygems'
21
- gem 'sqlite-ruby'
22
- gem 'dbi'
23
- rescue Exception => e
24
- end
25
-
26
- require 'dbi'
27
- require 'sqlite'
28
-
29
- module DBI
30
- module DBD
31
- #
32
- # DBD::SQLite - Database Driver for SQLite versions 2.x and lower.
33
- #
34
- # Requires DBI and the 'sqlite-ruby' gem to work.
35
- #
36
- # Only things that extend DBI's results are documented.
37
- #
38
- class SQLite
39
- VERSION = "0.1.2"
40
- DESCRIPTION = "SQLite 2.x DBI DBD"
41
-
42
- #
43
- # returns 'SQLite'
44
- #
45
- # See DBI::TypeUtil#convert for more information.
46
- #
47
- def self.driver_name
48
- "SQLite"
49
- end
50
-
51
- #
52
- # Validates that the SQL has no literal NUL characters. (ASCII 0)
53
- #
54
- # SQLite apparently really hates it when you do that.
55
- #
56
- # It will raise DBI::DatabaseError should it find any.
57
- #
58
- def self.check_sql(sql)
59
- # XXX I'm starting to think this is less of a problem with SQLite
60
- # and more with the old C DBD
61
- raise DBI::DatabaseError, "Bad SQL: SQL cannot contain nulls" if sql =~ /\0/
62
- end
63
-
64
- #
65
- # Split a type definition into parts via String#match and return the whole result.
66
- #
67
- def self.parse_type(type_name)
68
- type_name.match(/^([^\(]+)(\((\d+)(,(\d+))?\))?$/)
69
- end
70
-
71
- #
72
- # See DBI::BaseDriver.
73
- #
74
- class Driver < DBI::BaseDriver
75
- def initialize
76
- super "0.4.0"
77
- end
78
-
79
- def connect(dbname, user, auth, attr_hash)
80
- return Database.new(dbname, user, auth, attr_hash)
81
- end
82
- end
83
- end
84
- end
85
- end
86
-
87
- require 'dbd/sqlite/database'
88
- require 'dbd/sqlite/statement'
89
-
90
- DBI::TypeUtil.register_conversion(DBI::DBD::SQLite.driver_name) do |obj|
91
- case obj
92
- when ::NilClass
93
- ["NULL", false]
94
- else
95
- [obj, true]
96
- end
97
- end
data/lib/dbd/SQLite3.rb DELETED
@@ -1,124 +0,0 @@
1
- #--
2
- # DBD::SQLite3
3
- #
4
- # copyright (c) 2005 Jun Mukai <mukai@jmuk.org>
5
- # Compatibility patches by Erik Hollensbe <erik@hollensbe.org>
6
- #
7
- # All rights reserved.
8
- #
9
- # Redistribution and use in source and binary forms, with or without
10
- # modification, are permitted provided that the following conditions
11
- # are met:
12
- # 1. Redistributions of source code must retain the above copyright
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
16
- # documentation and/or other materials provided with the distribution.
17
- # 3. The name of the author may not be used to endorse or promote products
18
- # derived from this software without specific prior written permission.
19
- #
20
- # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
- # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
- # AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23
- # THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24
- # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25
- # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26
- # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
- # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28
- # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29
- # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
- #++
31
-
32
- begin
33
- require 'rubygems'
34
- gem 'sqlite3-ruby'
35
- gem 'dbi'
36
- rescue LoadError
37
- end
38
-
39
- require 'dbi'
40
- require 'sqlite3'
41
- require 'sqlite3/version'
42
-
43
- module DBI
44
- module DBD
45
- #
46
- # DBD::SQLite3 - Database Driver for SQLite versions 3.x
47
- #
48
- # Requires DBI and the 'sqlite3-ruby' gem to work.
49
- #
50
- # Only things that extend DBI's results are documented.
51
- #
52
- module SQLite3
53
- VERSION = "1.2.5"
54
- DESCRIPTION = "SQLite 3.x DBD for DBI"
55
-
56
- #
57
- # returns 'SQLite3'
58
- #
59
- # See DBI::TypeUtil#convert for more information.
60
- #
61
- def self.driver_name
62
- "SQLite3"
63
- end
64
-
65
- #
66
- # Validates that the SQL has no literal NUL characters. (ASCII 0)
67
- #
68
- # SQLite apparently really hates it when you do that.
69
- #
70
- # It will raise DBI::DatabaseError should it find any.
71
- #
72
- def self.parse_type(type_name)
73
- # FIXME plucked from SQLite driver, this needs to be in DBI proper
74
- return ['varchar'] unless type_name
75
- type_name.match(/^([^\(\s]+)\s*(\(\s*(\d+)\s*(,\s*(\d+))?\s*\))?$/)
76
- end
77
-
78
- #
79
- # See DBI::BaseDriver.
80
- #
81
- class Driver < DBI::BaseDriver
82
- def initialize
83
- @dbs = []
84
- super "0.4.0"
85
- end
86
-
87
- def connect(dbname, user, auth, attr)
88
- raise DBI::InterfaceError, "dbname must be a string" unless dbname.kind_of? String
89
- raise DBI::InterfaceError, "dbname must have some length" unless dbname.length > 0
90
- raise DBI::InterfaceError, "attrs must be a hash" unless attr.kind_of? Hash
91
- db = DBI::DBD::SQLite3::Database.new(dbname, attr)
92
- @dbs.push(db)
93
- db
94
- end
95
-
96
- def disconnect_all()
97
- @dbs.each{|db| db.disconnect()}
98
- end
99
- end
100
- end
101
- end
102
- end
103
-
104
- require 'dbd/sqlite3/database'
105
- require 'dbd/sqlite3/statement'
106
-
107
- DBI::TypeUtil.register_conversion(DBI::DBD::SQLite3.driver_name) do |obj|
108
- newobj = case obj
109
- when ::TrueClass
110
- '1'
111
- when ::FalseClass
112
- '0'
113
- else
114
- # SQLite3 is managing its own conversion right now, until I'm happy let's keep it that way
115
- obj.dup rescue obj
116
- end
117
- if newobj.kind_of?(::Symbol)
118
- newobj.to_s
119
- elsif newobj.object_id == obj.object_id
120
- [newobj, true]
121
- else
122
- [newobj, false]
123
- end
124
- end