og 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/ProjectInfo +2 -2
  2. data/README +8 -4
  3. data/Rakefile +1 -1
  4. data/doc/AUTHORS +1 -1
  5. data/doc/RELEASES +81 -0
  6. data/examples/README +7 -0
  7. data/lib/glue/cacheable.rb +152 -0
  8. data/lib/glue/hierarchical.rb +5 -4
  9. data/lib/glue/optimistic_locking.rb +0 -1
  10. data/lib/glue/orderable.rb +46 -44
  11. data/lib/glue/taggable.rb +7 -4
  12. data/lib/glue/timestamped.rb +1 -1
  13. data/lib/og.rb +13 -6
  14. data/lib/og/entity.rb +226 -9
  15. data/lib/og/evolution.rb +2 -2
  16. data/lib/og/ez/clause.rb +147 -0
  17. data/lib/og/ez/condition.rb +181 -0
  18. data/lib/og/manager.rb +31 -30
  19. data/lib/og/relation.rb +5 -5
  20. data/lib/og/relation/has_many.rb +3 -1
  21. data/lib/og/relation/joins_many.rb +1 -1
  22. data/lib/og/store.rb +6 -3
  23. data/lib/og/store/kirby.rb +3 -5
  24. data/lib/og/store/mysql.rb +0 -1
  25. data/lib/og/store/sql.rb +43 -7
  26. data/lib/og/store/sqlite.rb +97 -11
  27. data/lib/og/store/sqlite2.rb +231 -0
  28. data/lib/og/test/testcase.rb +1 -1
  29. data/lib/og/vendor/mysql.rb +103 -25
  30. data/test/glue/tc_revisable.rb +11 -11
  31. data/test/og/CONFIG.rb +20 -8
  32. data/test/og/mixin/tc_hierarchical.rb +5 -3
  33. data/test/og/mixin/tc_optimistic_locking.rb +6 -4
  34. data/test/og/mixin/tc_orderable.rb +22 -22
  35. data/test/og/mixin/tc_taggable.rb +15 -11
  36. data/test/og/mixin/tc_timestamped.rb +4 -2
  37. data/test/og/multi_validations_model.rb +8 -0
  38. data/test/og/store/tc_filesys.rb +15 -12
  39. data/test/og/store/tc_kirby.rb +14 -11
  40. data/test/og/tc_accumulator.rb +1 -3
  41. data/test/og/tc_cacheable.rb +58 -0
  42. data/test/og/tc_delete_all.rb +13 -16
  43. data/test/og/tc_ez.rb +33 -0
  44. data/test/og/tc_finder.rb +2 -4
  45. data/test/og/tc_inheritance.rb +3 -3
  46. data/test/og/tc_inheritance2.rb +2 -3
  47. data/test/og/tc_join.rb +3 -2
  48. data/test/og/tc_multi_validations.rb +3 -3
  49. data/test/og/tc_multiple.rb +3 -6
  50. data/test/og/tc_override.rb +19 -13
  51. data/test/og/tc_polymorphic.rb +1 -3
  52. data/test/og/tc_resolve.rb +32 -0
  53. data/test/og/tc_reverse.rb +27 -28
  54. data/test/og/tc_scoped.rb +2 -4
  55. data/test/og/tc_select.rb +1 -3
  56. data/test/og/tc_store.rb +3 -8
  57. data/test/og/tc_validation.rb +2 -2
  58. data/test/og/tc_validation2.rb +56 -58
  59. data/test/og/tc_validation_loop.rb +2 -5
  60. metadata +15 -7
  61. data/lib/og/vendor/mysql411.rb +0 -306
@@ -22,9 +22,7 @@ class TC_Query < Test::Unit::TestCase # :nodoc: all
22
22
  end
23
23
  end
24
24
 
25
- def setup
26
- @og = Og.setup($og_config)
27
- end
25
+ $og1.manage_classes(Item)
28
26
 
29
27
  def test_all
30
28
  Item.create(2, 34.5)
@@ -66,18 +66,13 @@ class TCOgStore < Test::Unit::TestCase # :nodoc: all
66
66
  many_to_many Bugger
67
67
  end
68
68
 
69
+ $og1.manage_classes(User, Category, Article, NewArticle, Comment, Bugger)
70
+
69
71
  def setup
70
- @og = nil
71
- end
72
-
73
- def teardown
74
- @og.store.close
75
- @og.store.class.destroy(@og.options)
76
- @og = nil
72
+ @og = $og1
77
73
  end
78
74
 
79
75
  def test_og
80
- @og = Og.setup($og_config)
81
76
  features_test
82
77
  # conversions_test
83
78
  end
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'CONFIG.rb')
2
2
 
3
- $DBG = true
3
+ # $DBG = true
4
4
  require 'rubygems'
5
5
  require 'facets'
6
6
 
@@ -18,7 +18,7 @@ class TC_ValidateUnique < Test::Unit::TestCase # :nodoc: all
18
18
  validate_unique :app_name
19
19
  end
20
20
 
21
- Og.setup($og_config)
21
+ $og1.manage_class Framework
22
22
 
23
23
  def setup
24
24
  @framework = Framework.new
@@ -1,81 +1,79 @@
1
- path = File.expand_path(File.dirname($0))
2
- $: << path + '/og/lib'
3
- $: << path + '/glue/lib'
1
+ require File.join(File.dirname(__FILE__), 'CONFIG.rb')
2
+
4
3
  require 'test/unit'
5
4
  require 'og'
6
5
 
7
6
  module UnitTestClasses
8
- class NoValidation
9
- property :prop, String
10
-
11
- def initialize(prop)
12
- @prop = prop
7
+ class NoValidation
8
+ property :prop, String
9
+
10
+ def initialize(prop)
11
+ @prop = prop
12
+ end
13
13
  end
14
- end
15
14
 
16
- class UniqueValidation < NoValidation
17
- property :slop, String
18
- validate_unique :prop, :slop
19
- end
15
+ class UniqueValidation < NoValidation
16
+ property :slop, String
17
+ validate_unique :prop, :slop
18
+ end
20
19
 
21
- class ValueValidation < NoValidation
22
- validate_value :prop
23
- end
20
+ class ValueValidation < NoValidation
21
+ validate_value :prop
22
+ end
24
23
 
25
- class ConfirmValidation < NoValidation
26
- validate_confirmation :prop
27
- end
24
+ class ConfirmValidation < NoValidation
25
+ validate_confirmation :prop
26
+ end
28
27
 
29
- class FormatValidation < NoValidation
30
- validate_format :prop, :format => /^\w\d\w-\d\w\d$/
31
- end
28
+ class FormatValidation < NoValidation
29
+ validate_format :prop, :format => /^\w\d\w-\d\w\d$/
30
+ end
32
31
 
33
- class MinValidation < NoValidation
34
- validate_length :prop, :min => 4
35
- end
32
+ class MinValidation < NoValidation
33
+ validate_length :prop, :min => 4
34
+ end
36
35
 
37
- class MaxValidation < NoValidation
38
- validate_length :prop, :max => 8
39
- end
36
+ class MaxValidation < NoValidation
37
+ validate_length :prop, :max => 8
38
+ end
40
39
 
41
- class RangeValidation < NoValidation
42
- validate_length :prop, :range => 10..20
43
- end
40
+ class RangeValidation < NoValidation
41
+ validate_length :prop, :range => 10..20
42
+ end
44
43
 
45
- class LengthValidation < NoValidation
46
- validate_length :prop, :length => 8
47
- end
44
+ class LengthValidation < NoValidation
45
+ validate_length :prop, :length => 8
46
+ end
48
47
 
49
- class InclusionValidation < NoValidation
50
- validate_inclusion :prop, :in => %w{ Male Female }
51
- end
48
+ class InclusionValidation < NoValidation
49
+ validate_inclusion :prop, :in => %w{ Male Female }
50
+ end
52
51
 
53
- class NumericValidation < NoValidation
54
- property :prop, Fixnum
55
- validate_numeric :prop, :integer => true
52
+ class NumericValidation < NoValidation
53
+ property :prop, Fixnum
54
+ validate_numeric :prop, :integer => true
56
55
 
57
- prop_accessor :prop2, Float
58
- validate_numeric :prop2
59
- end
56
+ prop_accessor :prop2, Float
57
+ validate_numeric :prop2
58
+ end
60
59
 
61
- class RelatedClass
62
- prop_accessor :test, String
63
- belongs_to :relation_validation, RelationValidation
64
- end
60
+ class RelatedClass
61
+ prop_accessor :test, String
62
+ belongs_to :relation_validation, RelationValidation
63
+ end
65
64
 
66
- class RelationValidation < NoValidation
67
- has_many :relations, RelatedClass
68
- validate_related :relations
69
- end
70
- end
65
+ class RelationValidation < NoValidation
66
+ has_many :relations, RelatedClass
67
+ validate_related :relations
68
+ end
71
69
 
72
- config = {
73
- :destroy => true,
74
- :store => :sqlite,
75
- :prop => 'dbtest_additions'
76
- }
70
+ $og1.manage_classes(NoValidation, UniqueValidation, ValueValidation,
71
+ ConfirmValidation, FormatValidation, MinValidation,
72
+ MaxValidation, RangeValidation, LengthValidation,
73
+ InclusionValidation, NumericValidation, RelatedClass,
74
+ RelationValidation)
77
75
 
78
- db = Og.setup(config)
76
+ end
79
77
 
80
78
  module Test::Unit::Assertions
81
79
  # Assert than an Og object is successfully saved and is error free.
@@ -1,3 +1,4 @@
1
+ =begin
1
2
  require 'test/unit'
2
3
 
3
4
  require 'rubygems'
@@ -10,8 +11,6 @@ class ManagedClass
10
11
  validate_unique :thing
11
12
  end
12
13
 
13
- Og.start
14
-
15
14
  class TC_Loop < Test::Unit::TestCase
16
15
  def setup
17
16
  @thing_1 = ManagedClass.new
@@ -28,9 +27,7 @@ class TC_Loop < Test::Unit::TestCase
28
27
  # }
29
28
  end
30
29
 
31
- def teardown
32
- ManagedClass.all.each { |i| i.delete }
33
- end
34
30
  end
35
31
 
36
32
  # * Bryan Soto <bryan.a.soto@gmail.com>
33
+ =end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: og
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.27.0
7
- date: 2006-01-16 00:00:00 +02:00
6
+ version: 0.28.0
7
+ date: 2006-02-06 00:00:00 +02:00
8
8
  summary: State of the art object-relational mapping system.
9
9
  require_paths:
10
10
  - lib
@@ -15,7 +15,7 @@ description:
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
18
- has_rdoc: true
18
+ has_rdoc: false
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
21
  - - ">"
@@ -63,6 +63,7 @@ files:
63
63
  - lib/og/errors.rb
64
64
  - lib/og/entity.rb
65
65
  - lib/og/collection.rb
66
+ - lib/og/ez
66
67
  - lib/og/markers.rb
67
68
  - lib/og/relation/many_to_many.rb
68
69
  - lib/og/relation/refers_to.rb
@@ -72,6 +73,7 @@ files:
72
73
  - lib/og/relation/belongs_to.rb
73
74
  - lib/og/relation/all.rb
74
75
  - lib/og/store/alpha
76
+ - lib/og/store/sqlite2.rb
75
77
  - lib/og/store/sqlite.rb
76
78
  - lib/og/store/sql.rb
77
79
  - lib/og/store/psql.rb
@@ -83,9 +85,10 @@ files:
83
85
  - lib/og/store/alpha/filesys.rb
84
86
  - lib/og/test/testcase.rb
85
87
  - lib/og/test/assertions.rb
86
- - lib/og/vendor/mysql411.rb
87
88
  - lib/og/vendor/mysql.rb
88
89
  - lib/og/vendor/README
90
+ - lib/og/ez/clause.rb
91
+ - lib/og/ez/condition.rb
89
92
  - lib/glue/taggable.rb
90
93
  - lib/glue/tree.rb
91
94
  - lib/glue/hierarchical.rb
@@ -94,6 +97,7 @@ files:
94
97
  - lib/glue/orderable.rb
95
98
  - lib/glue/optimistic_locking.rb
96
99
  - lib/glue/searchable.rb
100
+ - lib/glue/cacheable.rb
97
101
  - test/og
98
102
  - test/glue
99
103
  - test/og/mixin
@@ -108,7 +112,7 @@ files:
108
112
  - test/og/tc_polymorphic.rb
109
113
  - test/og/tc_multiple.rb
110
114
  - test/og/tc_join.rb
111
- - test/og/tc_validation2.rb
115
+ - test/og/tc_resolve.rb
112
116
  - test/og/tc_inheritance.rb
113
117
  - test/og/CONFIG.rb
114
118
  - test/og/tc_scoped.rb
@@ -116,8 +120,12 @@ files:
116
120
  - test/og/tc_validation.rb
117
121
  - test/og/tc_accumulator.rb
118
122
  - test/og/tc_inheritance2.rb
119
- - test/og/tc_multi_validations.rb
123
+ - test/og/tc_validation2.rb
120
124
  - test/og/tc_validation_loop.rb
125
+ - test/og/tc_cacheable.rb
126
+ - test/og/tc_multi_validations.rb
127
+ - test/og/multi_validations_model.rb
128
+ - test/og/tc_ez.rb
121
129
  - test/og/mixin/tc_timestamped.rb
122
130
  - test/og/mixin/tc_taggable.rb
123
131
  - test/og/mixin/tc_orderable.rb
@@ -146,5 +154,5 @@ dependencies:
146
154
  requirements:
147
155
  - - "="
148
156
  - !ruby/object:Gem::Version
149
- version: 0.27.0
157
+ version: 0.28.0
150
158
  version:
@@ -1,306 +0,0 @@
1
- #
2
- # mysq411.rb - 0.1 - Matt Mower <self@mattmower.com>
3
- #
4
- # The native Ruby MySQL client (mysql.rb) by Tomita Masahiro does not (yet) handle the new MySQL
5
- # protocol introduced in MySQL 4.1.1. This protocol introduces a new authentication scheme as
6
- # well as modifications to the client/server exchanges themselves.
7
- #
8
- # mysql411.rb modifies the Mysql class to add MySQL 4.1.x support. It modifies the connection
9
- # algorithm to detect a 4.1.1 server and respond with the new authentication scheme, otherwise using
10
- # the original one. Similarly for the changes to packet structures and field definitions, etc...
11
- #
12
- # It redefines serveral methods which behave differently depending upon the server context. The
13
- # way I have implemented this is to alias the old method, create a new alternative method, and redefine
14
- # the original method as a selector which calls the appropriate method based upon the server version.
15
- # There may have been a neater way to do this.
16
- #
17
- # In general I've tried not to change the original code any more than necessary, i.e. even where I
18
- # redefine a method I have made the smallest number of changes possible, rather than rewriting from
19
- # scratch.
20
- #
21
- # *Caveat Lector* This code passes all current ActiveRecord unit tests however this is no guarantee that
22
- # full & correct MySQL 4.1 support has been achieved.
23
- #
24
-
25
- require 'digest/sha1'
26
-
27
- #
28
- # Extend the Mysql class to work with MySQL 4.1.1+ servers. After version
29
- # 4.1.1 the password hashing function (and some other connection details) have
30
- # changed rendering the previous Mysql class unable to connect:
31
- #
32
- #
33
-
34
- class Mysql
35
- CLIENT_PROTOCOL_41 = 512
36
- CLIENT_SECURE_CONNECTION = 32768
37
-
38
- def real_connect( host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, flag=nil )
39
- @server_status = SERVER_STATUS_AUTOCOMMIT
40
-
41
- if( host == nil || host == "localhost" ) && defined? UNIXSocket
42
- unix_socket = socket || ENV["MYSQL_UNIX_PORT"] || MYSQL_UNIX_ADDR
43
- sock = UNIXSocket::new( unix_socket )
44
- @host_info = Error::err( Error::CR_LOCALHOST_CONNECTION )
45
- @unix_socket = unix_socket
46
- else
47
- sock = TCPSocket::new(host, port||ENV["MYSQL_TCP_PORT"]||(Socket::getservbyname("mysql","tcp") rescue MYSQL_PORT))
48
- @host_info = sprintf Error::err(Error::CR_TCP_CONNECTION), host
49
- end
50
-
51
- @host = host ? host.dup : nil
52
- sock.setsockopt Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true
53
- @net = Net::new sock
54
-
55
- a = read
56
-
57
- @protocol_version = a.slice!(0)
58
- @server_version, a = a.split(/\0/,2)
59
-
60
- # Store the version number components for speedy comparison
61
- version, ostag = @server_version.split( /-/, 2 )
62
- @major_ver, @minor_ver, @revision_num = version.split( /\./ ).map { |v| v.to_i }
63
-
64
- @thread_id, @scramble_buff = a.slice!(0,13).unpack("La8")
65
- if a.size >= 2 then
66
- @server_capabilities, = a.slice!(0,2).unpack("v")
67
- end
68
- if a.size >= 16 then
69
- @server_language, @server_status = a.unpack("cv")
70
- end
71
-
72
- # Set the flags we'll send back to the server
73
- flag = 0 if flag == nil
74
- flag |= @client_flag | CLIENT_CAPABILITIES
75
- flag |= CLIENT_CONNECT_WITH_DB if db
76
-
77
- if version_meets_minimum?( 4, 1, 1 )
78
- # In 4.1.1+ the seed comes in two parts which must be combined
79
- a.slice!( 0, 16 )
80
- seed_part_2 = a.slice!( 0, 12 );
81
- @scramble_buff << seed_part_2
82
-
83
- flag |= CLIENT_FOUND_ROWS
84
- flag |= CLIENT_PROTOCOL_41
85
- flag |= CLIENT_SECURE_CONNECTION if @server_capabilities & CLIENT_SECURE_CONNECTION;
86
-
87
- if db && @server_capabilities & CLIENT_CONNECT_WITH_DB != 0
88
- @db = db.dup
89
- end
90
-
91
- scrambled_password = scramble411( passwd, @scramble_buff, @protocol_version==9 )
92
- data = make_client_auth_packet_41( flag, user, scrambled_password, db )
93
- else
94
- scrambled_password = scramble( passwd, @scramble_buff, @protocol_version == 9 )
95
- data = Net::int2str(flag)+Net::int3str(@max_allowed_packet)+(user||"")+"\0"+scrambled_password
96
- if db and @server_capabilities & CLIENT_CONNECT_WITH_DB != 0 then
97
- data << "\0"+db
98
- @db = db.dup
99
- end
100
- end
101
-
102
- write data
103
- read
104
- self
105
- end
106
- alias :connect :real_connect
107
-
108
- # Pack the authentication information into depending upon whether an initial database has
109
- # been specified
110
- def make_client_auth_packet_41( flag, user, password, db )
111
- if db && @server_capabilities & CLIENT_CONNECT_WITH_DB != 0
112
- template = "VVcx23a#{user.size+1}cA#{password.size}a#{db.size+1}"
113
- else
114
- template = "VVcx23a#{user.size+1}cA#{password.size}x"
115
- end
116
-
117
- [ flag, @max_allowed_packet, @server_language, user, password.size, password, db ].pack( template )
118
- end
119
-
120
- def version_meets_minimum?( major, minor, revision )
121
- @major_ver >= major && @minor_ver >= minor && @revision_num >= revision
122
- end
123
-
124
- # SERVER: public_seed=create_random_string()
125
- # send(public_seed)
126
- #
127
- # CLIENT: recv(public_seed)
128
- # hash_stage1=sha1("password")
129
- # hash_stage2=sha1(hash_stage1)
130
- # reply=xor(hash_stage1, sha1(public_seed,hash_stage2)
131
- #
132
- # #this three steps are done in scramble()
133
- #
134
- # send(reply)
135
- #
136
- #
137
- # SERVER: recv(reply)
138
- # hash_stage1=xor(reply, sha1(public_seed,hash_stage2))
139
- # candidate_hash2=sha1(hash_stage1)
140
- # check(candidate_hash2==hash_stage2)
141
- def scramble411( password, seed, old_ver )
142
- return "" if password == nil or password == ""
143
- raise "old version password is not implemented" if old_ver
144
-
145
- # print "Seed Bytes = "
146
- # seed.each_byte { |b| print "0x#{b.to_s( 16 )}, " }
147
- # puts
148
-
149
- stage1 = Digest::SHA1.digest( password )
150
- stage2 = Digest::SHA1.digest( stage1 )
151
-
152
- dgst = Digest::SHA1.new
153
- dgst << seed
154
- dgst << stage2
155
- stage3 = dgst.digest
156
-
157
- # stage1.zip( stage3 ).map { |a, b| (a ^ b).chr }.join
158
- scrambled = ( 0 ... stage3.size ).map { |i| stage3[i] ^ stage1[i] }
159
- scrambled = scrambled.map { |x| x.chr }
160
- scrambled.join
161
- end
162
-
163
- def change_user(user="", passwd="", db="")
164
- scrambled_password = version_meets_minimum?( 4, 1, 1 ) ? scramble411( passwd, @scramble_buff, @protocol_version==9 ) : scramble( passwd, @scramble_buff, @protocol_version==9 )
165
- data = user+"\0"+scrambled_password+"\0"+db
166
- command COM_CHANGE_USER, data
167
- @user = user
168
- @passwd = passwd
169
- @db = db
170
- end
171
-
172
- #
173
- # The 4.1 protocol changed the length of the END packet
174
- #
175
- alias_method :old_read_one_row, :read_one_row
176
-
177
- def read_one_row( field_count )
178
- if version_meets_minimum?( 4, 1, 1 )
179
- read_one_row_41( field_count )
180
- else
181
- old_read_one_row( field_count )
182
- end
183
- end
184
-
185
- def read_one_row_41( field_count )
186
- data = read
187
- return if data[0] == 254 and data.length < 9
188
- rec = []
189
- field_count.times do
190
- len = get_length data
191
- if len == nil then
192
- rec << len
193
- else
194
- rec << data.slice!(0,len)
195
- end
196
- end
197
- rec
198
- end
199
-
200
- #
201
- # The 4.1 protocol changed the length of the END packet
202
- #
203
- alias_method :old_skip_result, :skip_result
204
-
205
- def skip_result
206
- if version_meets_minimum?( 4, 1, 1 )
207
- skip_result_41
208
- else
209
- old_skip_result
210
- end
211
- end
212
-
213
- def skip_result_41()
214
- if @status == :STATUS_USE_RESULT then
215
- loop do
216
- data = read
217
- break if data[0] == 254 and data.length == 1
218
- end
219
- @status = :STATUS_READY
220
- end
221
- end
222
-
223
- # The field description structure is changed for the 4.1 protocol passing
224
- # more data and a different packing form. NOTE: The 4.1 protocol now passes
225
- # back a "catalog" name for each field which is a new feature. Since AR has
226
- # nowhere to put it I'm throwing it away. Possibly this is not the best
227
- # idea?
228
- #
229
- alias_method :old_unpack_fields, :unpack_fields
230
-
231
- def unpack_fields( data, long_flag_protocol )
232
- if version_meets_minimum?( 4, 1, 1 )
233
- unpack_fields_41( data, long_flag_protocol )
234
- else
235
- old_unpack_fields( data, long_flag_protocol )
236
- end
237
- end
238
-
239
- def unpack_fields_41( data, long_flag_protocol )
240
- ret = []
241
-
242
- data.each do |f|
243
- catalog_name = f[0]
244
- database_name = f[1]
245
- table_name_alias = f[2]
246
- table_name = f[3]
247
- column_name_alias = f[4]
248
- column_name = f[5]
249
-
250
- charset = f[6][0] + f[6][1]*256
251
- length = f[6][2] + f[6][3]*256 + f[6][4]*256*256 + f[6][5]*256*256*256
252
- type = f[6][6]
253
- flags = f[6][7] + f[6][8]*256
254
- decimals = f[6][9]
255
- def_value = f[7]
256
- max_length = 0
257
-
258
- ret << Field::new(table_name, table_name, column_name_alias, length, type, flags, decimals, def_value, max_length)
259
- end
260
- ret
261
- end
262
-
263
- # In this instance the read_query_result method in mysql is bound to read 5 field parameters which
264
- # is expanded to 7 in the 4.1 protocol. So in this case we redefine this entire method in order
265
- # to write "read_rows 7" instead of "read_rows 5"!
266
- #
267
- alias_method :old_read_query_result, :read_query_result
268
-
269
- def read_query_result
270
- if version_meets_minimum?( 4, 1, 1 )
271
- read_query_result_41
272
- else
273
- old_read_query_result
274
- end
275
- end
276
-
277
- def read_query_result_41
278
- data = read
279
- @field_count = get_length(data)
280
- if @field_count == nil then # LOAD DATA LOCAL INFILE
281
- File::open(data) do |f|
282
- write f.read
283
- end
284
- write "" # mark EOF
285
- data = read
286
- @field_count = get_length(data)
287
- end
288
- if @field_count == 0 then
289
- @affected_rows = get_length(data, true)
290
- @insert_id = get_length(data, true)
291
- if @server_capabilities & CLIENT_TRANSACTIONS != 0 then
292
- a = data.slice!(0,2)
293
- @server_status = a[0]+a[1]*256
294
- end
295
- if data.size > 0 and get_length(data) then
296
- @info = data
297
- end
298
- else
299
- @extra_info = get_length(data, true)
300
- fields = read_rows 7
301
- @fields = unpack_fields(fields, @server_capabilities & CLIENT_LONG_FLAG != 0)
302
- @status = :STATUS_GET_RESULT
303
- end
304
- self
305
- end
306
- end