Closed kokizzu closed 3 months ago
code that previously works on v1 now no longer works on v2 (tested on tarantool 2.11 and 3.1)
previously Replace method on v1 was written like this:
Replace
v1
row, err := o.Adapter.Replace(o.SpaceName(), arr)
since v2, it became:
v2
row, err := u.Adapter.Connection.Do( tarantool.NewReplaceRequest(u.SpaceName()). Tuple(arr), ).Get()
that "users" table have unique index "email" and primary key "id"
box.space.users --- - engine: memtx before_replace: 'function: 0x7f0e9ec1d5e8' field_count: 0 is_sync: false is_local: false on_replace: 'function: 0x7f0e9ec1d5b0' temporary: false index: 0: &0 parts: - fieldno: 1 sort_order: asc type: unsigned exclude_null: false is_nullable: false sequence_id: 3 id: 0 space_id: 514 unique: true hint: true type: TREE name: id sequence_fieldno: 1 1: &1 unique: true parts: - fieldno: 2 sort_order: asc type: string exclude_null: false is_nullable: false hint: true id: 1 type: TREE space_id: 514 name: email email: *1 id: *0 type: normal enabled: true name: users id: 514 ...
now it gives:
ExtendedInfo: &tarantool.BoxError{ Type: "ClientError", File: "./src/box/memtx_tree.cc", Line: 0x48e, Msg: "Duplicate key exists in unique index \"email\" in space \"users\" with old tuple - [1, \"x@gmail.com\", \"$2a$10$ovBIy3zppEEnoj65UvRta.b5hbDIj2stFPctrrXxjwjZLOtAf44B6\", 1717101624, 0, 1717101624, 0, 0, 1717101624, \"OeUYV----07OikXT2tICF\", 0, 0, 0, 0, \"\", \"\", \"\", \"\"] and new tuple - [1, \"x@gmail.com\", \"$2a$10$ovBIy3zppEEnoj65UvRta.b5hbDIj2stFPctrrXxjwjZLOtAf44B6\", 1717101624, 0, 1717103073, 0, 0, 1717101624, \"OeUYV----07OikXT2tICF\", 0, 0, 0, 1717103073, \"\", \"\", \"\", \"\"]", Errno: 0x0, Code: 0x3, Fields: { "index": "email", "name": "TUPLE_FOUND", "new_tuple": []interface {}{ uint64(0x1), "x@gmail.com", "$2a$10$ovBIy3zppEEnoj65UvRta.b5hbDIj2stFPctrrXxjwjZLOtAf44B6", int64(1717101624), uint64(0x0), int64(1717103073), uint64(0x0), int64(0), int64(1717101624), "OeUYV----07OikXT2tICF", int64(0), int64(0), int64(0), int64(1717103073), "", "", "", "", }, "old_tuple": []interface {}{ int8(1), "x@gmail.com", "$2a$10$ovBIy3zppEEnoj65UvRta.b5hbDIj2stFPctrrXxjwjZLOtAf44B6", int64(1717101624), uint64(0x0), int64(1717101624), uint64(0x0), int64(0), int64(1717101624), "OeUYV----07OikXT2tICF", int64(0), int64(0), int64(0), int64(0), "", "", "", "", }, "space": "users", }, Prev: (*tarantool.BoxError)(nil), },
current content of that table:
SET SESSION "sql_seq_scan" = true; --- - row_count: 1 ... SELECT * FROM "users"; --- - metadata: - name: id type: unsigned - name: email type: string - name: password type: string - name: createdAt type: integer - name: createdBy type: unsigned - name: updatedAt type: integer - name: updatedBy type: unsigned - name: deletedAt type: integer - name: passwordSetAt type: integer - name: secretCode type: string - name: secretCodeAt type: integer - name: verificationSentAt type: integer - name: verifiedAt type: integer - name: lastLoginAt type: integer - name: fullName type: string - name: tenantCode type: string - name: role type: string - name: invitationState type: string rows: - [1, 'x@gmail.com', '$2a$10$ovBIy3zppEEnoj65UvRta.b5hbDIj2stFPctrrXxjwjZLOtAf44B6', -8, 0, -8, 0, -32, -8, 'OeUYV----07OikXT2tICF', -32, -32, -32, -32, '', '', '', ''] ...
apparently that's expected https://github.com/tarantool/tarantool/issues/5732
code that previously works on v1 now no longer works on v2 (tested on tarantool 2.11 and 3.1)
previously
Replace
method onv1
was written like this:since
v2
, it became:that "users" table have unique index "email" and primary key "id"
now it gives:
current content of that table: