Skip to content

Replace match any regex with always true condition #217

@elliVM

Description

@elliVM

Description
Java objects that generate JOOQ conditions sometimes support wildcards, when the compared value is just a wildcard to match any a true condition could be used instead.

Use case or motivation behind the feature request
Change simplifies resulting conditions and helps the SQL engine to avoid string comparisons.

Related issues

Additional context
if column is nullable a NOT NULL condition could be used.

example of simplification

(
  "streamdb"."stream"."directory" like '%'
  or (
    "streamdb"."stream"."directory" like 'haproxy'
    and "streamdb"."stream"."stream" like 'example:haproxy:haproxy'
  )
)

would be simplified into

(
  "streamdb"."stream"."directory" like 'haproxy'
  and "streamdb"."stream"."stream" like 'example:haproxy:haproxy'
)

results from

if ("*".equalsIgnoreCase(value)) {
    condition = DSL.trueCondition(); // added always true condition
    } 
else {
    condition = STREAMDB.STREAM.DIRECTORY.like(value.replace('*', '%'));
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions