-
Notifications
You must be signed in to change notification settings - Fork 521
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
Consider reworking Chapter 3.5 "3.2 Choosing A Database Crate" #191
Comments
Happy to point that
I see where you are coming from, but a DSL is still a DSL. It can be easy to learn, because it's close to SQL, but it's still not the same as working with SQL as its primary interface.
The point being made is not about compile-time guarantees - it's about making sure that users don't get the false impression that by learning the DSL they will never have to interface with SQL. It's a classic example of the 200% problem - you had one problem (database queries) and you transformed it into two problems (learning SQL and learning a custom DSL).
Happy to make a correction.
That section will go away given the correction above, but I disagree that it was "a gross simplification or a clear lie". I obviously can't know what you meant, but given what you wrote in that thread I stand by my interpretation.
There is a linked footnote, exactly where that sentence stands, with a much more detailed explanation of what the issue is:
It looks like we have a different definition of nebulous.
The well-known solution is a crate that up until December 2022 averaged less than 50 downloads per day? I'll make what I believe to be the necessary corrections ahead of publishing the next revision (~in a month or two). Said that, I really don't appreciate the tone and many of the adjectives you used to characterise my work, my perspective, or my intention. I'm happy to amend other factual issues in the book that might have arisen since the ecosystem shifted since it was first published, but I have honestly no intention whatsoever of engaging on a debate with you here (or elsewhere). |
First of all thanks for your fast answer.
As already written before: I'm totally fine with your own conclusion to prefer a SQL based solution there. What I'm looking for is more another text clarification that this is personal taste thing. It's fine to have that on the book cover, but people tend to not reading the whole thing but just pointing to parts claiming wild things based on extracts.
Well in that case my objections about DSL vs SQL are important. This argument would be relevant if your would need to learn a DSL that is totally unrelated to SQL, but that's not the case for diesels DSL. Again if you know SQL you should be able to pick up the DSL in a few hours. So it's not a 200% problem. (To be clear: I do believe that you need to know at least basic SQL anyway to write efficient code with diesel as well)
I'm not claiming that sqlx provides no compile time guarantees. I'm just saying that you cannot say that the guarantees provided by both crates are comparable. You probably shouldn't summarize that as both crates provide these guarantees. Maybe just be more detailed there and state that sqlx provides these guarantees in that cases, while diesel provides additional guarantees in these cases? Or summarize it in the table as I think my largest problem here is that on the one hand you are quite opinionated about a DSL that's really close to SQL vs SQL, but on the other hand you just skip over these differences in what guarantees are provided.
Please provide a link where I or a different diesel core team member wrote that this is not planed. Other than I consider that as gross simplification to write that something is not planed as the linked discussion clearly outlines technical problems and states: These need to be solved and to our best knowledge they cannot be solved with the current language limitations. We also stated several times that we are open for solutions/contributions there and discussed several solutions with potential contributors. There is an important difference between something is not planed and something is not possible due to language limitations/nobody has figured out how to make it work given a set of constraints. (Also it's always a gross simplification to "summarize" a discussion spanning pages in a single sentence)
First of all: Using AGPLv3 as license or stating that it is experimental is something different that not existing or not planed. To be clear here: It's still not in a state that I consider as good due to the language level issues, but at that point it's on par to what other crates promote as "that's production ready" regardless of the issues around cancellation safety and transactions. (To be super clear here: The issues outlined in this comment are still not solved by any crate, especially if you consider cancellation as well). That's an issue that in unsolved for all async database connection crates and that cannot be solved without language level changes.
Ok, let's break that down:
I'm aware of that footnote. My point is if that's the only reason why you require an
I'm sorry that you feel that way about this post, but please consider my perspective as well. I feel my work misrepresented by promoting things I do not consider as correct and stating things I've never said. I hoped that you or someone else would correct that on your own, but as your work is often used as the source to claim things about diesel that are not correct I finally filled this issue. Hopefully we can resolve this without trying to blame each other. |
I am a reader of the book and from the whole approach of the book it was clear from the beginning that it is an opinionated book. Thus pursuing every written quotation about your own work like an evangelist in a tone with orders like „Please correct that!“ seems wrong to me too, @weiznich Best regards, and thanks to Luca for writing the book |
@Bodobolero It's not about criticizing the conclusions Luca has made or even being picky about why they did not choose diesel. It's a totally fine decision to use sqlx there and I can even understand how Luca came to that conclusion. I filled this issue mainly for the following reasons:
In addition there is some general discussion about async in there. I must admit that I believe that some people generally tend to assume that async will make things better for no obvious reason. That's why I'm always asking for numbers there. That written, there is one thing I disagree in your comment: Spending time and effort on researching is exactly what I would expect from someone that writes a book about something. In fact due to my own career I know how much effort it takes to get such things correct and what others expect there. I know that this take more time and effort than most people expect, but exactly that's what differentiate a good writing from something else. |
Quoting straight from the comment you linked:
I assume you'd be more satisfied with interpreting that as "they are not planning to move forward with an async interface until some of what they consider key blockers are removed at the language level". But, on a practical level, it doesn't change the conclusion - there was no first-party support for an async interface in But I fundamentally agree with you - writing a sufficiently detailed summary of that discussion would have required more space than I believed to be worth dedicating to the subject in that section of the book, which is why there is a direct link to the conversation. I have nothing else to add on the other points being mentioned that was not answered in my first comment and, as already mentioned, I'm not interested in engaging in a debate here considering how you chose to articulate your positions and opinions. I'll lock the thread. |
This part of the chapter is out-dated and contains quite a few interesting claims:
Firstly in the
Compile-time Safety
section it claims that bothdiesel
andsqlx
check your queries at compile time. That's true for trivial queries, but not for more complex ones or dynamic queries.Sqlx
obviously cannot check queries that are constructed at runtime. This includes common things like having anIN
expression with a dynamic value list. In addition there are known cases where theSqlx
query checking reports the wrong results, as that for example happens forLEFT JOIN
. There the nullability of expressions coming from the joined table is inferred incorrectly. In contrastdiesel
is able to check these cases correctly as well. In additiondiesel
also allows to build compile time checked queries that include conditional only at runtime known parts. Claiming that these guarantees seems to be a bit misleading.Secondly for the "Query Interface" part you describe that diesel uses a DSL while the other two crates use plain SQL. This section is likely that one that is influenced most by personal taste. While that it is correct that diesel uses a DSL, I do not thing that this gives the reader a honest way to evaluate how the diesel provided DSL looks like. Yes, diesel provides a DSL, but one that's close tho SQL. That means that yes you cannot transfer that code easily to any other framework without rewriting query queries. But you don't need to spend a huge amount of work to learn that DSL if you already know SQL. In addition transferring plain SQL queries from one framework to another one also normally requires basically rewriting at least all the locations that emit a query.
Later you claim that with diesel you might need to end up to write SQL for expression complex queries as a downside. You link the "Extending Diesel" guide there, which specifically shows how to extend diesel in such a way that you getting the compile time grantees given by diesel for custom extensions as well.
Thirdly the "Async Support" section. There is quite a lot to write here. So let's first start with the easy things: Diesel supports async now via the
diesel-async
crate. So as of today (and quite some time back) that section is factually incorrect. That written: You write thatdiesel
does not roll out async support in the near future (at the point of writing). That was even back than not correct. Given the discussion in the linked issue I would even say that it was back something between a gross simplification and a clear lie. Please correct that!On a more fundamental review this section does a really bad job explaining why you even need an async database interface in the first place. It talks about some general reasons why you might want to use an async web framework, but it does not really explain why your database library needs to be async as well. It states nebulously that using an async database library "give you less headaches", which is just not correct. There are well known solutions to prevent the outlined problem via an async connection pool (See
deadpool-diesel
) or similar patterns. Point is: It is relatively easy to prevent that from happening and there are existing crates for that. Beside of that: As that topic comes up again and again and again from a certain async hyper focused kind of people: Do you have any numbers to backup that claim at all? I haven't seen a good rust/diesel specific benchmark for that yet, which make all these async performance claims about database connections feel like magic fairy powder.All that written: I do not request you to update your whole book there. It's totally fine to say: I'm using sqlx because I'm liking their interface more or something like that. Just do not try to make up claims about alternatives that are untrue.
The text was updated successfully, but these errors were encountered: