Skip to content

Commit

Permalink
Monolog is not used by this project (#30)
Browse files Browse the repository at this point in the history
* Monolog is not used by this project

* Added support for some other primitive data types from OData 2.0 specs
  • Loading branch information
madalindk authored and anderly committed May 15, 2019
1 parent e6eca03 commit 05accef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"require": {
"php": ">=7.1",
"guzzlehttp/guzzle": "^6.2",
"monolog/monolog": "^1.22",
"nesbot/carbon": "^1.22",
"illuminate/support": "^5.4"
},
Expand Down
10 changes: 7 additions & 3 deletions src/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ protected function whereBasic(Builder $query, $where)
//$value = $this->parameter($where['value']);
$value = $where['value'];

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

protected function isSpecialPrimitiveDataType($value){
return preg_match("/^(binary|datetime|guid|time|datetimeoffset)(\'[\w\:\-\.]+\')$/i", $value);
}

/**
* Compile the "order by" portions of the query.
*
Expand Down

0 comments on commit 05accef

Please sign in to comment.