Skip to content

Commit 7775795

Browse files
committedOct 31, 2024·
[fix] regex with pattern
1 parent b5533da commit 7775795

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎src/Medoo.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ protected function columnMap($columns, array &$stack, bool $root): array
13791379

13801380
foreach ($columns as $key => $value) {
13811381
if (is_int($key)) {
1382-
preg_match("/(" . $this::TABLE_PATTERN . ")?(?<column>" . $this::COLUMN_PATTERN . ")(?:\s*\((?<alias>" . $this::ALIAS_PATTERN . ")\))?(?:\s*\[(?<type>(?:String|Bool|Int|Number|Object|JSON))\])?/u", $value, $keyMatch);
1382+
preg_match("/(" . $this::TABLE_PATTERN . "\.)?(?<column>" . $this::COLUMN_PATTERN . ")(?:\s*\((?<alias>" . $this::ALIAS_PATTERN . ")\))?(?:\s*\[(?<type>(?:String|Bool|Int|Number|Object|JSON))\])?/u", $value, $keyMatch);
13831383

13841384
$columnKey = !empty($keyMatch['alias']) ?
13851385
$keyMatch['alias'] :
@@ -1389,7 +1389,7 @@ protected function columnMap($columns, array &$stack, bool $root): array
13891389
[$columnKey, $keyMatch['type']] :
13901390
[$columnKey];
13911391
} elseif ($this->isRaw($value)) {
1392-
preg_match("/(" . $this::TABLE_PATTERN . ")?(?<column>" . $this::COLUMN_PATTERN . ")(\s*\[(?<type>(String|Bool|Int|Number))\])?/u", $key, $keyMatch);
1392+
preg_match("/(" . $this::TABLE_PATTERN . "\.)?(?<column>" . $this::COLUMN_PATTERN . ")(\s*\[(?<type>(String|Bool|Int|Number))\])?/u", $key, $keyMatch);
13931393
$columnKey = $keyMatch['column'];
13941394

13951395
$stack[$key] = isset($keyMatch['type']) ?
@@ -1432,7 +1432,7 @@ protected function dataMap(
14321432

14331433
if (count($columnsKey) === 1 && is_array($columns[$columnsKey[0]])) {
14341434
$indexKey = array_keys($columns)[0];
1435-
$dataKey = preg_replace("/^[\p{L}_][\p{L}\p{N}@$#\-_]*\./u", '', $indexKey);
1435+
$dataKey = preg_replace("/^" . $this::COLUMN_PATTERN . "\./u", '', $indexKey);
14361436
$currentStack = [];
14371437

14381438
foreach ($data as $item) {

0 commit comments

Comments
 (0)
Please sign in to comment.