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.

Forgetting placeholder value should throw a meaningful error

See original GitHub issue

Goals

Getting a better error message if I forget to define the value for a placeholder, when querying a Realm.

Expected Results

I would love a message that said: “Query uses the $0 placeholder but a value was not provided”.

Actual Results

An error is thrown with "vector" as message.

Steps to Reproduce

Define a schema

const schema: Realm.ObjectSchema[] = [{
  name: 'Person',
  properties: {
    name: 'string',
    age: 'int',
  }
}];

Query data

realm.objects('Person').filtered('name != $0');

🔥

Code Sample

import * as assert from 'assert';
import * as Realm from 'realm';

const schema: Realm.ObjectSchema[] = [
  {
    name: 'Person',
    properties: {
      name: 'string',
      age: 'int',
    }
  }
];

describe('Realm filtering with an undefined placeholder', () => {
  let realm: Realm;

  before(() => {
    // Open a local realm
    assert(!realm);
    realm = new Realm({ path: 'test.realm', schema });
  });

  after(() => {
    if (realm) {
      if (!realm.isClosed) {
        realm.close();
      }
      Realm.deleteFile({ path: realm.path });
    }
  });

  it('throws a meaningful message', (done) => {
    // First we create a collection
    const persons = realm.objects('Person');
    assert.equal(persons.length, 0);
    try {
      const filteredPersons = persons.filtered('age > $0');
    } catch (err) {
      assert.notEqual(err.message, 'vector');
    }
  });
});

Version of Realm and Tooling

  • Realm JS SDK Version: 2.6.0
  • Node or React Native: N/A
  • Client OS & Version: N/A
  • Which debugger for React Native: N/A

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
knethcommented, Jun 13, 2018

2.8.3 has been released.

1reaction
ironagecommented, Jun 12, 2018

The fix is included in core 5.6.1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Could not Resolve placeholder - Stack Overflow
In my case , I forgot to add the new property in my application.properties under test folder.Adding it resolved the issue.
Read more >
Why Using Input Placeholders in Place of Labels is a Bad Idea
When the placeholder attribute made its way into HTML5 and became commonplace, a bad trend started—using them in place of labels for form ......
Read more >
Don't Use The Placeholder Attribute - Smashing Magazine
When a person enters information into an input, its placeholder content will disappear. The only way to restore it is to remove the...
Read more >
Power Query M Primer (Part 15): Error Handling | Ben Gribaudo
When an access attempt occurs, the logic that originally caused the error is not re-evaluated to see if it now will produce a...
Read more >
Error thrown - Warning: You called act(async () => ...) without ...
Ask your Question. I have a simple test that seems to generate the right snapshot at the end of execution, but throws me...
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