-
Notifications
You must be signed in to change notification settings - Fork 132
#189 - Accept StatementFilterFunction in DatabaseClient #308
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
Conversation
876a49e
to
309ccd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor issues and once more I'm not happy with a name without a real good alternative.
I also rebased and prepared two polishing commits.
@@ -134,7 +134,7 @@ In JDBC, the actual drivers translate `?` bind markers to database-native marker | |||
|
|||
Spring Data R2DBC lets you use native bind markers or named bind markers with the `:name` syntax. | |||
|
|||
Named parameter support leverages a `R2dbcDialect` instance to expand named parameters to native bind markers at the time of query execution, which gives you a certain degree of query portability across various database vendors. | |||
Named parameter support leverages a `R2dbcDialect` instance to expand named parameters to native bind markers at the time of query execution, which gives you a certain degree of query portability across various database vendors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I like the name filter
. I would expect it to accept a Predicate
.
I don't have a name I really like but maybe somthing like registerStatementCallback
, or modifyStatement
?
Or to go with the more functional nomenclature it would be a map
, maybe a mapStatement
?
Map<String, SettableValue> byName, Supplier<String> sqlSupplier) { | ||
return createTypedExecuteSpec(byIndex, byName, sqlSupplier, this.typeToRead); | ||
Map<String, SettableValue> byName, Supplier<String> sqlSupplier, StatementFilterFunction filterFunction) { | ||
return createTypedExecuteSpec(byIndex, byName, sqlSupplier, filterFunction, this.typeToRead); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typeToRead
is nullable but gets passed as an argument to a parameter which is not nullable and eventually actually gets dereferenced.
I'm not sure if there is something really wrong or if the nullability annotations need tweaking.
this.byIndex = byIndex; | ||
this.byName = byName; | ||
this.sqlSupplier = sqlSupplier; | ||
this.filterFunction = filterFunction; | ||
} | ||
|
||
<T> FetchSpec<T> exchange(Supplier<String> sqlSupplier, BiFunction<Row, RowMetadata, T> mappingFunction) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually about the line Function<Connection, Statement> executeFunction = it -> {
a few lines down.
It now clashes awkwardly with ExecuteFunction
and the member of that type also named executeFunction
. I think something should get a name change here.
We now accept StatementFilterFunction and ExecuteFunction via DatabaseClient to filter Statement execution. StatementFilterFunctions can be used to pre-process the statement or post-process Result objects. databaseClient.execute(…) .filter((s, next) -> next.execute(s.returnGeneratedValues("my_id"))) .filter((s, next) -> next.execute(s.fetchSize(25))) databaseClient.execute(…) .filter(s -> s.returnGeneratedValues("my_id")) .filter(s -> s.fetchSize(25))
Made assertions in tests more strict.
Refactored DefaultDatabaseClientUnitTests in order to make the relevant differences in setup easier to spot.
Fix nullability annotations. Relax generics at DatabaseClient.StatementFilterSpec.filter(…).
We now accept StatementFilterFunction and ExecuteFunction via DatabaseClient to filter Statement execution. StatementFilterFunctions can be used to pre-process the statement or post-process Result objects. databaseClient.execute(…) .filter((s, next) -> next.execute(s.returnGeneratedValues("my_id"))) .filter((s, next) -> next.execute(s.fetchSize(25))) databaseClient.execute(…) .filter(s -> s.returnGeneratedValues("my_id")) .filter(s -> s.fetchSize(25)) Original pull request: #308.
Made assertions in tests more strict. Original pull request: #308.
Refactored DefaultDatabaseClientUnitTests in order to make the relevant differences in setup easier to spot. Original pull request: #308.
Fix nullability annotations. Relax generics at DatabaseClient.StatementFilterSpec.filter(…). Original pull request: #308.
Minor formatting. Original pull request: #308.
That's merged. Thanks. |
We now accept
StatementFilterFunction
andExecuteFunction
viaDatabaseClient
to filter Statement execution. StatementFilterFunctions can be used to pre-process the statement or post-process Result objects.Related ticket: #189.