Skip to content

Commit b3846f6

Browse files
committed
Raise exception for update by an absent field name
It seems the exception "No field '<...>' defined" was not raised since introducing of named fields support in 31cf8a8 ('Next version of tarantool-php for php7'). There is the test for this case (DMLTest::test_08_update_error_nosuchfield), but it accepts any error message, because of a typo in an annotation name. Fixed this typo. The problem was found by this test when the annotation was replaced by a call in order to eliminate a phpunit-8 warning and to support phpunit-9. This change will land in a next commit.
1 parent f913c46 commit b3846f6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/tarantool.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,10 @@ int get_fieldno_by_name(tarantool_connection *obj, uint32_t space_no,
795795
fid = tarantool_schema_get_fid_by_string(obj->schema, space_no,
796796
Z_STRVAL_P(name),
797797
Z_STRLEN_P(name));
798-
if (fid == FAILURE)
798+
if (fid == FAILURE) {
799799
THROW_EXC("No field '%s' defined", Z_STRVAL_P(name));
800+
return FAILURE;
801+
}
800802
return fid + 1;
801803
}
802804

@@ -825,6 +827,8 @@ int tarantool_uwrite_op(tarantool_connection *obj, zval *op, uint32_t pos,
825827
goto cleanup;
826828
}
827829
op_pos = get_fieldno_by_name(obj, space_id, z_op_pos);
830+
if (op_pos == FAILURE)
831+
goto cleanup;
828832
zval *oparg, *splice_len, *splice_val;
829833
switch(Z_STRVAL_P(opstr)[0]) {
830834
case ':':

test/DMLTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function test_07_update_no_error() {
172172

173173
/**
174174
* @expectedException TarantoolException
175-
* @ExpectedExceptionMessage No field 'nosuchfield' defined
175+
* @expectedExceptionMessage No field 'nosuchfield' defined
176176
*/
177177
public function test_08_update_error_nosuchfield() {
178178
self::$tarantool->update("test", 0, array(
@@ -185,7 +185,7 @@ public function test_08_update_error_nosuchfield() {
185185

186186
/**
187187
* @expectedException TarantoolException
188-
* @ExpectedExceptionMessage Five fields
188+
* @expectedExceptionMessage Five fields
189189
*/
190190
public function test_08_update_error() {
191191
self::$tarantool->update("test", 0, array(
@@ -200,7 +200,7 @@ public function test_08_update_error() {
200200

201201
/**
202202
* @expectedException TarantoolException
203-
* @ExpectedExceptionMessage Field OP must be provided
203+
* @expectedExceptionMessage Field OP must be provided
204204
*/
205205
public function test_09_update_error() {
206206
self::$tarantool->update("test", 0, array(
@@ -214,7 +214,7 @@ public function test_09_update_error() {
214214

215215
/**
216216
* @expectedException TarantoolException
217-
* @ExpectedExceptionMessage Field OP must be provided
217+
* @expectedExceptionMessage Field OP must be provided
218218
*/
219219
public function test_10_update_error() {
220220
self::$tarantool->update("test", 0, array(
@@ -227,7 +227,7 @@ public function test_10_update_error() {
227227

228228
/**
229229
* @expectedException TarantoolException
230-
* @ExpectedExceptionMessage Three fields must be provided
230+
* @expectedExceptionMessage Three fields must be provided
231231
*/
232232
public function test_11_update_error() {
233233
self::$tarantool->update("test", 0,

0 commit comments

Comments
 (0)