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

[React] Numeric field of an entity is sent as a string in the JSON via REST API #23850

Merged
merged 3 commits into from
Oct 20, 2023

Conversation

qmonmert
Copy link
Contributor

Fix #23763


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

Copy link
Contributor

@hide212131 hide212131 left a comment

Choose a reason for hiding this comment

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

@qmonmert Thank you for addressing this issue. 🙂
I'll comment on the points I've noticed.

@hide212131
Copy link
Contributor

Actually, I'm currently working on a generator for integration tests using Testing Library and MSW to increase test coverage for React entities.
generator-jhipster-react-enhance

It's still under construction, but it generates code like the following:
Generated Code Example

I discovered issues #23763 and #23769 during the development process.
If you'd like to give it a try, I'd be delighted.

@qmonmert qmonmert marked this pull request as draft October 15, 2023 07:11
@qmonmert qmonmert marked this pull request as ready for review October 15, 2023 12:11
@qmonmert qmonmert requested a review from hide212131 October 15, 2023 12:33
@hide212131
Copy link
Contributor

@qmonmert Thank you for addressing the changes. I've checked them and everything looks good. 😃
...However, apologies for the piecemeal feedback 😭 . Upon further investigation, I found another minor issue.

This is the section where related entity IDs are sent.

https://github.com/jhipster/generator-jhipster/blob/72de10a384c263a7af972742669e043de6021282/generators/react/templates/src/main/webapp/app/shared/util/entity-utils.ts.ejs#L41C116-L41C118

The final { id } is a string in the form, but the actual entity ID should be a number.
I think it would be better to use map((id: any) => ({ id: Number(id) }));.

@qmonmert qmonmert force-pushed the fix/23763 branch 2 times, most recently from e88c41d to 474100f Compare October 15, 2023 19:11
@DanielFran
Copy link
Member

Adding a bug bounty, seems lot of work

@DanielFran DanielFran added $100 https://www.jhipster.tech/bug-bounties/ $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ labels Oct 15, 2023
@qmonmert
Copy link
Contributor Author

@DanielFran thanks

@qmonmert qmonmert force-pushed the fix/23763 branch 3 times, most recently from 6f4a34f to ec029f8 Compare October 16, 2023 12:00
@qmonmert
Copy link
Contributor Author

@mshima always the same build fails :/

@mshima
Copy link
Member

mshima commented Oct 16, 2023

The failure is related to jdl not loading the databaseType into entity.

It’s considering the postgres (gateway) primary key default (Long instead of UUID).

@mshima
Copy link
Member

mshima commented Oct 19, 2023

We should add a warning for microservice entities to use custom id.

@DanielFran DanielFran merged commit e45278d into jhipster:main Oct 20, 2023
@qmonmert
Copy link
Contributor Author

@mshima thanks for the help 🙂

@qmonmert
Copy link
Contributor Author

@DanielFran
Copy link
Member

@qmonmert approved

@mshima mshima mentioned this pull request Nov 1, 2023
19 tasks
@deepu105 deepu105 added this to the 8.0.0 milestone Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: enhancement 🔧 $$ bug-bounty $$ https://www.jhipster.tech/bug-bounties/ theme: jhipster-internals theme: react $100 https://www.jhipster.tech/bug-bounties/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In React, a numeric field of an entity is sent as a string in the JSON via REST API.
5 participants