Skip to content

Add support for Criteria composition #289

Closed

Description

@FlatMapIO

Criteria.where(Condition) will support the construction of dynamic where clauses.

val noCondition = Conditions.just("1 = 1")
val condition = noCondition.and("name = :name").or(...)
client.select()
            .from("table")
            .matching(Criteria.where(condition))
            .fetch()

Activity

  1. changed the title [-]Criteria support initial condition.[/-] [+]Criteria.where() support initial condition.[/+] on Jan 26, 2020
  2. mp911de commented on Jan 27, 2020

    @mp911de
    Member

    Thanks for the ticket. These are actually two different requirements here. First, Criteria.where(…). The second one deals with the fact of introducing the SQL DSL API into the criteria API.

    Spring Data R2DBC uses the SQL DSL on a lower abstraction level to create statements by considering dialect-specifics. The example name = :name does not work here. Named parameters are resolved only for plain queries via the execute(…) API. Furthermore,

    client.select()
                .from("table")
                .matching(Criteria.where(condition))
                .fetch()
    

    does not accept parameter bindings as we expect parameters to be passed in through the Criteria object. So there's no way how we could bind the parameter.

    The Criteria API was built to help with simple use-cases. It makes sense to introduce an empty Criteria object via Criteria.empty() that allows composition without the code to consider whether you're constructing the first or a subsequent Criteria segment.

  3. added this to the 1.1 M4 (Neumann) milestone on Feb 18, 2020
  4. changed the title [-]Criteria.where() support initial condition.[/-] [+]Add support for Criteria composition[/+] on Feb 18, 2020
  5. added 2 commits that reference this issue on Feb 18, 2020
  6. linked a pull request that will close this issueAdd support for Criteria composition #307on Feb 18, 2020
  7. added and removed
    for: team-attentionAn issue we need to discuss as a team to make progress
    on Feb 18, 2020
  8. added a commit that references this issue on Mar 9, 2020
  9. added 2 commits that reference this issue on Mar 10, 2020
  10. schauder commented on Mar 10, 2020

    @schauder
    Contributor

    Done.

  11. added a commit that references this issue on Mar 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions