Closed KieranFJ closed 2 years ago
@KieranFJ have you tried you oData API manually and works? It might be not supported by oData, so the library won't be able to do anything about it.
@tavy315 Yeh, if you try something like :
https://services.odata.org/V4/OData/OData.svc/Products?$filter=Rating%20lt%20Price
you'll get relevant results back, but what the library ends up generating is
https://services.odata.org/V4/OData/OData.svc/Products?$filter=Rating%20lt%20'Price'
Which is just looking for the literal string value of 'Price', not comparing the column. Which is due to prepareValue checking the value of and quoting it if its a string.
Example using another REST
@KieranFJ seems that Laravel Eloquent has whereColumn / orWhereColumn methods, but odata-client-php doesn't implement such a feature yet.
Aweseome, thanks @tavy315 Ill updated to the 0.6.0 and pull #95 down and give it a try. Looks a lot better than what i came up with.
I have been using the library for a while and getting along with it, but have only just now need to filter a column by another column, for example
$filter=QtyOnHand eq QtyReserved
Both columns are decimals.
However the where method treats the value as a string, and eventually puts single quotes around it in Grammar - prepareValue()
so the end result for the URI will have $filter=QtyOnHand eq 'QtyReserved' which ends up with a decimal / string compare error. If I do the same query in postman, minus the quotes, it works fine.
->where('QtyOnHand ', '=' 'QtyReserved');
Doesn't appear to be a way to hint that this is a column and not a value. Am I missing something obvious?
I have made a temp work around (pass a valueType = 'column' or 'value' and eventually decide not to quote the string, and it in theory works.