Skip to content

target.splice is not a function #195

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

Closed
gboor opened this issue Jun 26, 2018 · 3 comments
Closed

target.splice is not a function #195

gboor opened this issue Jun 26, 2018 · 3 comments

Comments

@gboor
Copy link

gboor commented Jun 26, 2018

In the firestore (@next) release, there is a function that deals with breaking down a path called walkSet. Inside this function, the path part is tested with isFinite and added to an array if true. If any other part of the path is !isFinite, the target is an object and not an array, resulting in "target.splice is not a function".

I think this is quite a rare case and highly dependent on the data in firestore, so I have created a Sandbox example using a demo account to connect to the specific data where I encountered this. It can be found here;

https://codesandbox.io/s/k9p895y6j5

main.js handles the setup and login with the demo account and App.vue is where the firestore binding causes this error.

The binding does work (or so it seems), as the data (1 customer) does appear in the document before it errors out.

@gboor gboor mentioned this issue Jun 26, 2018
36 tasks
@posva
Copy link
Member

posva commented Jun 26, 2018

Hey, thanks for the clear explanation and boiled down repro. Really appreciate it 🙂
Could you paste a dump of the customers collection? I couldn't explore the data using (https://vjoao.github.io/firestore-explorer/#/) because of the auth (I think)

@gboor
Copy link
Author

gboor commented Jun 26, 2018

I think I can do you one better. I have been tinkering with the data a bit and found that the actual problem is not with the customers collection, but with a reference.

Customers has an associative array (object) of project references, each indexed by its customer-specific number and having a reference to a project.

A project, in turn, has an associative array (object) of items, each indexed by a project-specific number and having a reference to an item.

Here is a breakdown of what this looks like (the collections currently only contain 1 item);

/customers/1NajcTL22Dtr1mCxsgIf

{
  "code": {
    "type": "string",
    "value": "1"
  },
  "name": {
    "type": "string",
    "value": "Test customer #01"
  },
  "projects": {
    "NL058113": {
      "type": "reference",
      "value": "projects/83LUbEoK0LJUpv2LyW9u"
    },
    "type": "object"
  }
}

/projects/83LUbEoK0LJUpv2LyW9u

{
  "code": {
    "type": "string",
    "value": "NL058113"
  },
  "items": {
    "567893": {
      "type": "reference",
      "value": "items/7TGYix43EJMccZ1iX1X7"
    },
    "type": "object"
  }
}

/items/7TGYix43EJMccZ1iX1X7

{
  "code": {
    "type": "string",
    "value": "567893"
  }
}

Having the code as a key may seem superfluous, but in certain cases, multiple customers are linked to the same project with different customer-specific codes. Same for projects -> items.

Where the error occurs is when querying the customer, it queries the projects and the items to generate some sort of path. The isFinite function is run on every key of the array or object. The key in projects/items is "567893" - which triggers "true" on isFinite, after which "items" is treated as an array, even though it is an object.

Hope this helps!

posva added a commit that referenced this issue Jul 1, 2018
@posva
Copy link
Member

posva commented Jul 1, 2018

Fixed in the new version. Thanks for reporting it!

@posva posva closed this as completed Jul 1, 2018
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