Skip to content

Commit 4ea642c

Browse files
committed
#63 - fixed
1 parent d5c76c6 commit 4ea642c

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

src/tp_transcode.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ yajl_map_key(void *ctx, const unsigned char * key, size_t len)
379379
if (unlikely(!tp_call_wof(&s_ctx->tp)))
380380
say_overflow_r_2(s_ctx);
381381

382-
/** Set method binded to this transcoding
382+
/** Set the method to this transcoding
383383
*/
384384
if (!s_ctx->read_method) {
385385
tp_transcode_t *tc = s_ctx->tc;
@@ -488,12 +488,14 @@ yajl_end_map(void *ctx)
488488

489489
if (s_ctx->size == 0) {
490490

491-
if (unlikely(!tp_call_wof_add_params(&s_ctx->tp)))
492-
say_overflow_r_2(s_ctx);
493-
494491
if (!(s_ctx->been_stages & PARAMS)) {
492+
dd("ADDING EMPTY PARAMS\n");
493+
494+
if (unlikely(!tp_call_wof_add_params(&s_ctx->tp)))
495+
say_overflow_r_2(s_ctx);
495496

496-
if (s_ctx->tc->data.pos && s_ctx->tc->data.len) {
497+
if (s_ctx->tc->data.pos && s_ctx->tc->data.len
498+
/*has data to bind*/) {
497499
tp_encode_array(&s_ctx->tp, 1);
498500
if (unlikely(!bind_data(s_ctx)))
499501
say_overflow_r_2(s_ctx);
@@ -548,7 +550,7 @@ yajl_start_array(void *ctx)
548550

549551
stack_grow_array(s_ctx);
550552

551-
bool push_ok = false, bind_first_argument = true;
553+
bool push_ok = false, bind_first_argument = false;
552554
if (unlikely(s_ctx->size == 0)) {
553555
push_ok = stack_push(s_ctx, s_ctx->tp.p, TYPE_ARRAY | PARAMS);
554556
bind_first_argument = true;
@@ -565,9 +567,11 @@ yajl_start_array(void *ctx)
565567

566568
tp_add(&s_ctx->tp, 1 + sizeof(uint32_t));
567569

568-
// Binding data [
569-
if (unlikely(bind_first_argument)) {
570-
if (!bind_data(s_ctx))
570+
// Here is bind data
571+
// e.g. http request
572+
// [
573+
if (bind_first_argument) {
574+
if (unlikely(!bind_data(s_ctx)))
571575
say_overflow_r_2(s_ctx);
572576
}
573577
// ]
@@ -588,19 +592,20 @@ yajl_end_array(void *ctx)
588592

589593
dd("array close, count %d ']'\n", item->count);
590594

595+
size_t item_count = item->count;
591596
if (unlikely(item->type & PARAMS)) {
592597
dd("PARAMS END\n");
593598
s_ctx->stage = WAIT_NEXT;
594599
s_ctx->been_stages |= PARAMS;
595600
// Increase number of args for binded data [
596601
tp_transcode_t *tc = s_ctx->tc;
597602
if (tc->data.pos && tc->data.len)
598-
++item->count;
603+
++item_count;
599604
// ]
600605
}
601606

602607
*(item->ptr++) = 0xdd;
603-
*(uint32_t *) item->ptr = mp_bswap_u32(item->count);
608+
*(uint32_t *) item->ptr = mp_bswap_u32(item_count);
604609

605610
} else {
606611
say_wrong_params(s_ctx);

test/test.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ box.cfg {
4343
wal_mode = 'none';
4444
}
4545

46-
if not box.space.tester then
46+
box.once('gr', function()
4747
box.schema.user.grant('guest', 'read,write,execute', 'universe')
48-
box.schema.create_space('tester')
49-
end
48+
end)
5049

5150
-- BUG -- https://github.com/tarantool/nginx_upstream_module/issues/37 [[
5251
function read(http_request_full)
@@ -103,7 +102,7 @@ function delete(request, a1, a2)
103102
end
104103

105104
function insert(request, a1, a2)
106-
return request
105+
return { request, a1, a2 }
107106
end
108107

109108
function update(request)

test/v23_features.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,21 @@
145145
delete_success(preset_method_location, {'params':[]}, None)
146146
result = delete_success(preset_method_location, None, None)
147147

148-
preset_method_location = BASE_URL + '/issue_58'
149-
150148
(rc, result) = request(preset_method_location, [{'id': 1}, {'id': 2}])
151149
assert(result[0]['id'] == 1), 'expected id = 1'
152150
assert(result[1]['id'] == 2), 'expected id = 2'
151+
152+
data = {"id":0,"params":[
153+
{
154+
"soc":"68ALLNVS2",
155+
"product_number":2355574,
156+
"description":"sd",
157+
"business_types":["B2C"],
158+
"product_spec_characteristic_values":{
159+
"asd":{"value":"1123asda"}
160+
}
161+
}
162+
]
163+
}
164+
result = put_success(preset_method_location, data, None)
165+
assert(result[1] == data['params'][0]), 'result != data'

0 commit comments

Comments
 (0)