question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not compatible with javascript template literals filtered(`name = ${name}`)

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
reformercommented, Dec 31, 2016

@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” ".

0reactions
reformercommented, Jan 2, 2017

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found