Skip to content

Conversation

ku1551
Copy link
Contributor

@ku1551 ku1551 commented Jul 10, 2025

Summary

This PR adds a unit test to ensure that <choose> with <when> conditions correctly falls back to <otherwise> when a parameter is missing or null.

Motivation

While MyBatis already appears to handle OGNL evaluation with missing parameters gracefully, there wasn't an explicit test to guarantee this behavior.

By adding this test, we can be more confident that:

  • When name is not provided, the when condition fails safely.
  • The otherwise clause executes as expected, producing AND status = 'ACTIVE'.

Details

  • Added ChooseWhenTest under submitted.choosewhen to verify this edge case.
  • Uses H2 in-memory database and CreateDB.sql for test setup.

Notes

I wanted to provide a clear test case that proves <choose> properly falls back to <otherwise>.
This improves test coverage and helps ensure future refactoring doesn't accidentally break this logic.


Let me know if you'd like any adjustments!

@hazendaz hazendaz closed this Aug 24, 2025
@hazendaz hazendaz reopened this Aug 24, 2025
@coveralls
Copy link

Coverage Status

coverage: 87.299% (-0.009%) from 87.308%
when pulling ddc75d7 on ku1551:feature/choosewhen-test
into 05558e2 on mybatis:master.

@hazendaz hazendaz merged commit 6bb9982 into mybatis:master Aug 24, 2025
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants