ODataAngularResources icon indicating copy to clipboard operation
ODataAngularResources copied to clipboard

expandPredicate odata v4 date bad format

Open elste opened this issue 7 years ago • 0 comments

If I execute this:

$odataresource("http://services.odata.org/V4/Northwind/Northwind.svc/Products", {}, {}, { isodatav4: true}) 
    .odata()
    .filter('UnitPrice', '>', 10)
    .filter('Discontinued', true)
    .orderBy('UnitsInStock', 'asc')
    .expandPredicate('Order_Details')
    .expandPredicate('Order')
    .filter('OrderDate', new Date('1996-07-17T00:00:00Z'))
    .finish()
    .finish()
  .query();

I get the url with date not in v4 format:

http://services.odata.org/V4/Northwind/Northwind.svc/Products?$filter=(UnitPrice gt 10) and (Discontinued eq true)&$orderby=UnitsInStock asc&$expand=Order_Details($expand=Order($filter=OrderDate eq datetime'1996-07-17T02:00:00'))

My solution: in factory $odataExpandPredicate, I changed the source this way:

var ODataExpandPredicate = function (tableName, context) {
        if (tableName === undefined) {
            throw "ExpandPredicate should be passed a table name but got undefined.";
        }

        if (context === undefined) {
            throw "ExpandPredicate should be passed a context but got undefined.";
        }

        this.name = tableName;
        this.expandables = []; // To maintain recursion compatibility with base OdataResourceProvider
        this.options = {
            select: [],
            filter: [],
            orderby: [],
            expand: this.expandables,
        };
        this.context = context;
	this.isv4 = context.isv4; // NEW  LINE !!!
};

Now I get the url with date in v4 format:

http://services.odata.org/V4/Northwind/Northwind.svc/Products?$filter=(UnitPrice gt 10) and (Discontinued eq true)&$orderby=UnitsInStock asc&$expand=Order_Details($expand=Order($filter=OrderDate eq 1996-07-17T02:00:00Z))

regards

elste avatar Oct 17 '17 13:10 elste