brianloveswords / streamsql

A streaming, backend agnostic SQL ORM heavily inspired by levelup
MIT License
67 stars 7 forks source link

`relationshipsDepth` slightly broken for large values #17

Open brianloveswords opened 10 years ago

brianloveswords commented 10 years ago

It doesn't actually fulfill all of the relationships.

{relationshipsDepth: 2}
// yields
{ id: 1,
     createdOn: '2014-04-17T15:40:55.000Z',
     jsonUrl: 'http://example.org/two',
     earnerId: 'test-user',
     badgeClassId: 1,
     uid: 'test-badge-one',
     imageUrl: null,
     badgeJSONUrl: 'http://example.org/badge.json',
     evidenceUrl: null,
     issuedOn: null,
     expires: null,
     earner:
      { id: 'test-user',
        createdOn: '2014-04-17T15:40:55.000Z',
        metadata: {},
        badges: [],
        _metadata: [] },
     json:
      { url: 'http://example.org/two',
        data: '{"sup": true}',
        updatedOn: '2014-04-17T15:40:55.000Z',
        assertion: [Object],
        badge: [Object],
        issuer: [Object] },
     badgeClass:
      { id: 1,
        createdOn: '2014-04-17T15:40:55.000Z',
        jsonUrl: 'http://example.org/one',
        issuerOrgId: 1,
        name: 'Example Badge Class',
        description: 'I AM ERROR',
        imageUrl: 'http://example.org/image.png',
        criteriaUrl: 'http://example.org/criteria',
        issuerJSONUrl: 'http://example.org/issuer.json',
        json: [Object],
        issuer: [Object] } } }

// -------------------------------------------

{relationshipsDepth: Infinity}
// missing `json` and `badgeClass`
{ id: 1,
     createdOn: '2014-04-17T15:41:03.000Z',
     jsonUrl: 'http://example.org/two',
     earnerId: 'test-user',
     badgeClassId: 1,
     uid: 'test-badge-one',
     imageUrl: null,
     badgeJSONUrl: 'http://example.org/badge.json',
     evidenceUrl: null,
     issuedOn: null,
     expires: null,
     earner:
      { id: 'test-user',
        createdOn: '2014-04-17T15:41:03.000Z',
        metadata: {},
        badges: [],
        _metadata: [] } } }

// -----------------------------------------
// also interesting, if I use too high a value, I get the same result as Infinity
{relationshipsDepth: 3}

{ id: 1,
     createdOn: '2014-04-17T15:43:36.000Z',
     jsonUrl: 'http://example.org/two',
     earnerId: 'test-user',
     badgeClassId: 1,
     uid: 'test-badge-one',
     imageUrl: null,
     badgeJSONUrl: 'http://example.org/badge.json',
     evidenceUrl: null,
     issuedOn: null,
     expires: null,
     earner:
      { id: 'test-user',
        createdOn: '2014-04-17T15:43:36.000Z',
        metadata: {},
        badges: [],
        _metadata: [] } } }