Calling .get() on a keyed reference to another reference collection returns getter function #179

Closed
absoludity opened this Issue Dec 4, 2012 · 1 comment

Comments

Projects
None yet
2 participants

I recently updated the todomvc project to use a more recent derby due to

addyosmani/todomvc#338 which was a result of codeparty#171

It solved the "DERBY is not defined" error, but seems to have found another:

model.set('colors', {
  red: {hex: '#f00', id: 'red'}
, green: {hex: '#0f0', id: 'green'}
, blue: {hex: '#00f', id: 'blue'}
});
model.ref('_colors.favourite', model.filter('colors').where('id').equals('red'))
model.ref('_colors.notfavourite', model.filter('colors').where('id').equals('green'))
model.set('_filter', 'favourite')
model.ref('_keyedRef', '_colors', '_filter')
model.get('_keyedRef')

Expected output:

[{hex: '#f00', id: 'red'}]

Actual output:

function getter(data, pathToRef, rest, refEmitter, prevRests) {
    if (! prevRests) {
      prevRests = [rest];
    } else {
      prevRests.push(rest);
    }
    var out = treeLookup(data, to, {prevRests: prevRests});
    prevRests.pop();
    refEmitter && refEmitter.emit('refWithoutKey', out.node, out.path, rest, hardLink);
    if (typeof out.node === 'undefined') out.halt = true;
    return out;
  }

I've worked around it for the moment by always setting an unkey-ed ref:
https://github.com/addyosmani/todomvc/pull/340/files

Contributor

nateps commented Apr 10, 2014

Master of Derby is now the rewritten 0.6 and I am removing previous issues pretty aggressively so that I can be more responsive to new issues.

Please re-open if this issue is still relevant in Derby 0.6.

@nateps nateps closed this Apr 10, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment