dbd-mysql 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ module DBI
49
49
  # Only things that extend DBI's results are documented.
50
50
  #
51
51
  module Mysql
52
- VERSION = "0.3.3"
52
+ VERSION = "0.4.0"
53
53
  DESCRIPTION = "MySQL DBI DBD, Leverages 'mysql' low-level driver"
54
54
 
55
55
  MyError = ::MysqlError
@@ -181,7 +181,7 @@ module DBI::DBD::Mysql
181
181
  uniques = []
182
182
  dbh.execute("SHOW INDEX FROM #{table}") do |sth|
183
183
  sth.each do |row|
184
- uniques << row[4] if row[1] == "0"
184
+ uniques << row[4] if row[1] == 0
185
185
  end
186
186
  end
187
187
 
@@ -128,7 +128,7 @@ module DBI::DBD::Mysql
128
128
  # is set only by mysql_list_fields()
129
129
 
130
130
  @res_handle.fetch_fields.each {|col|
131
- mysql_type_name = Database::TYPE_MAP[col.type][0] rescue nil
131
+ mysql_type_name, dbi_type = Database::TYPE_MAP[col.type] rescue [nil, nil]
132
132
  xopen_info = Database::MYSQL_to_XOPEN[mysql_type_name] ||
133
133
  Database::MYSQL_to_XOPEN[nil]
134
134
  sql_type = xopen_info[0]
@@ -158,6 +158,8 @@ module DBI::DBD::Mysql
158
158
 
159
159
  if retval[-1]['sql_type'] == DBI::SQL_TINYINT and retval[-1]['precision'] == 1
160
160
  retval[-1]['dbi_type'] = DBI::Type::Boolean
161
+ elsif dbi_type
162
+ retval[-1]['dbi_type'] = dbi_type
161
163
  end
162
164
  }
163
165
  retval
@@ -1,4 +1,13 @@
1
1
  @class = Class.new(DBDConfig.testbase(DBDConfig.current_dbtype)) do
2
+
3
+ def test_execute
4
+ assert_nothing_raised do
5
+ @dbh.execute("select * from names order by age") do |sth|
6
+ assert_equal([["Joe", 19], ["Bob", 21], ["Jim", 30]], sth.fetch_all)
7
+ end
8
+ end
9
+ end
10
+
2
11
  def test_quoting # FIXME breaks sqlite-ruby to a segfault - research
3
12
  @sth = nil
4
13
 
@@ -114,7 +123,7 @@
114
123
  @sth.finish
115
124
  end
116
125
 
117
- def test_execute
126
+ def test_prepare_execute
118
127
  assert_nothing_raised do
119
128
  @sth = @dbh.prepare("select * from names")
120
129
  @sth.execute
@@ -134,7 +143,7 @@
134
143
  end
135
144
  end
136
145
 
137
- def test_execute_with_transactions
146
+ def test_prepare_execute_with_transactions
138
147
  @dbh["AutoCommit"] = false
139
148
  config = DBDConfig.get_config['sqlite3']
140
149
 
@@ -4,9 +4,13 @@ class TestMysqlPatches < DBDConfig.testbase(:mysql)
4
4
  sth = @dbh.prepare("select sum(age) from names")
5
5
  sth.execute
6
6
  row = sth.fetch
7
- # FIXME: this is BROKEN - should not be a string, should be fixnum
8
7
  assert_equal(70.0, row[0])
9
8
  sth.finish
9
+
10
+ sth = @dbh.prepare("select count(*) from names")
11
+ sth.execute
12
+ assert_equal([3], sth.fetch)
13
+ sth.finish
10
14
  end
11
15
  end
12
16
 
@@ -45,20 +49,21 @@ class TestMysqlPatches < DBDConfig.testbase(:mysql)
45
49
  assert_equal [2], row
46
50
  assert_equal [
47
51
  {
48
- :name =>"foo",
49
- :mysql_type_name =>"INT",
50
- :mysql_max_length =>1,
51
- :primary =>true,
52
- :scale =>0,
53
- :mysql_flags =>49155,
54
- :sql_type =>4,
55
- :nullable =>false,
56
- :mysql_type =>3,
57
- :indexed =>true,
58
- :mysql_length =>11,
59
- :precision =>11,
60
- :type_name =>"INTEGER",
61
- :unique =>true
52
+ :dbi_type => DBI::Type::Integer,
53
+ :name =>"foo",
54
+ :mysql_type_name =>"INT",
55
+ :mysql_max_length =>1,
56
+ :primary =>true,
57
+ :scale =>0,
58
+ :mysql_flags =>49155,
59
+ :sql_type =>4,
60
+ :nullable =>false,
61
+ :mysql_type =>3,
62
+ :indexed =>true,
63
+ :mysql_length =>11,
64
+ :precision =>11,
65
+ :type_name =>"INTEGER",
66
+ :unique =>true
62
67
  }
63
68
  ], columns
64
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbd-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Hollensbe
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2008-08-23 00:00:00 -07:00
13
+ date: 2008-09-02 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency