Skip to content

Commit fe8bc48

Browse files
committed
Fix cases where end date isn't null when tenant is null
1 parent 10a1d88 commit fe8bc48

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

realty-common/src/main/java/io/github/md5sha256/realty/database/maria/mapper/MariaLeaseholdContractMapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ AND lc.endDate < NOW()
137137
@Update("""
138138
UPDATE LeaseholdContract
139139
SET tenantId = NULL,
140+
startDate = NULL,
141+
endDate = NULL,
140142
currentMaxExtensions = CASE WHEN maxExtensions IS NOT NULL THEN 0 ELSE NULL END
141143
WHERE leaseholdContractId = #{leaseholdContractId}
142144
""")
@@ -174,6 +176,8 @@ int updateLandlordByRegion(@Param("worldGuardRegionId") @NotNull String worldGua
174176
INNER JOIN Contract c ON c.contractId = lc.leaseholdContractId AND c.contractType = 'leasehold'
175177
INNER JOIN RealtyRegion rr ON rr.realtyRegionId = c.realtyRegionId
176178
SET lc.tenantId = #{tenantId},
179+
lc.startDate = CASE WHEN #{tenantId} IS NULL THEN NULL ELSE lc.startDate END,
180+
lc.endDate = CASE WHEN #{tenantId} IS NULL THEN NULL ELSE lc.endDate END,
177181
lc.currentMaxExtensions = CASE
178182
WHEN #{tenantId} IS NULL AND lc.maxExtensions IS NOT NULL THEN 0
179183
ELSE lc.currentMaxExtensions

0 commit comments

Comments
 (0)