Skip to content

Commit 08ea20c

Browse files
committed
1 parent 842733b commit 08ea20c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

ext-src/swoole_table.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ static inline void php_swoole_table_get_field_value(
5959
} else if (col->type == TableColumn::TYPE_FLOAT) {
6060
double dval = 0;
6161
row->get_value(col, &dval);
62-
add_assoc_double_ex(return_value, col->name.c_str(), col->name.length(), dval);
6362
ZVAL_DOUBLE(return_value, dval);
6463
} else if (col->type == TableColumn::TYPE_INT) {
6564
long lval = 0;

tests/swoole_table/key_value.phpt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ swoole_table: key-value operate
66
<?php
77
require __DIR__ . '/../include/bootstrap.php';
88

9+
const PI = 3.1415926;
10+
const NAME = 'rango';
11+
912
$table = new swoole_table(65536);
1013

1114
$table->column('id', swoole_table::TYPE_INT);
@@ -16,7 +19,7 @@ if (!$table->create())
1619
{
1720
echo __LINE__." error";
1821
}
19-
if (!$table->set('test_key', array('id' => 1, 'name' => 'rango', 'num' => 3.1415926)))
22+
if (!$table->set('test_key', array('id' => 1, 'name' => NAME, 'num' =>PI)))
2023
{
2124
echo __LINE__." error";
2225
}
@@ -33,6 +36,13 @@ if (!($ret and $ret == 1))
3336
echo __LINE__." error";
3437
}
3538

39+
Assert::eq($table->get('test_key', 'name'), NAME);
40+
Assert::eq($table->get('test_key', 'num'), PI);
41+
42+
// field not exists
43+
Assert::false($table->get('test_key', 'id_no_exists'));
44+
Assert::false($table->get('test_key_no_exists', 'id_no_exists'));
45+
3646
$ret = $table->exist('test_key');
3747
if (!($ret))
3848
{
@@ -82,7 +92,7 @@ if ($table->exist('test_key'))
8292
{
8393
echo __LINE__." error";
8494
}
85-
echo "SUCCESS";
95+
echo "SUCCESS\n";
8696
?>
8797
--EXPECT--
8898
SUCCESS

0 commit comments

Comments
 (0)