ruby-mysql-ext 2.9.10 → 2.9.11

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.
@@ -1,3 +1,4 @@
1
+ # coding: ascii-8bit
1
2
  class Mysql
2
3
  class Packet
3
4
  # convert Numeric to LengthCodedBinary
@@ -1,3 +1,4 @@
1
+ # coding: ascii-8bit
1
2
  # Copyright (C) 2008-2012 TOMITA Masahiro
2
3
  # mailto:tommy@tmtm.org
3
4
 
@@ -282,16 +283,16 @@ class Mysql
282
283
 
283
284
  # Retrieve all records for simple query
284
285
  # === Argument
285
- # nfields :: [Integer] number of fields
286
+ # fields :: [Array<Mysql::Field>] number of fields
286
287
  # === Return
287
288
  # [Array of Array of String] all records
288
- def retr_all_records(nfields)
289
+ def retr_all_records(fields)
289
290
  check_state :RESULT
290
291
  enc = charset.encoding
291
292
  begin
292
293
  all_recs = []
293
294
  until (pkt = read).eof?
294
- all_recs.push RawRecord.new(pkt, nfields, enc)
295
+ all_recs.push RawRecord.new(pkt, fields, enc)
295
296
  end
296
297
  pkt.read(3)
297
298
  @server_status = pkt.utiny
@@ -501,7 +502,7 @@ class Mysql
501
502
  raise EOFError unless ret && ret.length == len
502
503
  end
503
504
  rescue EOFError
504
- raise ClientError::ServerGoneError, 'The MySQL server has gone away'
505
+ raise ClientError::ServerGoneError, 'MySQL server has gone away'
505
506
  rescue Timeout::Error
506
507
  raise ClientError, "read timeout"
507
508
  end while len == MAX_PACKET_LENGTH
@@ -549,7 +550,7 @@ class Mysql
549
550
  @sock.flush
550
551
  end
551
552
  rescue Errno::EPIPE
552
- raise ClientError::ServerGoneError, 'The MySQL server has gone away'
553
+ raise ClientError::ServerGoneError, 'MySQL server has gone away'
553
554
  rescue Timeout::Error
554
555
  raise ClientError, "write timeout"
555
556
  end
@@ -730,14 +731,16 @@ class Mysql
730
731
  end
731
732
 
732
733
  class RawRecord
733
- def initialize(packet, nfields, encoding)
734
- @packet, @nfields, @encoding = packet, nfields, encoding
734
+ def initialize(packet, fields, encoding)
735
+ @packet, @fields, @encoding = packet, fields, encoding
735
736
  end
736
737
 
737
738
  def to_a
738
- @nfields.times.map do
739
+ @fields.map do |f|
739
740
  if s = @packet.lcs
740
- s = Charset.convert_encoding(s, @encoding)
741
+ unless f.type == Field::TYPE_BIT or f.charsetnr == Charset::BINARY_CHARSET_NUMBER
742
+ s = Charset.convert_encoding(s, @encoding)
743
+ end
741
744
  end
742
745
  s
743
746
  end
@@ -13,7 +13,7 @@ MYSQL_SOCKET = ENV['MYSQL_SOCKET']
13
13
 
14
14
  describe 'Mysql::VERSION' do
15
15
  it 'returns client version' do
16
- Mysql::VERSION.should == 20910
16
+ Mysql::VERSION.should == 20911
17
17
  end
18
18
  end
19
19
 
@@ -338,13 +338,14 @@ describe 'Mysql' do
338
338
  end
339
339
 
340
340
  describe '#kill' do
341
- it 'returns self' do
342
- @m.kill(@m.thread_id).should == @m
341
+ before do
342
+ @m2 = Mysql.new(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
343
343
  end
344
- it 'kill specified connection' do
345
- m = Mysql.new(MYSQL_SERVER, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE, MYSQL_PORT, MYSQL_SOCKET)
346
- m.list_processes.map(&:first).should be_include @m.thread_id.to_s
347
- m.close
344
+ after do
345
+ @m2.close rescue nil
346
+ end
347
+ it 'returns self' do
348
+ @m.kill(@m2.thread_id).should == @m
348
349
  end
349
350
  end
350
351
 
@@ -1719,11 +1720,21 @@ if defined? Encoding
1719
1720
 
1720
1721
  describe 'default_internal is CP932' do
1721
1722
  before do
1723
+ @m.prepare("insert into t (utf8,cp932,eucjp,bin) values (?,?,?,?)").execute @utf8, @cp932, @eucjp, @bin
1722
1724
  Encoding.default_internal = 'CP932'
1723
1725
  end
1724
1726
  it 'is converted to CP932' do
1725
1727
  @m.query('select "あいう"').fetch.should == ["\x82\xA0\x82\xA2\x82\xA4".force_encoding("CP932")]
1726
1728
  end
1729
+ it 'data is stored as is' do
1730
+ @m.query('select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t').fetch.should == ['E38184E3828DE381AF', '82A282EB82CD', 'A4A4A4EDA4CF', '00017F80FEFF']
1731
+ end
1732
+ it 'By simple query, charset of retrieved data is connection charset' do
1733
+ @m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@cp932, @cp932, @cp932, @bin]
1734
+ end
1735
+ it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
1736
+ @m.prepare('select utf8,cp932,eucjp,bin from t').execute.fetch.should == [@cp932, @cp932, @cp932, @bin]
1737
+ end
1727
1738
  end
1728
1739
 
1729
1740
  describe 'query with CP932 encoding' do
@@ -1746,7 +1757,7 @@ if defined? Encoding
1746
1757
  @m.query('select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t').fetch.should == ['E38184E3828DE381AF', '82A282EB82CD', 'A4A4A4EDA4CF', '00017F80FEFF']
1747
1758
  end
1748
1759
  it 'By simple query, charset of retrieved data is connection charset' do
1749
- @m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@utf8, @utf8, @utf8, @bin.dup.force_encoding("UTF-8")]
1760
+ @m.query('select utf8,cp932,eucjp,bin from t').fetch.should == [@utf8, @utf8, @utf8, @bin]
1750
1761
  end
1751
1762
  it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
1752
1763
  @m.prepare('select utf8,cp932,eucjp,bin from t').execute.fetch.should == [@utf8, @utf8, @utf8, @bin]
@@ -1761,7 +1772,7 @@ if defined? Encoding
1761
1772
  @m.query("select hex(utf8),hex(cp932),hex(eucjp),hex(bin) from t").fetch.should == ["E38184E3828DE381AF", "82A282EB82CD", "A4A4A4EDA4CF", "E38184E3828DE381AF"]
1762
1773
  end
1763
1774
  it 'By simple query, charset of retrieved data is connection charset' do
1764
- @m.query("select utf8,cp932,eucjp,bin from t").fetch.should == [@utf8, @utf8, @utf8, @utf8]
1775
+ @m.query("select utf8,cp932,eucjp,bin from t").fetch.should == [@utf8, @utf8, @utf8, @utf8.dup.force_encoding('ASCII-8BIT')]
1765
1776
  end
1766
1777
  it 'By prepared statement, charset of retrieved data is connection charset except for binary' do
1767
1778
  @m.prepare("select utf8,cp932,eucjp,bin from t").execute.fetch.should == [@utf8, @utf8, @utf8, @utf8.dup.force_encoding("ASCII-8BIT")]
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mysql-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.10
5
- prerelease:
4
+ version: 2.9.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tomita Masahiro
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-12 00:00:00.000000000 Z
11
+ date: 2013-04-09 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: This is MySQL connector with C extension.
15
14
  email: tommy@tmtm.org
@@ -33,27 +32,26 @@ files:
33
32
  homepage: http://github.com/tmtm/ruby-mysql
34
33
  licenses:
35
34
  - Ruby's
35
+ metadata: {}
36
36
  post_install_message:
37
37
  rdoc_options: []
38
38
  require_paths:
39
39
  - lib
40
40
  required_ruby_version: !ruby/object:Gem::Requirement
41
- none: false
42
41
  requirements:
43
- - - ! '>='
42
+ - - '>='
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
46
45
  required_rubygems_version: !ruby/object:Gem::Requirement
47
- none: false
48
46
  requirements:
49
- - - ! '>='
47
+ - - '>='
50
48
  - !ruby/object:Gem::Version
51
49
  version: '0'
52
50
  requirements: []
53
51
  rubyforge_project:
54
- rubygems_version: 1.8.23
52
+ rubygems_version: 2.0.0
55
53
  signing_key:
56
- specification_version: 3
54
+ specification_version: 4
57
55
  summary: MySQL connector with extension
58
56
  test_files:
59
57
  - spec/mysql_spec.rb