Closed EvanK closed 10 years ago
There a case study/real world example for this? Certainly not opposed to adding functionality, but curious when this may arise! :8ball:
Any SQL query that results in a lot of null values, in my use case a complex left join:
new db('foo')
.select('id')
.join('bar', function() {
this
.on('foo.id','=','bar.foreign_key_1')
.orOn('foo.id','=','bar.foreign_key_2');
}, 'left');
.column(
'bar.foreign_key_1',
'bar.foreign_key_2',
'bar.name',
'bar.something',
'bar.something_else'
);
This would return something like:
+--------+-------------------+-------------------+----------+---------------+--------------------+
| foo.id | bar.foreign_key_1 | bar.foreign_key_2 | bar.name | bar.something | bar.something_else |
+--------+-------------------+-------------------+----------+---------------+--------------------+
| 123 | NULL | 123 | alpha | NULL | NULL |
+--------+-------------------+-------------------+----------+---------------+--------------------+
Good point @EvanK!
@EvanK This should all be addressed by default in v2.0.0+ in case you are still using this...
It'd be useful to have an option to remove/reduce empty deep structures. For example, after running a particular query through
treeize.grow
, I might end up with:One could, say, remove objects with entirely null properties, and reduce arrays of empty objects to an empty array (the latter so that something expected to be iterable still would be, without needing an additional empty check in whatever is consuming your data feed):