ruby-mysql 2.9.2 → 2.9.3

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.

Potentially problematic release.


This version of ruby-mysql might be problematic. Click here for more details.

data/ChangeLog CHANGED
@@ -1,3 +1,17 @@
1
+ 2010-06-06 TOMITA Masahiro <tommy@tmtm.org>
2
+
3
+ * lib/mysql/charset.rb: support tis620 charset.
4
+
5
+ * lib/mysql/charset.rb, lib/mysql/protocol.rb: convert encoding to
6
+ Encoding.default_internal.
7
+
8
+ 2010-05-06 TOMITA Masahiro <tommy@tmtm.org>
9
+
10
+ * lib/mysql.rb (Mysql#connect): Fix: Mysql.connect ignore flag.
11
+
12
+ * spec/mysql_spec.rb: use environment variables for MySQL
13
+ connection.
14
+
1
15
  2010-01-17 TOMITA Masahiro <tommy@tmtm.org>
2
16
 
3
17
  * lib/mysql.rb (Mysql#errno): Fix: Mysql#errno's default value
data/lib/mysql.rb CHANGED
@@ -16,7 +16,7 @@ class Mysql
16
16
  require "#{dir}/mysql/charset"
17
17
  require "#{dir}/mysql/protocol"
18
18
 
19
- VERSION = 20900 # Version number of this library
19
+ VERSION = 20903 # Version number of this library
20
20
  MYSQL_UNIX_PORT = "/tmp/mysql.sock" # UNIX domain socket filename
21
21
  MYSQL_TCP_PORT = 3306 # TCP socket port number
22
22
 
@@ -108,7 +108,7 @@ class Mysql
108
108
  # self
109
109
  def connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, flag=nil)
110
110
  @protocol = Protocol.new host, port, socket, @connect_timeout, @read_timeout, @write_timeout
111
- @protocol.authenticate user, passwd, db, (@local_infile ? CLIENT_LOCAL_FILES : 0), @charset
111
+ @protocol.authenticate user, passwd, db, (@local_infile ? CLIENT_LOCAL_FILES : 0) | (flag || 0), @charset
112
112
  @charset ||= @protocol.charset
113
113
  @host_info = (host.nil? || host == "localhost") ? 'Localhost via UNIX socket' : "#{host} via TCP/IP"
114
114
  query @init_command if @init_command
data/lib/mysql/charset.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2008 TOMITA Masahiro
1
+ # Copyright (C) 2008-2010 TOMITA Masahiro
2
2
  # mailto:tommy@tmtm.org
3
3
 
4
4
  require "#{File.dirname __FILE__}/error"
@@ -207,7 +207,7 @@ class Mysql
207
207
  "macroman" => Encoding::MacRoman,
208
208
  "sjis" => Encoding::SHIFT_JIS,
209
209
  "swe7" => nil,
210
- "tis620" => nil,
210
+ "tis620" => Encoding::TIS_620,
211
211
  "ucs2" => Encoding::UTF_16BE,
212
212
  "ujis" => Encoding::EucJP_ms,
213
213
  "utf8" => Encoding::UTF_8,
@@ -217,6 +217,16 @@ class Mysql
217
217
  value.dup.force_encoding Encoding::ASCII_8BIT
218
218
  end
219
219
 
220
+ # convert raw to encoding and convert to Encoding.default_internal
221
+ # === Argument
222
+ # raw :: [String]
223
+ # charset :: [Mysql::Charset]
224
+ # === Return
225
+ # result [String]
226
+ def self.convert_encoding(raw, encoding)
227
+ raw.dup.force_encoding(encoding).encode
228
+ end
229
+
220
230
  # retrun corresponding Ruby encoding
221
231
  # === Return
222
232
  # encoding [Encoding]
@@ -234,14 +244,6 @@ class Mysql
234
244
  value
235
245
  end
236
246
 
237
- # convert encoding from MySQL charset to Ruby
238
- def force_encoding(value)
239
- if value.is_a? String
240
- value = value.dup.force_encoding encoding
241
- end
242
- value
243
- end
244
-
245
247
  else
246
248
  # for Ruby 1.8
247
249
 
@@ -249,6 +251,10 @@ class Mysql
249
251
  value
250
252
  end
251
253
 
254
+ def self.convert_encoding(raw, encoding)
255
+ raw
256
+ end
257
+
252
258
  def encoding
253
259
  nil
254
260
  end
@@ -257,9 +263,6 @@ class Mysql
257
263
  value
258
264
  end
259
265
 
260
- def force_encoding(value)
261
- value
262
- end
263
266
  end
264
267
  end
265
268
  end
@@ -335,7 +335,7 @@ class Mysql
335
335
  until self.class.eof_packet?(data = read)
336
336
  rec = fields.map do
337
337
  s = self.class.lcs2str!(data)
338
- s && charset.force_encoding(s)
338
+ s && Charset.convert_encoding(s, charset.encoding)
339
339
  end
340
340
  all_recs.push rec
341
341
  end
@@ -513,7 +513,7 @@ class Mysql
513
513
  elsif f.type == Field::TYPE_BIT or f.flags & Field::BINARY_FLAG != 0
514
514
  Charset.to_binary(v)
515
515
  else
516
- charset.force_encoding(v)
516
+ Charset.convert_encoding(v, charset.encoding)
517
517
  end
518
518
  end
519
519
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.2
4
+ version: 2.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tommy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-22 00:00:00 +09:00
12
+ date: 2010-06-06 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15