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
data/doc/homepage/ruby-dbi.css
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
BODY {
|
2
|
-
background-color: #666;
|
3
|
-
}
|
4
|
-
|
5
|
-
a:visited {
|
6
|
-
color: #144;
|
7
|
-
}
|
8
|
-
|
9
|
-
a {
|
10
|
-
color: white;
|
11
|
-
}
|
12
|
-
|
13
|
-
a:active {
|
14
|
-
text-decoration: none;
|
15
|
-
}
|
16
|
-
|
17
|
-
a:hover {
|
18
|
-
text-decoration: none;
|
19
|
-
}
|
20
|
-
|
21
|
-
.body-container {
|
22
|
-
margin-left: auto;
|
23
|
-
margin-right: auto;
|
24
|
-
margin-top: 50px;
|
25
|
-
width: 80%;
|
26
|
-
background-color: #AAA;
|
27
|
-
color: black;
|
28
|
-
padding: 10px;
|
29
|
-
border: 1px solid black;
|
30
|
-
}
|
31
|
-
|
32
|
-
h1 {
|
33
|
-
display: block;
|
34
|
-
margin: 2em;
|
35
|
-
border: 1px solid black;
|
36
|
-
padding: 1em;
|
37
|
-
color: #444;
|
38
|
-
font-size: 1em;
|
39
|
-
text-align: center;
|
40
|
-
font-family: sans-serif;
|
41
|
-
}
|
42
|
-
|
43
|
-
.main-container {
|
44
|
-
margin: 2em;
|
45
|
-
}
|
46
|
-
|
47
|
-
.nav-container {
|
48
|
-
display: block;
|
49
|
-
border: 1px solid black;
|
50
|
-
float: left;
|
51
|
-
vertical-align; top:
|
52
|
-
font-size: .8em;
|
53
|
-
min-width: 20%;
|
54
|
-
margin-right: 2em;
|
55
|
-
margin-bottom: 2em;
|
56
|
-
}
|
57
|
-
|
58
|
-
.nav-container h1 {
|
59
|
-
margin: 0;
|
60
|
-
padding: 0;
|
61
|
-
border: 0;
|
62
|
-
border-bottom: 1px solid black;
|
63
|
-
font-size: 1.2em;
|
64
|
-
font-weight: bold;
|
65
|
-
color: black;
|
66
|
-
text-align: center;
|
67
|
-
font-family: sans-serif;
|
68
|
-
}
|
69
|
-
|
70
|
-
.nav-container a {
|
71
|
-
display: block;
|
72
|
-
padding: 5px;
|
73
|
-
}
|
74
|
-
|
75
|
-
.nav-container a:hover {
|
76
|
-
background-color: #444;
|
77
|
-
color: white;
|
78
|
-
font-weight: bold;
|
79
|
-
}
|
80
|
-
|
81
|
-
.copyright {
|
82
|
-
display: block;
|
83
|
-
margin: 2em;
|
84
|
-
border: 1px solid black;
|
85
|
-
padding: 1em;
|
86
|
-
color: #444;
|
87
|
-
font-size: 0.6em;
|
88
|
-
text-align: center;
|
89
|
-
font-family: sans-serif;
|
90
|
-
}
|
91
|
-
|
data/lib/dbd/Mysql.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2001, 2002 Michael Neumann <neumann@s-direktnet.de>
|
3
|
-
#
|
4
|
-
# All rights reserved.
|
5
|
-
#
|
6
|
-
# Redistribution and use in source and binary forms, with or without
|
7
|
-
# modification, are permitted provided that the following conditions
|
8
|
-
# are met:
|
9
|
-
# 1. Redistributions of source code must retain the above copyright
|
10
|
-
# notice, this list of conditions and the following disclaimer.
|
11
|
-
# 2. Redistributions in binary form must reproduce the above copyright
|
12
|
-
# notice, this list of conditions and the following disclaimer in the
|
13
|
-
# documentation and/or other materials provided with the distribution.
|
14
|
-
# 3. The name of the author may not be used to endorse or promote products
|
15
|
-
# derived from this software without specific prior written permission.
|
16
|
-
#
|
17
|
-
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
18
|
-
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
19
|
-
# AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
20
|
-
# THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
-
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
-
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
23
|
-
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
24
|
-
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
25
|
-
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
26
|
-
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
27
|
-
#
|
28
|
-
# $Id$
|
29
|
-
#++
|
30
|
-
|
31
|
-
begin
|
32
|
-
require 'rubygems'
|
33
|
-
gem 'mysql'
|
34
|
-
gem 'dbi'
|
35
|
-
rescue LoadError => e
|
36
|
-
end
|
37
|
-
|
38
|
-
require 'dbi'
|
39
|
-
require "mysql"
|
40
|
-
require "thread" # for Mutex
|
41
|
-
|
42
|
-
module DBI
|
43
|
-
module DBD
|
44
|
-
#
|
45
|
-
# DBD::Mysql - Database Driver for the MySQL database system.
|
46
|
-
#
|
47
|
-
# Requires DBI and the 'mysql' gem or package to work.
|
48
|
-
#
|
49
|
-
# Only things that extend DBI's results are documented.
|
50
|
-
#
|
51
|
-
module Mysql
|
52
|
-
VERSION = "0.4.4"
|
53
|
-
DESCRIPTION = "MySQL DBI DBD, Leverages 'mysql' low-level driver"
|
54
|
-
|
55
|
-
MyError = ::MysqlError
|
56
|
-
|
57
|
-
#
|
58
|
-
# returns 'Mysql'
|
59
|
-
#
|
60
|
-
# See DBI::TypeUtil#convert for more information.
|
61
|
-
#
|
62
|
-
def self.driver_name
|
63
|
-
"Mysql"
|
64
|
-
end
|
65
|
-
|
66
|
-
DBI::TypeUtil.register_conversion(driver_name) do |obj|
|
67
|
-
newobj = case obj
|
68
|
-
when ::DBI::Binary
|
69
|
-
obj = obj.to_s.gsub(/\\/) { "\\\\" }
|
70
|
-
obj = obj.to_s.gsub(/'/) { "''" }
|
71
|
-
"'#{obj}'"
|
72
|
-
when ::DateTime
|
73
|
-
"'#{obj.strftime("%Y-%m-%d %H:%M:%S")}'"
|
74
|
-
when ::Time
|
75
|
-
"'#{obj.strftime("%H:%M:%S")}'"
|
76
|
-
when ::Date
|
77
|
-
"'#{obj.strftime("%Y-%m-%d")}'"
|
78
|
-
when ::NilClass
|
79
|
-
"NULL"
|
80
|
-
else
|
81
|
-
obj
|
82
|
-
end
|
83
|
-
|
84
|
-
if newobj.object_id == obj.object_id
|
85
|
-
[newobj, true]
|
86
|
-
else
|
87
|
-
[newobj, false]
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
#
|
95
|
-
# Utility Methods for the MySQL DBD.
|
96
|
-
#
|
97
|
-
|
98
|
-
module DBI::DBD::Mysql::Util
|
99
|
-
private
|
100
|
-
|
101
|
-
# Raise exception using information from MysqlError object e.
|
102
|
-
# For state value, use SQLSTATE value if mysql-ruby defines
|
103
|
-
# sqlstate method, otherwise nil.
|
104
|
-
def error(e)
|
105
|
-
sqlstate = e.respond_to?("sqlstate") ? e.sqlstate : nil
|
106
|
-
raise DBI::DatabaseError.new(e.message, e.errno, sqlstate)
|
107
|
-
end
|
108
|
-
|
109
|
-
end # module Util
|
110
|
-
|
111
|
-
module DBI::DBD::Mysql::Type
|
112
|
-
#
|
113
|
-
# Custom handling for DATE types in MySQL. See DBI::Type for more
|
114
|
-
# information.
|
115
|
-
#
|
116
|
-
class Date < DBI::Type::Null
|
117
|
-
def self.parse(obj)
|
118
|
-
obj = super
|
119
|
-
return obj unless obj
|
120
|
-
|
121
|
-
case obj.class
|
122
|
-
when ::Date
|
123
|
-
return obj
|
124
|
-
when ::String
|
125
|
-
return ::Date.strptime(obj, "%Y-%m-%d")
|
126
|
-
else
|
127
|
-
return ::Date.parse(obj.to_s) if obj.respond_to? :to_s
|
128
|
-
return ::Date.parse(obj.to_str) if obj.respond_to? :to_str
|
129
|
-
return obj
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
require 'dbd/mysql/driver'
|
136
|
-
require 'dbd/mysql/database'
|
137
|
-
require 'dbd/mysql/statement'
|
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 'ydbi'
|
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 = DBI::VERSION
|
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(DBI::VERSION)
|
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
|