Not compatible with javascript template literals filtered(`name = ${name}`)
See original GitHub issueHi,
I was passing my query conditions using Javascript es6 template literals and noticed an error
'number = "111122"':1:0: Invalid predicate.
and the condition was
const condition = ` number = "${number}"`
also tried
const condition = `number = ${number}`
The condition would later go to a realm.objects.filtered(condition)
to make a query which it then brings that error i showed.
It doesn’t bring any error when i use normal string concatenation however.
const condition = 'number = "' + number + '"';
In my modal i had
VehicleSchema = {
name: 'vehicleInfo',
properties: {
name: 'string',
number: 'int',
password: 'string',
type: 'string',
picture: { type: 'data', optional: true }
}
};
Is this a known issue?
Thank you!
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >Javascript template literals work when declared as a variable ...
Trying to wrap my head around Javascript. If I have a declared variable with template literals, for example: var templateObject = `Student name...
Read more >JavaScript Template Literals and styled-components
The template literal is broken down into an array of strings and a list of variables. In the example above the array of...
Read more >The Power of Javascript Template Literals - LinkedIn
Template literals solve two problems - creating multiline content ... const filterNames = names.filter((name)=>name[prop].match(re)) return ...
Read more >Template Literals | CSS-Tricks
The Template Literal, introduced in ES6, is a new way to create a ... you do not need to use a Template Literal...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@maotora I think the issue is datatype. Realm “number” column has int datatype and you passing number in string datatype. That’s why it shows you invalid predicate. Your query string is like “number = 11111” not like "number = “11111” ".
@maotora Yes my friend glad to you found where was the issue lies. I also many times stuck in Realm issues. But it got resolved after seen documentation carefully. Of course Realm has to be mature much more like other databases.