null value results in two identical rows not being merged
See original GitHub issueWhen rows contain a field with a null value, they are treated as different values and even though the rows should be merged, they are not.
// Treeize turns flat associative data (as from SQL queries) like this:
var peopleData = [
{
'name': 'John Doe',
'age': null,
'pets:name': 'Rex',
'pets:type': 'dog',
'pets:toys:type': 'bone'
},
{
'name': 'John Doe',
'age': null,
'pets:name': 'Rex',
'pets:type': 'dog',
'pets:toys:type': 'ball'
},
{
'name': 'Mary Jane',
'age': 19,
'pets:name': 'Mittens',
'pets:type': 'kitten',
'pets:toys:type': 'yarn'
},
{
'name': 'Mary Jane',
'age': 19,
'pets:name': 'Fluffy',
'pets:type': 'cat'
}
];
// ...via a dead-simple implementation:
var Treeize = require('treeize');
var people = new Treeize();
people.grow(peopleData);
// ...into deep API-ready object graphs like this:
console.log(people.getData());
[ { name: 'John Doe', pets: [ [Object] ] },
{ name: 'John Doe', pets: [ [Object] ] },
{ name: 'Mary Jane', age: 19, pets: [ [Object], [Object] ] } ]
Or am I missing something ?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:6
- Comments:5
Top Results From Across the Web
Two rows having null values merge into one row without null ...
I was getting results similar to Op. My City and States were being duplicated. Original query: SELECT TABLE1.CITY, TABLE1.STATE, CASE WHEN ...
Read more >Why are there nulls in my secondary merged results query?
You are expecting that your merged results will match all values and display no null values. However, there are nulls in the results....
Read more >Merge two rows in table - identical data, expect one null field
I'm new in SQL, and have been wondering how i am able to join two rows, that are almost identical, expect for one...
Read more >Merge statement inserting duplicate rows on matching key
The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than...
Read more >How to merge rows in Excel without losing data - Ablebits
4 different ways to combine rows in Excel: merge multiple rows ... merge unique values only, omitting duplicates and skipping empty cells.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same problem with the null column value (for a deleted date which is null 99% of the time). It is fixable with the workaround to suffix the column name with ‘*’, it is documented here https://github.com/kwhitley/treeize#specifying-your-own-keyblueprint-for-collections
For anyone running into this, the treeize inspired flatToTrees seems handle null values better.