-
Notifications
You must be signed in to change notification settings - Fork 62
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
MySQL Exists statement Support #1760
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b4eba14
Remove custom exists queries and use jpql to have spring do queries b…
aindriu-aiven de365e4
Run spotless:apply
aindriu-aiven 09dc24b
Update to recitfy exists statement that had a not clause in it.
aindriu-aiven 1bea3ba
Use a converter to ensure that the data is converted correctly from t…
aindriu-aiven 45f92bc
Merge branch 'main' into issue-mysql-support-remove-custom-exists
aindriu-aiven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
core/src/main/java/io/aiven/klaw/helpers/AclIPPrincipleTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.aiven.klaw.helpers; | ||
|
||
import io.aiven.klaw.model.enums.AclIPPrincipleType; | ||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
@Converter | ||
public class AclIPPrincipleTypeConverter | ||
implements AttributeConverter<AclIPPrincipleType, Integer> { | ||
|
||
@Override | ||
public Integer convertToDatabaseColumn(AclIPPrincipleType aclIPPrincipleType) { | ||
if (aclIPPrincipleType == null) { | ||
return null; | ||
} | ||
|
||
return aclIPPrincipleType.ordinal(); | ||
} | ||
|
||
@Override | ||
public AclIPPrincipleType convertToEntityAttribute(Integer ordinalAclIpPrincipalType) { | ||
if (ordinalAclIpPrincipalType == null) { | ||
return null; | ||
} | ||
return switch (ordinalAclIpPrincipalType) { | ||
case 0 -> AclIPPrincipleType.IP_ADDRESS; | ||
case 1 -> AclIPPrincipleType.PRINCIPAL; | ||
case 2 -> AclIPPrincipleType.USERNAME; | ||
default -> null; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,19 +34,11 @@ boolean existsSchemaRequestByEnvironmentAndTenantId( | |
boolean existsSchemaRequestByEnvironmentAndTenantIdAndRequestStatus( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not part of this change, but an unused method, can be deleted. |
||
String envId, Integer tenantId, String requestStatus); | ||
|
||
@Query( | ||
value = | ||
"select exists(select 1 from kwschemarequests where teamid = :teamId and tenantid = :tenantId and topicstatus='created')", | ||
nativeQuery = true) | ||
boolean existsRecordsCountForTeamId( | ||
@Param("teamId") Integer teamId, @Param("tenantId") Integer tenantId); | ||
boolean existsByTeamIdAndTenantIdAndRequestStatus( | ||
Integer teamId, Integer tenantId, String topicStatus); | ||
|
||
@Query( | ||
value = | ||
"select exists(select 1 from kwschemarequests where (requestor = :userId) and tenantid = :tenantId and topicstatus='created')", | ||
nativeQuery = true) | ||
boolean existsRecordsCountForUserId( | ||
@Param("userId") String userId, @Param("tenantId") Integer tenantId); | ||
boolean existsByRequestorAndTenantIdAndRequestStatus( | ||
String requestor, Integer tenantId, String requestStatus); | ||
|
||
List<SchemaRequest> findAllByTenantId(int tenantId); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
adding request status parameter intentional ?
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.
Yes it was hard coded in the native query for the requests it is checking if there is an open request for that team