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

Fix id extraction in id #257

Merged
merged 2 commits into from
Jul 13, 2021
Merged

Conversation

KidkArolis
Copy link
Contributor

In knex, db.insert(data, ['id']) returns an array of objects in the shape of [{ id }, { id }]. Referencing rows[0] gives you { id }, and that means we call this._get({ id }), when we meant to call this._get(id). This still works! Because of knexify manages to turn that into a valid query, but I'm not sure that's intended? We just want to call _get(id) from the get go. This doesn't really change the outcome, but confused me for a while when debugging another issue, and this change could prevent future problems in case feathers-knex or knex code changes in some way.

@KidkArolis
Copy link
Contributor Author

I've updated this PR to unbreak the sqlite support. knex.insert(data, returning) behaves differently in the different DBs, so handle that correctly. I don't have an easy way to add tests for this one, hm, but it's the code I'm using in my Postgres app.

id = rows[0][this.id]
}

if (!id) return rows
Copy link
Contributor Author

@KidkArolis KidkArolis Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure about this line.

@daffl daffl merged commit fcdbfdc into feathersjs-ecosystem:master Jul 13, 2021
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

Successfully merging this pull request may close these issues.

2 participants