Skip to content

Convert entity relation name back to camel case before querying #35

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

Merged
merged 2 commits into from
Mar 14, 2023

Conversation

too-soon
Copy link

Fixes #28.

Sometimes an entity would not be found while trying to POST a resource with its relationship.
Like mentioned in the issue, we need to convert our entity name back to camel case before querying.

@too-soon too-soon changed the title Revert entity relation name back to camel case before querying Convert entity relation name back to camel case before querying Mar 11, 2023
@klerick
Copy link
Owner

klerick commented Mar 12, 2023

@Mites-G thanks for contribute. Could you add unit test for this case?

@too-soon
Copy link
Author

@klerick can you help me creating a new relationship on the mock database?

It needs to have an underline character(_) in its name to test my feature but I couldn't figure out how to do so.

Something to that effect:

  @OneToOne(() => Addresses, (item) => item.id)
  @IsNotEmpty()
  @JoinColumn({
    name: 'addresses_id',
  })
  public address_data: Addresses;

@klerick
Copy link
Owner

klerick commented Mar 13, 2023

you shoukd create table using SQL in this file
and create entity for test and add reletion. and use it in test. I believe, create separate entity will better solution for unit test which cover this case.

if you have problem, let me know, tomorro I will have free time and will try to do it myself

@too-soon too-soon marked this pull request as draft March 13, 2023 21:42
@too-soon too-soon marked this pull request as ready for review March 13, 2023 22:58
@too-soon
Copy link
Author

@klerick I managed to do it, thank you for helping out.

Here's the test before the fix:
image

And now after:
image

@klerick
Copy link
Owner

klerick commented Mar 14, 2023

thank you!

@klerick klerick merged commit 02b0479 into klerick:master Mar 14, 2023
@github-actions
Copy link

🎉 This pull request is included in version [email protected] 🎉

The release is available on GitHub release

@too-soon too-soon deleted the relationship-capitalization branch March 14, 2023 10:17
@github-actions
Copy link

github-actions bot commented Jun 1, 2023

🎉 This pull request is included in version [email protected] 🎉

The release is available on GitHub release

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

Successfully merging this pull request may close these issues.

EntityMetadataNotFoundError on posting entity with relation
2 participants