Skip to content

Commit 05accef

Browse files
madalindkanderly
authored andcommitted
Monolog is not used by this project (#30)
* Monolog is not used by this project * Added support for some other primitive data types from OData 2.0 specs
1 parent e6eca03 commit 05accef

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"require": {
1616
"php": ">=7.1",
1717
"guzzlehttp/guzzle": "^6.2",
18-
"monolog/monolog": "^1.22",
1918
"nesbot/carbon": "^1.22",
2019
"illuminate/support": "^5.4"
2120
},

src/Query/Grammar.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ protected function whereBasic(Builder $query, $where)
285285
//$value = $this->parameter($where['value']);
286286
$value = $where['value'];
287287

288-
// stringify all values if it has NOT an odata enum syntax
289-
// (ex. Microsoft.OData.SampleService.Models.TripPin.PersonGender'Female')
290-
if (!preg_match("/^([\w]+\.)+([\w]+)(\'[\w]+\')$/", $value)) {
288+
// stringify all values if it has NOT an odata enum or special syntax primitive data type
289+
// (ex. Microsoft.OData.SampleService.Models.TripPin.PersonGender'Female' or datetime'1970-01-01T00:00:00')
290+
if (!preg_match("/^([\w]+\.)+([\w]+)(\'[\w]+\')$/", $value) && !$this->isSpecialPrimitiveDataType($value)) {
291291
// Check if the value is a string and NOT a date
292292
if (is_string($value) && !\DateTime::createFromFormat('Y-m-d\TH:i:sT', $value)) {
293293
$value = "'".$where['value']."'";
@@ -297,6 +297,10 @@ protected function whereBasic(Builder $query, $where)
297297
return $where['column'].' '.$this->getOperatorMapping($where['operator']).' '.$value;
298298
}
299299

300+
protected function isSpecialPrimitiveDataType($value){
301+
return preg_match("/^(binary|datetime|guid|time|datetimeoffset)(\'[\w\:\-\.]+\')$/i", $value);
302+
}
303+
300304
/**
301305
* Compile the "order by" portions of the query.
302306
*

0 commit comments

Comments
 (0)