Skip to content

Commit

Permalink
[fix] regex with pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
catfan committed Oct 31, 2024
1 parent b5533da commit 7775795
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ protected function columnMap($columns, array &$stack, bool $root): array

foreach ($columns as $key => $value) {
if (is_int($key)) {
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);
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);

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

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

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

foreach ($data as $item) {
Expand Down

0 comments on commit 7775795

Please sign in to comment.