Skip to content

Introduce QueryCriterion.isEqualTo (Kotlin-friendly alias for is) - #949

Merged
alexander-yevsyukov merged 9 commits into
masterfrom
query-criterion-is-equal-to
Jun 23, 2026
Merged

Introduce QueryCriterion.isEqualTo (Kotlin-friendly alias for is)#949
alexander-yevsyukov merged 9 commits into
masterfrom
query-criterion-is-equal-to

Conversation

@alexander-yevsyukov

@alexander-yevsyukov alexander-yevsyukov commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Introduces QueryCriterion.isEqualTo(V), carrying the behavior previously
implemented by is(V), and makes is(V) delegate to it.

isEqualTo is now the canonical "equals" criterion. is is documented as a
short form of it — a convenience wrapper for working with a QueryCriterion
from Java.

Why

Calling is(...) from Kotlin is awkward: is is a reserved word there, so
the call has to be wrapped in backticks:

builder.where(column).`is`(value)      // before — backticks required
builder.where(column).isEqualTo(value) // now — reads cleanly

isEqualTo reads naturally from both Java and Kotlin, while is stays
available (and convenient) for Java callers.

Changes

  • QueryCriterion.isEqualTo(V) — new canonical method (null-check + EQUALS
    parameter), inherited by EntityCriterion and RecordCriterion.
  • QueryCriterion.is(V) — now delegates to isEqualTo; KDoc/Javadoc updated to
    describe it as the Java-convenient short form and to point Kotlin callers to
    isEqualTo.
  • RecordQueryBuilderTest — new IsEqualToAlias tests: isEqualTo appends an
    EQUALS parameter, and yields the same parameter as is.

is is intentionally not deprecated — it remains a first-class Java-side
short form.

Build fix (unrelated pre-existing CI flake)

While verifying this PR, CI's Build on Ubuntu failed with ~30–80 failures in
packages unrelated to this change (io.spine.type, io.spine.base,
io.spine.protobuf, io.spine.code) — io.spine.type.KnownTypes loading an
incomplete descriptor set. Zero io.spine.query tests were affected.

Root cause (reproduced deterministically, independent of the isEqualTo
change): generateProto/generateTestProto delete com.google files from
their own output directory in a doLast action. That mutation is not reproduced
when the task is restored from the Gradle build cache, so a cached
restoration leaves an inconsistent descriptor set on the test classpath and
KnownTypes loads a partial type set. This is why master (cache miss →
executed → green) and a branch that restored the cache entry (cache hit → red)
behaved differently — pure cache-population order, not the code change.

Fix: opt those tasks out of the build cache (outputs.cacheIf { false }) so they
always execute and the deletion is always applied. Verified: with the cache
enabled, clean build now passes 3/3 (previously failed deterministically when
generateTestProto was restored from cache).

Testing

  • ./gradlew :base:test --tests "io.spine.query.*"133/133 pass (incl. the
    two new tests).
  • ./gradlew clean build (cache enabled) → green and deterministic after the
    build fix.

Review notes

  • spine-code-review and review-docs reviewed the isEqualTo change;
    spine-code-review reviewed the build fix — all APPROVE.
  • Version bumped 2.0.0-SNAPSHOT.4202.0.0-SNAPSHOT.421.

🤖 Generated with Claude Code

alexander-yevsyukov and others added 5 commits June 18, 2026 18:22
`isEqualTo` is now the canonical "equals" criterion. It carries the
behavior previously implemented by `is`, and `is` delegates to it.

`is` is documented as a short form of `isEqualTo`, convenient when
working with a `QueryCriterion` from Java. Kotlin callers should prefer
`isEqualTo`, because `is` is a reserved word in Kotlin and calling it
requires wrapping the method name in backticks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces QueryCriterion.isEqualTo(V) as a Kotlin-friendly, canonical equality criterion while keeping is(V) as a Java-convenient short form that now delegates to isEqualTo.

Changes:

  • Added QueryCriterion.isEqualTo(V) and made is(V) delegate to it (preserving behavior and null-checking).
  • Updated Javadoc/KDoc to guide Kotlin callers to isEqualTo while retaining is as the Java short form.
  • Added tests verifying isEqualTo produces an EQUALS parameter and matches is, plus bumped snapshot version and regenerated dependency reports.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
base/src/main/java/io/spine/query/QueryCriterion.java Adds isEqualTo() as the canonical equality criterion and makes is() delegate to it with updated docs.
base/src/test/java/io/spine/query/RecordQueryBuilderTest.java Adds coverage ensuring isEqualTo() appends EQUALS and matches is().
version.gradle.kts Bumps published snapshot version to .421.
docs/dependencies/pom.xml Regenerates dependency POM with the new snapshot version.
docs/dependencies/dependencies.md Regenerates dependency report to reflect the new snapshot version and generation timestamp.

Comment thread base/src/main/java/io/spine/query/QueryCriterion.java Outdated
Comment thread base/src/main/java/io/spine/query/QueryCriterion.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@alexander-yevsyukov alexander-yevsyukov left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude[agent], please see my comments.


@Nested
@DisplayName("treat `is` as a short form of `isEqualTo`")
final class IsEqualToAlias {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the class to IsEqualTo.

}

@Nested
@DisplayName("treat `is` as a short form of `isEqualTo`")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the display name read: "support filtering by given values".

}

@Test
@DisplayName("producing the same parameter as `is`")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change the display name to: "providing is alias for isEqualTo".

@Claude

Claude AI commented Jun 23, 2026

Copy link
Copy Markdown

@alexander-yevsyukov Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 1767437e-73a5-467e-befc-4f2a41bc7002

Sorry for the inconvenience!

…ness

The `generateProto`/`generateTestProto` tasks delete `com.google` files
from their own output directory in a `doLast` action. That mutation is not
reproduced when a task is restored from the Gradle build cache, so a cached
restoration leaves an inconsistent descriptor set on the test classpath and
`io.spine.type.KnownTypes` loads an incomplete set of types.

This intermittently failed ~30-80 tests unrelated to the change under test,
in `io.spine.type`, `io.spine.base`, `io.spine.protobuf`, and
`io.spine.code` (e.g. PR #949's Ubuntu CI), depending on whether the build
cache had a hit for these tasks. It is why `master` (cache miss, executed)
stayed green while a branch that restored the cache entry went red.

Marking the tasks non-cacheable makes them always execute, so the deletion
is always applied and the descriptor set is consistent. Verified: with the
build cache enabled, `clean build` now passes 3/3 with `generateTestProto`
always executed; previously it failed deterministically when the task was
restored from cache.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 02:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment on lines +106 to +109
/**
* Appends an associated query builder with a criterion checking that the value
* of the associated column equals to the one provided.
*
Comment thread base/build.gradle.kts
Comment on lines +104 to +108
// downstream descriptor set on the test classpath) that differs from a
// fresh run, intermittently leaving `io.spine.type.KnownTypes` with an
// incomplete set of types. Opt this task out of the build cache so it
// always executes and the deletion is always applied.
outputs.cacheIf { false }
Apply the same `equals to` -> `equals` correction to `is` that was made
for `isEqualTo`, so the two duplicated summary sentences stay consistent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@SpineEventEngine SpineEventEngine deleted a comment from Claude AI Jun 23, 2026
@SpineEventEngine SpineEventEngine deleted a comment from Claude AI Jun 23, 2026
@SpineEventEngine SpineEventEngine deleted a comment from Claude AI Jun 23, 2026
@SpineEventEngine SpineEventEngine deleted a comment from Claude AI Jun 23, 2026
@SpineEventEngine SpineEventEngine deleted a comment from Claude AI Jun 23, 2026
- Rename the nested test class `IsEqualToAlias` to `IsEqualTo`.
- Class display name -> "support filtering by given values".
- `matchIs` display name -> "providing `is` alias for `isEqualTo`".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 02:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread base/build.gradle.kts
Comment on lines +105 to +107
// fresh run, intermittently leaving `io.spine.type.KnownTypes` with an
// incomplete set of types. Opt this task out of the build cache so it
// always executes and the deletion is always applied.
@alexander-yevsyukov
alexander-yevsyukov merged commit 43b5585 into master Jun 23, 2026
8 checks passed
@alexander-yevsyukov
alexander-yevsyukov deleted the query-criterion-is-equal-to branch June 23, 2026 08:57
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in v2.0 Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants