Skip to content

[Feature Request] - Simplify top-level APIs for SqlClient #939

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

Open
TokgoRonin opened this issue Feb 24, 2025 · 5 comments
Open

[Feature Request] - Simplify top-level APIs for SqlClient #939

TokgoRonin opened this issue Feb 24, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@TokgoRonin
Copy link
Contributor

Reason

  • Now SqlClient's top-level API is too much, especially for different save modes, provides a very large number of APIs, such as: insert, update, insertIfAbsent, etc. (these APIs also have their own overloaded version), which leads to SqlClient's top-level API is very confusing. In fact, all of these APIs can be accomplished by specifying different parameters in the save method, so it is inappropriate to put these APIs in the top level of SqlClient.

  • And in version 0.9.0, the insert and update of the associated object save mode of destructive changes , resulting in previous users need to be very careful to upgrade to modify the code is very much , and the current number of top-level API is also a very large number of new users just started learning Jimmer, resulting in difficulties in understanding and improve the cost of learning .

Translated with DeepL.com (free version)

Description

  • It is recommended that SqlClient's top-level API be redesigned and simplified. Ideally, for all types of save processing, we would like to keep only save and not insert and update, especially insertIfAbsent and so on, which are very seldom used and should never be put into the top-level API.

  • Currently, there are 6 overloads for the save method alone, which is enough to cope with all kinds of scenarios, and the other simplified APIs are not necessary to be put on the top level, so it is recommended to remove these APIs.

  • If you really do not want to delete these insert/update, then it is recommended to rename it, for example, to pureInset, and do not put it on the top level of the SqlClient.

Existing solutions

No response

@TokgoRonin TokgoRonin added the enhancement New feature or request label Feb 24, 2025
@belovaf
Copy link
Contributor

belovaf commented Mar 17, 2025

My vote is for not remove all these methods from SqlClient.
Our projects have relatively complex logic and we often use all overloaded SqlClient methods.
It is very convenient to haven all these methods here.
If SqlClient api will be simplified we will have to create all these methods on the client side in each project.

@LanXa7
Copy link

LanXa7 commented Mar 18, 2025

I think manually setting the save mode is helpful for a deeper understanding of Jimmer and the database, and I support redesigning and simplifying the top-level API of SQL Client. And there are some patterns that are actually rarely used and should never be included in top-level APIs. If considering the needs of some users who really do not want to delete these insert/update files, it is recommended to rename them, for example, to pureInset, and not place them at the top level of SQL Client.

@TokgoRonin
Copy link
Contributor Author

My vote is for not remove all these methods from SqlClient. Our projects have relatively complex logic and we often use all overloaded SqlClient methods. It is very convenient to haven all these methods here. If SqlClient api will be simplified we will have to create all these methods on the client side in each project.

I think it's only necessary to keep one save method, and two overloaded save methods for specifying SaveMode and AssociatedSaveMode, everything else can be removed.

And the insert and update methods changed AssociatedSaveMode in version 0.9.0, which was a breaking change that caused many older projects to shy away from upgrading at all. The original insert and update methods, whose AssociatedSaveMode is Replace, have been in use for almost 2 years before version 0.9.0, and the number of these old projects during this 2-year period is very large, and the demands of these old projects should not be ignored!

And the simplified Top-Level Api is also more friendly to new users, and the Api will be more unified.

@LanXa7
Copy link

LanXa7 commented Mar 18, 2025

My vote is for not remove all these methods from SqlClient.我的投票是不支持从 SqlClient 中删除所有这些方法。 Our projects have relatively complex logic and we often use all overloaded SqlClient methods.我们的项目具有相对复杂的逻辑,我们经常使用所有重载的 SqlClient 方法。 It is very convenient to haven all these methods here.将所有这些方法都留在这里非常方便。 If SqlClient api will be simplified we will have to create all these methods on the client side in each project.如果 SqlClient api 要简化,我们将不得不在每个项目的客户端创建所有这些方法。

If possible, I think you can independently maintain this part by yourselves. I believe your team has the ability to do so

@TokgoRonin
Copy link
Contributor Author

My vote is for not remove all these methods from SqlClient. Our projects have relatively complex logic and we often use all overloaded SqlClient methods. It is very convenient to haven all these methods here. If SqlClient api will be simplified we will have to create all these methods on the client side in each project.

The main point is that AssociatedSaveMode should not follow the change of shortcut API, AssociatedSaveMode should be Replace by default, if you want to change AssociatedSaveMode, you can just set it by your own initiative. For example, the AssociatedSaveMode of insert was originally Replace, but after version 0.9.0, the AssociatedSaveMode of insert was changed to APPEND, and others such as the AssociatedSaveMode of update was changed to APPEND_IF_ABSENT, the AssociatedSaveMode of merge was changed to APPEND_IF_ABSENT, and the AssociatedSaveMode of merge was changed to APPEND_IF_ABSENT. ABSENT, and the AssociatedSaveMode of merge has been changed to MERGE, and so on. The existence of these shortcut APIs changes the default AssociatedSaveMode mode, which is a very inconsistent experience for newcomers, and the need to memorize more APIs has also become more, which seriously undermines the development experience of Jimmer users.

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

No branches or pull requests

3 participants