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

Creating a record without content fails, but reports success #387

Open
gabrielgrant opened this issue Jun 9, 2016 · 1 comment
Open

Comments

@gabrielgrant
Copy link
Contributor

Steps to reproduce

Create a record with no content:

    var task = this.store.createRecord('task', {});
    console.log(task.get('currentState.stateName'));  // root.loaded.created.uncommitted
    task.save().then(data => {
      console.log(data.get('currentState.stateName'));  // root.loaded.saved
    });
    console.log(task.get('currentState.stateName'));  // root.loaded.created.inFlight

An ID is assigned in the ED store, and the record reports having been saved successfully, but no data has actually been recorded in Firebase.

Expected behavior

Any empty record should be returned when fetching the list of Tasks

Actual behavior

The new Task is not saved, unless data is added.


Pretty sure this occurs because there is no way to store an empty record in Firebase -- it just deletes the node. In the ED world, though, that's a surprising result -- usually fields are optional, and there's a big difference between a record being created with no attributes set vs no record at all

I see two workable options:

  1. use some sort of sentinel value as a default (false?), that gets interpreted as null when loaded by the adapter
  2. fail loudly with an explicit error stating empty objects aren't supported in EmberFire
@tstirrat
Copy link
Contributor

Thanks for the report on this, will probably need to do the second option. The sentinel value will add more confusion that it's worth and its pretty useless storing an empty record -- at the very minimum you'd probably want a created date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Core Development
Accepted / TODO
Development

No branches or pull requests

2 participants