Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxDocument - number field is set to null #215

Closed
topperblues opened this issue Jul 11, 2017 · 5 comments
Closed

RxDocument - number field is set to null #215

topperblues opened this issue Jul 11, 2017 · 5 comments

Comments

@topperblues
Copy link

Case

Bug

Issue

I try to use an RxDocument as described in the examples but the schema have a number field. When i create the form all works well but when an user write a number in the number field and then delete it the field is set to null.
This generate an error (see Code section) that block all changes to the RxDocument while the page is refreshed.
If i try to save the document after delete and rewrite the number field without page refresh, i get a validation error on the number field because it is still set to null.
For the code refer to https://github.com/pubkey/rxdb/tree/master/examples/angular2/app/src/components/hero-insert

Info

  • Environment: Angular 2, Browser or Electron
  • Adapter: IndexedDB

Code

For the code refer to https://github.com/pubkey/rxdb/tree/master/examples/angular2/app/src/components/hero-insert

ERROR TypeError: Cannot read property 'defineGetter' of null
at RxDocument.js:239
at Array.forEach ()
at RxDocument._defineGetterSetter (RxDocument.js:235)
at RxDocument.get (RxDocument.js:223)
at RxDocument.foglio (RxDocument.js:240)
at Object.eval [as updateDirectives] (RegistroAddComponent.html:38)
at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13108)
at checkAndUpdateView (core.es5.js:12288)
at callViewAction (core.es5.js:12653)
at execEmbeddedViewsAction (core.es5.js:12611)

@pubkey
Copy link
Owner

pubkey commented Jul 11, 2017

I can reproduce the error because of setting null as value.
But I can not reproduce the error with defineGetter. Can you enlist the steps to reproduce?
Which browser do you use?

@topperblues
Copy link
Author

Browser

I'm using Chrome browser.

Steps

Changes i made:
In the collection schema:

"age": {
            "type": "number"
        },

In the component:

const collection = await this.databaseService.getCollection('person');
this.person = collection.newDocument({
        ...
        "age": 0,
        ...
      });

Where getCollection('person') return Person collection from _createCollections.

In the template:
<input type="number" class="form-control" id="age" name="age" [(ngModel)]="person.age">

Error

When i delete the 0 in the age filed of the form i get this error in console:

ERROR TypeError: Cannot read property '__defineGetter__' of null
    at RxDocument.js:239
    at Array.forEach (<anonymous>)
    at RxDocument._defineGetterSetter (RxDocument.js:235)
    at RxDocument.get (RxDocument.js:223)
    at RxDocument.age (RxDocument.js:240)
    at Object.eval [as updateDirectives] (PersonAddComponent.html:38)
    at Object.debugUpdateDirectives [as updateDirectives] (core.es5.js:13108)
    at checkAndUpdateView (core.es5.js:12288)
    at callViewAction (core.es5.js:12653)
    at execEmbeddedViewsAction (core.es5.js:12611)

From now every time i type a digit in the field i get the same error in console.

If never empty age field i never get error.

@pubkey
Copy link
Owner

pubkey commented Jul 11, 2017

This helps a bit. But it's not complete. There is not person-collection in the ng2-example. Can you fork this repo and implement the changes in the fork?

EDIT: I could reproduce this now. I will investigate..

@pubkey
Copy link
Owner

pubkey commented Jul 11, 2017

Fixed with this commit. (Accidentially set the wrong commit-number)

@pubkey pubkey closed this as completed Jul 11, 2017
pubkey added a commit that referenced this issue Jul 11, 2017
@topperblues
Copy link
Author

Issue fixed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants