Skip to content

Fix morphTo options.query#2059

Merged
ricardograca merged 5 commits into
bookshelf:masterfrom
Znarkus:fix/morphto-optionsquery
Mar 2, 2020
Merged

Fix morphTo options.query#2059
ricardograca merged 5 commits into
bookshelf:masterfrom
Znarkus:fix/morphto-optionsquery

Conversation

@Znarkus

@Znarkus Znarkus commented Feb 27, 2020

Copy link
Copy Markdown
Contributor

Don't use same query builder for all candidates

Introduction

fetching event gets same query builder for all morphTo candidates.

Motivation

We're using on('fetching', ..) to add deleted_at check for relations, but this fails for morphTo relations, since opts.query is the same regardless of candidate.

Proposed solution

Remove query from options prior to sending it to sync, solves this issue.

Current PR Issues

No issues known.

Alternatives considered

No alternatives considered.

Don't use same query builder for all candidates

@ricardograca ricardograca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a test case for this issue? That should help ensure it's not re-introduced at a later time.

@Znarkus

Znarkus commented Feb 28, 2020

Copy link
Copy Markdown
Contributor Author

@ricardograca Added a passing test (finally) that fails if I remove my fix.

Comment thread test/integration/relations.js Outdated
Comment thread test/integration/relations.js Outdated
@Znarkus

Znarkus commented Mar 2, 2020

Copy link
Copy Markdown
Contributor Author

@ricardograca I changed the test setup to better fit the existing structure, please check to see if it makes sense.

@ricardograca ricardograca left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! It's better now.

@ricardograca
ricardograca merged commit da25f3d into bookshelf:master Mar 2, 2020
@Znarkus

Znarkus commented Mar 2, 2020

Copy link
Copy Markdown
Contributor Author

@ricardograca Great! Thanks. When can we expect the next version to be published?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants