Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested object returns as null if first property is null #7

Open
hannupekka opened this issue Dec 20, 2018 · 1 comment
Open

Nested object returns as null if first property is null #7

hannupekka opened this issue Dec 20, 2018 · 1 comment

Comments

@hannupekka
Copy link

Given the query
const query = knex.select(['table.col_a AS _nested_colA','table.col_b AS _nested_colB']);

am I right to assume that with table.col_a as null and table.col_b as foo I should be getting back

{
  nested: {
    colA: null,
    colB: 'foo'
  }
}

However, I get

{
  nested: null
}

Is this how it should be working or might this be a bug?

@hannupekka
Copy link
Author

I've forked this project and added test data to hilight the issue: https://github.com/hannupekka/KnexNest/tree/issue/7-nested-objects-return-as-null

The reason for this seems to be at https://github.com/CoursePark/NestHydrationJS/blob/master/NestHydrationJS.js#L98 - if I remove that else block, nested null values seem to get returned properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant