Skip to content

Commit

Permalink
Backward incompatible!!! tarantool changes inserted/deleted fields
Browse files Browse the repository at this point in the history
make tests pass
  • Loading branch information
funny-falcon committed Mar 26, 2014
1 parent 3bb8d00 commit 0293950
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/tarantool/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def _pack_operations(body, operations, fields)
op = operation[1]
op = UPDATE_OPS[op] unless Integer === op
raise ArgumentError, "Unknown operation #{operation[1]}" unless op
::BinUtils.append_int32_int8_le!(body, field_no, op)
case op
when 0
::BinUtils.append_int32_int8_le!(body, field_no, op)
if (type = fields[field_no]).nil?
if operation.size == 4 && Symbol === operation.last
*operation, type = operation
Expand All @@ -268,11 +268,13 @@ def _pack_operations(body, operations, fields)
end
pack_field(body, type, operation[2])
when 1, 2, 3, 4
::BinUtils.append_int32_int8_le!(body, field_no, op)
unless operation.size == 3 && !operation[2].nil?
raise ArgumentError, "wrong arguments for integer operation #{operation.inspect}"
end
pack_field(body, :sint, operation[2])
when 5
::BinUtils.append_int32_int8_le!(body, field_no, op)
unless operation.size == 5 && !operation[2].nil? && !operation[3].nil?
raise ArgumentError, "wrong arguments for slice operation #{operation.inspect}"
end
Expand All @@ -283,9 +285,10 @@ def _pack_operations(body, operations, fields)
::BinUtils.append_bersize_int32_le!(body, operation[3].to_i)
::BinUtils.append_bersize_string!(body, str.to_s)
when 7
old_field_no = field_no +
old_field_no = field_no +
(inserted ||= []).count{|i| i <= field_no} -
(deleted ||= []).count{|i| i <= field_no}
::BinUtils.append_int32_int8_le!(body, old_field_no, op)
inserted << field_no
if (type = fields[old_field_no]).nil?
if operation.size == 4 && Symbol === operation.last
Expand All @@ -299,6 +302,11 @@ def _pack_operations(body, operations, fields)
end
pack_field(body, type, operation[2])
when 6
old_field_no = field_no +
(inserted ||= []).count{|i| i <= field_no} -
(deleted ||= []).count{|i| i <= field_no}
::BinUtils.append_int32_int8_le!(body, old_field_no, op)
deleted << field_no
body << ZERO
# pass
end
Expand Down

0 comments on commit 0293950

Please sign in to comment.