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

TypeError when parsing a row: parse-row.js #6

Open
hunsoo opened this issue Jan 7, 2020 · 1 comment
Open

TypeError when parsing a row: parse-row.js #6

hunsoo opened this issue Jan 7, 2020 · 1 comment

Comments

@hunsoo
Copy link

hunsoo commented Jan 7, 2020

TypeError: Cannot read property 'v' of null
    at ...../node_modules/cuba/src/parse-row.js:10:71

This happens when checking for null with:

result[schema[index]] = transform(typeof cell === 'object' ? cell.v : null)

When you do typeof null, you get 'object'.
It can be fixed by checking for the null with double negation, because the cell is either an object literal (which always returns true when used in conditional statements) or null:

result[schema[index]] = transform(!!cell ? cell.v : null) 

This works fine with my data.

@hunsoo hunsoo changed the title Error when parse-row.js TypeError when parsing a row: parse-row.js Jan 7, 2020
@Exiliot
Copy link

Exiliot commented Dec 11, 2020

I have the same issue. @yuanqing what would you say about the suggestion above? It would be great to fix this in the package itself.

Exiliot added a commit to Exiliot/cuba that referenced this issue Dec 11, 2020
This change fixes this issue – yuanqing#6
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