Skip to content

Commit

Permalink
[fix] equal operator for columns relationship #1014.
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelaon committed Sep 17, 2021
1 parent 96c66ae commit 6f9a6c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ protected function dataImplode(array $data, array &$map, string $conjunctor): st
$isIndex = is_int($key);

preg_match(
'/([\p{L}_][\p{L}\p{N}@$#\-_\.]*)(\[(?<operator>\>\=?|\<\=?|\!|\<\>|\>\<|\!?~|REGEXP)\])?([\p{L}_][\p{L}\p{N}@$#\-_\.]*)?/u',
'/([\p{L}_][\p{L}\p{N}@$#\-_\.]*)(\[(?<operator>\>\=?|\<\=?|\=|\!\=?|\<\>|\>\<|\!?~|REGEXP)\])?([\p{L}_][\p{L}\p{N}@$#\-_\.]*)?/u',
$isIndex ? $value : $key,
$match
);
Expand Down
7 changes: 5 additions & 2 deletions tests/WhereTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ public function testColumnsRelationshipWhere($type)
], [
"post.content"
], [
"post.restrict[<]account.age"
"post.restrict[<]account.age",
"post.type[=]account.type"
]);

$this->assertQuery(
Expand All @@ -444,7 +445,9 @@ public function testColumnsRelationshipWhere($type)
FROM "post"
LEFT JOIN "account"
USING ("user_id")
WHERE "post"."restrict" < "account"."age"
WHERE
"post"."restrict" < "account"."age" AND
"post"."type" = "account"."type"
EOD,
$this->database->queryString
);
Expand Down

0 comments on commit 6f9a6c6

Please sign in to comment.