Closed
Description
I'm using a REST api and have been successful filtering by string and decimals etc.
But when filtering a guid column I get a 400 Bad Response
with the following error:
A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'.
I'm currently filtering like this:
$item = $odataClient->from('Item')->where('id', '=', 'ec11-80f1-0022489308a6')->get();
I see that the issue is related to the single quotes being added to the value in Grammar::prepareValue()
.
To prevent single quotes being added, it seems I have to explicitly define the type as a prefix Grammar::isSpecialPrimitiveDataType()
return preg_match("/^(binary|datetime|guid|time|datetimeoffset)(\'[\w\:\-\.]+\')$/i", $value);
So I've modified the guid value to something like this:
$item = $odataClient->from('Item')->where('id', '=', "guid'ec11-80f1-0022489308a6'")->get();
Which resulted in a different error.
Can anyone suggest anything else I can try?
Thanks!
- odata-client:
v0.7.3
- REST API: MS Dynamics 365 (D365)
Edit
- It seems that the API I'm using (MS Dynamics 365) doesn't support the
guid'<value>'
syntax - And there's no way to passthrough the value without the value being stringified by this library (I believe)
- I'm proposing a possible fix here:
- Passthrough raw values without it being stringified #156
Edit 02
- I just noticed this PR:
- Where raw #105
- Which deals with passing through the whole raw statement
Rest API
Test done via Postman
Filter | Response |
---|---|
id eq 'ec11-80f1-0022489308a6' |
Error: A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'. |
id eq guid'ec11-80f1-0022489308a6' |
Error: Unrecognized 'Edm.String' literal... |
id eq ec11-80f1-0022489308a6 |
OK |
Metadata
Metadata
Assignees
Labels
No labels