It does not make sense to force driver implementors to build an abstraction on top of native parameter placeholders. That’s a library feature, not a driver one.
+1I understand that supporting a generic binding marker would make the driver implementations more complex, but without that the complexity is delegated on the libraries built on top of R2DBC, which will result in libraries that only support some databases, which is very bad for the ecosystem.
El lunes, 8 de abril de 2019, 9:45:57 (UTC+2), Lukas Eder escribió:Hello,I'd like to follow up on the discussion in these tweets:I must have misunderstood R2DBC's strategy here in the past, otherwise, I would have raised this issue before. To my (current) understanding, R2DBC does not plan on imposing the support of JDBC's bind marker syntax on R2DBC drivers. So, statements likeSELECT * FROM t WHERE id = ?will work only if a driver chooses to implement that syntax at its own discretion, but that's not a requirement. Instead, drivers are encouraged to enforce their vendor specific syntax instead, such as:-- Oracle and othersSELECT * FROM t WHERE id = :1SELECT * FROM t WHERE id = :name-- SQL ServerSELECT * FROM t WHERE id = @name-- PostgreSQLSELECT * FROM t WHERE id = $1I think this is a mistake. Part of JDBC's success, in my opinion, is this standardisation of bind markers. It was always possible in JDBC to use vendor specific markers as the drivers could map indexes to names if they chose to support that. This made JDBC much easier to learn than if vendor specificity had to be documented everywhere. Note that driver implementors were always free to still support their database native syntax as well.I understand Mark's feedback on Twitter, of course:It does not make sense to force driver implementors to build an abstraction on top of native parameter placeholders. That’s a library feature, not a driver one.But nothing prevents R2DBC from offering an out of the box implementation that maps ? to ?1, :1, $1, or whatever syntax a vendor supports, via an SPI. While this is a minor hassle for driver implementors (they've somehow managed for 22 years now), it's quite a hassle for API users. I know that a lot of people in the R2DBC team think that R2DBC will be mainly used by higher level abstractions and libraries, but I trust that end users will differ and also use R2DBC directly, just like JDBC has always been used directly.Lukas
--
You received this message because you are subscribed to the Google Groups "r2dbc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r2dbc+un...@googlegroups.com.
To post to this group, send email to r2...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/r2dbc/c5c23989-1b10-46e7-85f6-277e0f7c2905%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'd have to agree. That said please don't make it '?' This is already an overloaded operator in PostgreSQL
Thanks for continuing the discussion on our ML.I see a few forces in this discussion and I'd like to hear more why you think we should (re)introduce standardized bind markers.Here are my thoughts:* Bind markers are a user-facing feature. We intentionally keep R2DBC SPI minimal and aim for encapsulation of just the database specifics in drivers. We do not want each driver vendor to put a user-specific abstraction into their drivers.
* You could argue the same way about R2DBC Connection URL. It's one of the most prominent user-facing features. We decided here to solve that requirement once within R2DBC so that drivers don't need to deal with URL parsing and come up with fancy connection URLs.
* There's a certain level of SQL portability. Probably most CRUD applications. When starting with pagination, it already starts getting difficult.
* We consider SQL portability as client library or even application-level concern. There are a ton of JDBC clients that address various areas of SQL database access: Connection/Transaction management, SQL query repository (e.g. lookup/construction of SQL queries), SQL query builders, CRUD tools, object (relational) mappers. Each library has its specifics. It either passes-thru SQL (portability/store-specifics are an application-level concern), build SQL (specifics are a library concern) or introduce their own query language (specifics are a library concern).From that perspective, R2DBC usage requires an extension of dialect-specific support in SQL builder-like libraries and object (relational) mappers. Users are shielded from this requirement because there's a library in front of them.SQL query repositories and direct SQL usage require a bit effort on the application development side and potentially more for simple portable queries that are not dialect-specific.
In any case, we're talking about new applications and we're not breaking code because that applications do not exist yet.
* I fear it does not matter which syntax we chose, there's likely a database that will have issues with it.
* As a comparison: Every other programming language uses native markers (or they don't use markers at all and materialize values in the actual query which opens up the path to potential vulnerabilities)
* As a comparison: Every other programming language uses native markers (or they don't use markers at all and materialize values in the actual query which opens up the path to potential vulnerabilities)
Cheers,Mark
Am Montag, 8. April 2019 12:57:22 UTC+2 schrieb Lukas Eder:On Mon, Apr 8, 2019 at 12:39 PM Dave Cramer <davec...@gmail.com> wrote:I'd have to agree. That said please don't make it '?' This is already an overloaded operator in PostgreSQLThat's quite an edge case in ordinary PostgreSQL usage, just like in Oracle and the SQL Standard, where '?' became a syntax element for MATCH_RECOGNIZE. Notice that Oracle and the ISO standards committee are working on defining a standard escape sequence for these cases, which will be useful given how significant '?' is in JDBC:I think that deviating from '?' as the default is not necessarily wise, as there will most definitely some other conflict with some other syntax by some other vendor that will probably not be foreseen. The limitations of '?' have been understood by now. In PostgreSQL, for example, there's often a workaround for not being able to use '?' through JDBC, e.g.:
--
You received this message because you are subscribed to the Google Groups "r2dbc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r2dbc+un...@googlegroups.com.
To post to this group, send email to r2...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/r2dbc/9c037760-1857-4d02-8c53-3ecb023c4f0b%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/r2dbc/CAEiFUmYQM11%3DF68tMDxn%2BzXToDcvc6xd_vwiC0mRnd5Uba3A7A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
I do, to some extent, see R2DBC as an opportunity for a revolution. There are certain places (like three different kinds of Statements) where I think challenging the status quo is a good idea. But I'm not a fan of tossing out everything JDBC just because.
This marker syntax thing is quite interesting to me in this respect. I took this idea from one of ADBA's primary design goals, as the idea that there was no "portable enough" SQL that _could_ be shared with a generic bind marker. I'd always assumed that the ORM's wrote hyper-optimized SQL for each dialect and going a step further and asking them to dialect their bind markers wouldn't be too much to ask.
Now you, a true expert in the field, come back and point out that this isn't true and that there are large swathes of SQL that can be written "portably enough" to warrant a generic bind parameter. With that knowledge, I'm open to adding it to R2DBC. The question in my mind is how much of this is a hang-over from existing JDBC implementations (a bit of Stockholm Syndrome) versus what is an ideal situation a couple of years from now.
I think the best way to explore this today is trying to split the difference and adding a proxy implementation that applies a JDBC compatibility layer to the SQL going by. Exploring the solution this way gives us a couple of benefits as I see it. In one case it turns out that this compatibility behavior isn't necessary in the long term (as more clients join up) and its use becomes optional and decreasing. In the other case it turns out compatibility is *critical* for clients and we've managed to implement it in a really decoupled way so it can be included as part of the spec implementation (not the drivers) or used by the drivers as a library. Either outcome seems reasonable.
Separately, to my mind, the discussion about JDBC URL compatibility is much more fraught. I totally understand and deeply appreciate the benefits to understanding existing JDBC URIs. At the same time, I've got 15 years of experience and customer complaints about how inscrutable and inconsistently parsed those URIs are. I think there's very significant value to a better definition of database connection URIs and given that each R2DBC driver would need to mimic the same parsing behaviors and oddities but with new code, I'm not sure how to rate the value compatibility provides. It is worth thinking about some more though as slotting into the existing world is appealing.