-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
InsertSetStep and similar interfaces should implement AutoCloseable #4683
Comments
Hmm, interesting. It would be easy to implement. I suspect that it would be sufficient for What would |
It's just good practice to call Since the implementation of
It also might be nice for all these interfaces to extend I know that this is growing the scope of this issue, and it can be broken out into two; or we could just renamed it "Create & extend ExecutableQuery super-interface of Query", or some such similar title. |
I was tired this morning. I suspect I hadn't looked into the right version of
That won't work well with jOOQ's DSL design strategy. It should not be possible to execute queries that are "incomplete"
Perhaps... It could be
I wouldn't do that for the reasons mentioned before.
There is a strategic distinction between the DSL API and the model API, which we will further evolve in future versions. The DSL API is supposed to be used for "static SQL" whereas the model API is better suited for "dynamic SQL". In that sense, if you want to build very dynamic SQL statements, you might be better off with the model API, e.g. with |
I had heard about the model API, but hadn't yet looked into it, but now I have, and it looks like it should solve the issues that I had with the restrictiveness of the DSL API. Thanks for bringing it to my attention again. I'm not sure what you mean by "It might make sense to put that API on all of these Step types. On the other hand, it's not 100% clear what should be communicated to the user, this way.". Do you mean making them extend |
The Model API is much less expressive than the DSL API, so having all of its interfaces extend |
The DSL API is so much more natural than the Model API that I'd much prefer to use the DSL. if you're willing to add If you're unwilling to add From what I've seen, this should only require managing a few interface methods / interfaces, since all the implementations of interfaces without |
FYI, |
I think we're already discussing solutions to a problem that we haven't yet fully specified or understood - at least I haven't. We'll certainly not do any deprecation trickery, that's for sure. :) Guava may do things, but that doesn't mean that those things are good. In all of the above discussion, you haven't yet explained why you're trying to write the following: try (InsertSetStep insert = ctx.insertInto(table)) {
...
} ... rather than, for instance, the following: try (Query insert = ctx.insertInto(table).values(...)) {
...
} ... or even: Query insert = ctx.insertInto(...).values(...);
try (Query query = insert) {
...
} Let's get on the same level of understanding about the problem first, before we discuss possible solutions. Do note that my point here is that locally assigning intermediate DSL "Step" API parts is always a workaround, and never best practice. Any attempt to improve the feel of applying this workaround is the wrong way to go forward in the long run. An acceptable solution in the long run is to work towards overall better APIs. The DSL API is designed for static SQL, and the model API is designed for dynamic SQL. Every in-between solution will deteriorate the perceived API quality, maintainablity, and usability. And already now, things aren't perfect.
That's a known issue: #3771. It will not be possible to call |
After second review, I really don't think this is a reasonable thing to do. The intermediate "Step" API types do not stand on their own. As such, they should not expose any "convenient" functionality that helps using them in a way they weren't intended to be used. Some people use them for "dynamic SQL". That is not recommended practice, although for a quick win, unfortunately, it is perceived better than resorting to the model API. This means we should fix the model API in jOOQ 4.0 to make it more suitable for such cases, not add functionality to the Step types. Closing this as won't fix |
InsertSetStep
and similar interfaces should implementAutoCloseable
.DSLContext#insertInto(Table<R>)
returns anInsertSetStep
, which, sinceInsertSetStep
doesn't currently implementAutoCloseable
, means that I can't write the following sensible code:The text was updated successfully, but these errors were encountered: