Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.
This repository was archived by the owner on May 19, 2025. It is now read-only.

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

Open

Description

@gabrielgrant

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

Activity

  1. tstirrat commented on Jun 13, 2016

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions