Skip to content

Commit 4fe261d

Browse files
author
enricodelazzari
committed
FIX json_extract param
1 parent 2a519e1 commit 4fe261d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Utils/AttributeUtil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public static function formatJsonOperator(Model $model, string $attributeName, s
117117
return "$attributeName->>'$jsonKey'";
118118
}
119119

120-
return "JSON_UNQUOTE(JSON_EXTRACT($attributeName, '$.$jsonKey'))";
120+
return "JSON_UNQUOTE(JSON_EXTRACT($attributeName, '$.\"$jsonKey\"'))";
121121
}
122122

123123
/**

tests/Utils/AttributeUtilTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function it_should_return_the_unquoted_extraction_of_the_attribute_name_i
118118

119119
$result = AttributeUtil::formatJsonOperator($model, $attributeName, $jsonKey);
120120

121-
$this->assertEquals("JSON_UNQUOTE(JSON_EXTRACT($attributeName, '$.$jsonKey'))", $result);
121+
$this->assertEquals("JSON_UNQUOTE(JSON_EXTRACT($attributeName, '$.\"$jsonKey\"'))", $result);
122122
}
123123

124124
/** @test */
@@ -168,7 +168,7 @@ public function it_should_return_the_first_non_null_value_in_a_list_with_the_spe
168168

169169
$result = AttributeUtil::formatAttribute($model, $attribute);
170170

171-
$this->assertEquals("COALESCE(JSON_UNQUOTE(JSON_EXTRACT(users.description, '$.*')),'')", $result);
171+
$this->assertEquals("COALESCE(JSON_UNQUOTE(JSON_EXTRACT(users.description, '$.\"*\"')),'')", $result);
172172
}
173173

174174
/** @test */

0 commit comments

Comments
 (0)