Skip to content

Commit 3b806d7

Browse files
author
Elizaveta Dokshina
committed
Get rid of cont_pairs
1 parent e7a6356 commit 3b806d7

File tree

13 files changed

+386
-681
lines changed

13 files changed

+386
-681
lines changed

crud/common/state.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
local checks = require('checks')
21
local uuid = require('uuid')
32

43
local state = {}
54

6-
local operations = {}
5+
local states = {}
76

87
function state.get(id)
9-
checks('?string')
108
id = id or uuid.str()
11-
local op_state = operations[id]
9+
local op_state = states[id]
1210
if op_state == nil then
13-
op_state = {}
14-
op_state.id = id
15-
operations[op_state.id] = op_state
11+
op_state = { id = id }
12+
states[id] = op_state
1613
end
1714
return op_state
1815
end
1916

2017
function state.clear(id)
21-
checks('string')
22-
operations[id] = nil
18+
assert(id ~= nil)
19+
states[id] = nil
2320
return true
2421
end
2522

crud/common/utils.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,22 @@ function utils.extract_key(tuple, key_parts)
8181
return key
8282
end
8383

84+
function utils.merge_primary_key_parts(key_parts, pk_parts)
85+
local merged_parts = {}
86+
local key_fieldnos = {}
87+
88+
for _, part in ipairs(key_parts) do
89+
table.insert(merged_parts, part)
90+
key_fieldnos[part.fieldno] = true
91+
end
92+
93+
for _, pk_part in ipairs(pk_parts) do
94+
if not key_fieldnos[pk_part.fieldno] then
95+
table.insert(merged_parts, pk_part)
96+
end
97+
end
98+
99+
return merged_parts
100+
end
101+
84102
return utils

crud/cont_pairs/1x.lua

Lines changed: 0 additions & 135 deletions
This file was deleted.

0 commit comments

Comments
 (0)