question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

null value results in two identical rows not being merged

See original GitHub issue

When 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:open
  • Created 8 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

1reaction
pom421commented, Nov 16, 2019

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

1reaction
arenddeboercommented, Jun 30, 2017

For anyone running into this, the treeize inspired flatToTrees seems handle null values better.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found