8000 update limit默认值为10 && 子查询不支持limit设为0 && 子查询判断IN处理 && 引入声明判断过滤 && 修改测试用例 · APIJSON/hyperf-APIJSON@a6cbae7 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6cbae7

Browse files
committed
update limit默认值为10 && 子查询不支持limit设为0 && 子查询判断IN处理 && 引入声明判断过滤 && 修改测试用例
1 parent 9701daa commit a6cbae7

File tree

5 files changed

+136
-244
lines changed

5 files changed

+136
-244
lines changed

app/ApiJson/Entity/ConditionEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ConditionEntity
1111
*/
1212
protected array $where = [];
1313

14-
protected int $limit = 0;
14+
protected int $limit = 10;
1515
protected int $offset = 0;
1616
protected array $column = ['*'];
1717
protected array $group = [];

app/ApiJson/Handle/AbstractHandle.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ protected function subTableQuery(array $data): QueryInterface
6565
{
6666
$tableName = $data['from'];
6767
$tableEntity = new TableEntity($tableName, $data);
68-
$handle = new Handle($tableEntity->getConditionEntity(), $tableEntity);
68+
$conditionEntity = $tableEntity->getConditionEntity();
69+
$conditionEntity->setLimit(0);
70+
$handle = new Handle($conditionEntity, $tableEntity);
6971
$handle->build();
7072
/** @var QueryInterface $query */
7173
return new (ApplicationContext::getContainer()->get(ConfigInterface::class)->get(QueryInterface::class))($tableEntity->getRealTableName(), $tableEntity->getConditionEntity());

app/ApiJson/Handle/WhereSubQueryHandle.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ protected function buildModel()
1212
{
1313
$query = $this->subTableQuery($value);
1414

15-
$op = '=';
15+
$op = ' = ';
1616
if(str_ends_with($key, '>=@')) {
17-
$op = '>=';
17+
$op = ' >= ';
1818
} else if(str_ends_with($key, '<=@')) {
19-
$op = '<=';
19+
$op = ' <= ';
2020
} else if(str_ends_with($key, '>@')) {
21-
$op = '>';
21+
$op = ' > ';
2222
} else if(str_ends_with($key, '<@')) {
23-
$op = '<';
23+
$op = ' < ';
24+
} else if(str_ends_with($key, '{}@')) {
25+
$op = ' IN ';
2426
}
2527
$sql = sprintf('`%s`%s(%s)', $this->sanitizeKey($key), $op, $query->toSql());
2628
$this->condition->addQueryWhere($key, $sql, $query->getBindings());

app/ApiJson/Replace/QuoteReplace.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ protected function process()
99
$condition = $this->condition->getCondition();
1010

1111
foreach (array_filter($condition, function($key){
12-
return str_ends_with($key, '@') && !str_ends_with($key, '}{@');
12+
return str_ends_with($key, '@') && !str_ends_with($key, '}{@') && !str_ends_with($key, '{}@');
1313
}, ARRAY_FILTER_USE_KEY) as $key => $value)
1414
{
15+
if (!is_string($value)) continue;
1516
$path = str_replace(['/', '[]'], ['.', 'currentItem'], $value);
1617
if (str_starts_with($path, '.')) {
1718
$path = 'currentItem' . $path;

0 commit comments

Comments
 (0)
0