-
Notifications
You must be signed in to change notification settings - Fork 53
fix: Modify mapper #209
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
fix: Modify mapper #209
Conversation
WalkthroughThe changes across multiple MyBatis XML mapper files simplify conditional checks for various boolean or flag fields. Previously, these conditions tested for both non-nullity and non-empty string values (e.g., Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Mapper
participant Database
Client->>Mapper: Submit query/update with parameters
Mapper->>Mapper: Check if field != null
alt Field is not null
Mapper->>Database: Include field in SQL WHERE/SET clause
else Field is null
Mapper->>Database: Exclude field from SQL clause
end
Database-->>Mapper: Return results/status
Mapper-->>Client: Return results/status
Poem
Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
base/src/main/resources/mappers/ComponentMapper.xml (1)
75-83
: Ensure query conditions are consistent
The corresponding<if>
tests inComponentByCondition
still includeand isOfficial!=''
,and isDefault!=''
, andand isTinyReserved!=''
. Consider removing these redundant empty‐string checks for consistency across your mapper.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
base/src/main/resources/mappers/AppMapper.xml
(5 hunks)base/src/main/resources/mappers/BlockHistoryMapper.xml
(2 hunks)base/src/main/resources/mappers/BlockMapper.xml
(2 hunks)base/src/main/resources/mappers/ComponentLibraryMapper.xml
(2 hunks)base/src/main/resources/mappers/ComponentMapper.xml
(1 hunks)base/src/main/resources/mappers/MaterialMapper.xml
(4 hunks)base/src/main/resources/mappers/PageHistoryMapper.xml
(4 hunks)base/src/main/resources/mappers/PageMapper.xml
(4 hunks)base/src/main/resources/mappers/PageTemplateMapper.xml
(4 hunks)base/src/main/resources/mappers/PlatformMapper.xml
(4 hunks)base/src/main/resources/mappers/UserMapper.xml
(4 hunks)
🔇 Additional comments (20)
base/src/main/resources/mappers/UserMapper.xml (1)
22-24
: Simplify boolean flag condition checks
Removed redundant empty‐string (!=''
) comparisons for the flag fields (isEnable
,isAdmin
,isPublic
) in both theUserByCondition
andUserSetColumns
SQL fragments. Conditions now only test for!=null
, which aligns with the intended wrapper‐type semantics and eliminates unnecessary string checks.Also applies to: 46-48, 49-51, 62-64, 87-89, 90-92
base/src/main/resources/mappers/AppMapper.xml (1)
85-87
: Streamline boolean flag conditions in App mapper
Removed redundant empty‐string checks (!=''
) for boolean/flag fields (isDefault
,canAssociate
,isPublish
,isDemo
) across theAppByCondition
andAppSetColumns
fragments. Now each<if>
only verifies!=null
, standardizing logic and reducing unnecessary evaluations.Also applies to: 115-117, 176-178, 209-210, 212-214, 242-244
base/src/main/resources/mappers/BlockMapper.xml (1)
57-59
: Simplify block‐flag null checks
Dropped redundant!=''
checks for the flag parameters (isOfficial
,isDefault
,isTinyReserved
) in bothBlockByCondition
andBlockSetColumns
. Conditions now only test for non‐nullity, aligning with typed boolean semantics and improving readability.Also applies to: 63-68, 148-150, 154-159
base/src/main/resources/mappers/BlockHistoryMapper.xml (1)
56-58
: Remove unnecessary empty‐string tests for history flags
Consolidated the<if>
tests forisOfficial
,isDefault
, andisTinyReserved
by removing!=''
checks in both the condition (BlockHistoryByCondition
) and update (BlockHistorySetColumns
) fragments. Now they only validate!=null
, matching the field definitions and simplifying the SQL.Also applies to: 62-67, 150-152, 156-161
base/src/main/resources/mappers/ComponentLibraryMapper.xml (1)
52-60
: Streamline component‐library flag checks
Removed redundant empty‐string validations (!=''
) for the boolean/flag fields (isStarted
,isOfficial
,isDefault
) in both theComponentLibraryByCondition
andComponentLibrarySetColumns
fragments. Conditions now solely check!=null
, which is appropriate for wrapper‐type parameters and cleans up the SQL mappings.Also applies to: 122-130
base/src/main/resources/mappers/ComponentMapper.xml (1)
172-180
: Remove redundant empty-string checks for boolean flags in update fragment
The<if>
conditions forisOfficial
,isDefault
, andisTinyReserved
now correctly only test for non-null values, which is sufficient for boolean/flag fields.base/src/main/resources/mappers/PageTemplateMapper.xml (2)
25-30
: Simplify boolean flag checks in query fragment
The<if>
tests forpublished
,publicStatus
, andisPreset
now only verify!= null
, which is appropriate for nullable boolean/flag fields.Also applies to: 37-39
83-88
: Simplify boolean flag checks in update fragment
The<if>
tests forpublished
,publicStatus
, andisPreset
have been correctly updated to only check for non-null values inPageTemplateSetColumns
.Also applies to: 95-97
base/src/main/resources/mappers/PlatformMapper.xml (2)
21-23
: Standardize null-only checks for boolean flags in query fragment
Removed redundant!=''
checks forisPublish
andisDefault
, leaving only!= null
, which aligns with handling boolean fields.Also applies to: 48-50
103-105
: Standardize null-only checks for boolean flags in update fragment
Updated<if>
tests forisPublish
andisDefault
to only test for non-null values inPlatformSetColumns
, matching the query fragment changes.Also applies to: 130-132
base/src/main/resources/mappers/PageHistoryMapper.xml (2)
34-36
: Remove redundant empty-string checks for flag fields in query fragment
The<if>
conditions forisBody
,isPage
, andisDefault
now only test for non-null, which is correct for boolean/flag fields.Also applies to: 46-48, 49-51
107-109
: Remove redundant empty-string checks for flag fields in update fragment
The<if>
tests forisBody
,isPage
, andisDefault
have been simplified to only check for non-null values inPageHistorySetColumns
.Also applies to: 119-124
base/src/main/resources/mappers/MaterialMapper.xml (2)
33-35
: Simplify null-only checks for boolean flags in query fragment
The<if>
conditions forisPublish
,isOfficial
,isDefault
, andisTinyReserved
now correctly only test for non-null values, removing the redundant!=''
checks.Also applies to: 51-53, 54-56, 57-59
118-120
: Simplify null-only checks for boolean flags in update fragment
Updated<if>
tests forisPublish
,isOfficial
,isDefault
, andisTinyReserved
to only validate non-nullity inMaterialSetColumns
, aligning with query fragment changes.Also applies to: 136-138, 139-141, 142-144
base/src/main/resources/mappers/PageMapper.xml (6)
29-31
: SimplifyisBody
condition
Removing the!=''
check is correct for a Boolean/flag field—testing onlyisBody != null
is sufficient and improves readability.
41-43
: SimplifyisPage
condition
The empty‐string comparison was redundant for a Boolean-like field; retaining justisPage != null
streamlines the SQL fragment without changing its behavior.
47-49
: SimplifyisDefault
condition
Dropping the string‐emptiness check is appropriate, sinceisDefault
represents a flag. The null check alone preserves correct filtering.
96-98
: SimplifyisBody
update clause
In the<set>
fragment, checking onlyisBody != null
suffices for a Boolean field and makes the mapper more concise.
108-110
: SimplifyisPage
update clause
Removing the!=''
portion is valid;isPage != null
alone correctly governs whether the column is included.
114-116
: SimplifyisDefault
update clause
TestingisDefault != null
by itself is sufficient for a flag field and reduces unnecessary complexity.
English | 简体中文
PR
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
Background and solution
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information
Summary by CodeRabbit