The filter string used in BreezeJS query is incompatible with TimeSpan value

My attempt to execute a query with a filter on a string column is running into issues. Some filter values, like 'PO Box 27', are causing the queries to fail at runtime. The error message I receive states: "The string 'PO Box 27' is not a valid TimeSpan value."

Here is the code snippet:

var crmAccountsQuery = EntityQuery
        .from('crmAccountEFs')
        .where(breeze.Predicate.create('address1_Line1', 'eq', 'abc'));

Upon attempting to filter using this query structure, it fails and throws an error message.

The breeze.js library on the client side generates a URL like:

http://localhost:49800/breeze/BreezeDb/crmAccountEFs?$filter=(Address1_Line1%20eq%20time'PO%20Box%2027')

It seems that there is a mismatch in data typing.

Edit: related link: BreezeJS malformed OData query Url when using "startsWith"

Answer №1

After delving into the issue, I stumbled upon an unexpected solution. It turns out that the 'from' entityType was incorrectly specified as CrmAccountEFs instead of being in the correct case (crmAccountEFs), but no error was thrown. Strangely, the server managed to handle this case change, causing the client to fallback to an anonymous type without raising any alarms (especially because the code was trying to deal with Projection Queries). This particular discrepancy became evident while inspecting EntityQuery._getFromEntityType().

The repercussions of this error surfaced when executing the Query - the resource name failed to map to a specific entityType and ended up being assigned an anonymous type. Consequently, the column's type had to be deduced from its value. In my scenario, a leading 'P' assumed it to be of type Time. However, when the resultant URL reached the server, it stumbled while attempting to convert it to the accurate type.

//var query = breeze.EntityQuery.from("Todos");    //Ok

//wrong case => entityType = Anonymous => column's type inferred from value
var query = breeze.EntityQuery.from("todos");    //Error 

http://jsfiddle.net/rockresolve/C4A

Breeze Development Team: Detecting this subtle error can be quite challenging (and might also affect other string type inferences). Would it be feasible for EntityQuery to anticipate a resourceName that is a valid entityType by default, and only permit an Anonymous type when initialized through an explicit parameter?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am having trouble adding multiple items on different occasions - is it something to do with JQUERY

I have been working on a dynamic website that loads Firebase values into a table. However, I encountered an issue where the data does not appear when going back to the orders page after visiting another page. After some testing, I found that placing a but ...

Troubles encountered while processing STL file readers

Utilizing STLLoader.js, I am able to render components successfully, however, they all appear with one uniform color which does not resemble real-world components. The image above showcases my implementation in Three.js using STLLoader.js (Binary STL file ...

Create a duplicate of the information stored within the $scope variable

Suppose there are multiple variables stored in a $scope and the objective is to create a new object that only includes those variables, excluding all the internal Angular-related data. The specific names of the $scope variables may not be known. This can ...

Having trouble updating Vuejs array with new values

Currently, I am facing an issue with the template code for my survey builder. I am successfully receiving responses from the server, but the addAnotherQuestion value is not updating as expected. Despite trying various approaches, I have been unable to reso ...

Is it considered best practice to update the state of a React component by calling a function from within another function?

Initially, my code is functional, but I'm interested in learning best practices as I am new to React. I aim to create a basic countdown feature, however, encountered problems while using this.setState(...) as 'this' was not defined. The ...

Is it possible to dynamically call a component in Vue.js using a variable name

Can a Vue.js component be called by using a variable name? The components are registered like this: import Component1 from 'component1' import Component2 from 'component2' import Component3 from 'component3' ... components: ...

Identifier unique to Node.js for clients used for reconnections

I am in the process of developing a reconnection protocol for clients who may experience connection disruptions. In my client-side JavaScript code, I have implemented functionality to detect when a connection is lost and make periodic attempts to reestabli ...

The server is unable to process the request with parameters for the specified URL

I've been encountering an error every time I try to post something. articlesRouter.post('articles/:target', async (req, res) => { const target = req.params.target.replaceAll("_", " ") const article = await Arti ...

Exploring the Structure of Trees using JavaScript

Here are my terms: var terms = [ { id: 1, name: "Name 1", parent: null }, { id: 2, name: "Name 2", parent: 6 }, { id: 3, name: "Name 3", parent: null }, { id: 4, name: "Name 4", parent: 2}, { id: 5, name: "Name 5", ...

What does the buffer.copy() method do in Node.js?

Can someone please discuss the purpose and functionality of buffer.copy() in a Node.js application? Provide a real-time example for better understanding. Additionally, I am curious about the differences between the copy and slice methods in Node.js. How ...

What is the best way to iterate through a JSON object using the stages array provided?

I am facing an issue with parsing the provided json to display the desired output on the screen. These are the steps I need to follow for parsing this json: 1. Extract the stages array from the json - for example, stages ["check_dependency_progress", "sh ...

Am I utilizing the htmlspecialchars function properly?

My main objective is to protect the user from malicious code and prevent XSS attacks. I have implemented a series of checks to filter the user's input before storing it in the database. The user input is stored in the $post variable. $post = htmlspec ...

"Ensuring Proper Validation for Forms with JavaScript: A Step-by-Step Guide

Here is a sample Javascript form: <form id="loginForm" name="loginForm" action="/create_session/" method="post">{% csrf_token %} <table border="0" cellpadding="0" cellspacing="0" id="id-form"> <tr> <th valign=" ...

Creating a reactive connection between Fabric js and Vue js for dynamic updates

As a beginner in Vue.js, I decided to practice using Fabric.js and Vue.js. My goal was to make my canvas reactive by utilizing Vue.js, but unfortunately, nothing seemed to happen. The default display in the canvas was "Text". However, after clicking a butt ...

Steps for refreshing the content within a div without having to reload the entire page following an ajax request

I am trying to achieve the task of reloading the content of a specific div on a webpage without refreshing the entire page. My goal is to reload the div after uploading a photo so that the newly uploaded photo can be displayed from the database. However, t ...

Changing elements within Angular Scope while in ng-repeat loop

Creating an HTML form using ng-repeat to generate form elements from an object in the scope is a common practice. However, issues may arise when trying to update values outside of the ng-repeat block. Here's a basic example: <div ng-app="App"> ...

Move the circles using scaleLinear starting coordinates

Having issues moving circles within my chart. Take a look at this live demo https://codesandbox.io/s/71loxoq65j. Chart Visualization import { event, select, Selection } from "d3-selection"; import { scaleLinear, ScaleLinear } from "d3-scale"; import { Ax ...

What is the process for implementing optional chaining on a JSON object?

I'm currently facing an issue where I need to compare a value within a JSON object with a variable. if (resp.userdetails.name == username) { // do something } The challenge arises when not all resp objects contain the userdetails property, resulting ...

Utilize the filter functionality within an Angular2 service

Currently, I am in the process of developing an application using Angular 2. I have implemented a service, and my aim is to efficiently filter the data before retrieving it from the service. Specifically, I am looking for a way to retrieve just one project ...

Ways to transmit data from PHP to JavaScript

I have a file called "hotlaps.php" where I've created a JavaScript script: echo "<body onload=\"myFunction(".$array_1.",".$array_2.",".$array_3.");\">"; In my "hotlaps.js" file, I have the following function: function myFunction(arr ...