-
Notifications
You must be signed in to change notification settings - Fork 61
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
feat(database): supports query database by tenantName、clusterNam and dataSourceName #4232
base: dev/4.3.x
Are you sure you want to change the base?
Conversation
...e/src/main/java/com/oceanbase/odc/service/connection/database/model/QueryDatabaseParams.java
Outdated
Show resolved
Hide resolved
...odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java
Outdated
Show resolved
Hide resolved
...odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java
Outdated
Show resolved
Hide resolved
...odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java
Outdated
Show resolved
Hide resolved
server/odc-service/src/main/java/com/oceanbase/odc/metadb/connection/DatabaseSpecs.java
Show resolved
Hide resolved
...odc-service/src/main/java/com/oceanbase/odc/service/connection/database/DatabaseService.java
Outdated
Show resolved
Hide resolved
.../odc-server/src/main/java/com/oceanbase/odc/server/web/controller/v2/DataBaseController.java
Outdated
Show resolved
Hide resolved
server/odc-service/src/main/java/com/oceanbase/odc/service/connection/ConnectionService.java
Outdated
Show resolved
Hide resolved
server/odc-service/src/main/java/com/oceanbase/odc/service/connection/ConnectionService.java
Show resolved
Hide resolved
be7421c
to
91e7e5b
Compare
server/odc-service/src/main/java/com/oceanbase/odc/service/connection/ConnectionService.java
Show resolved
Hide resolved
String clusterName) { | ||
long conditionCount = Stream.of(dataSourceName, tenantName, clusterName).filter(StringUtils::isNotBlank) | ||
.count(); | ||
if (conditionCount == 0L || conditionCount >= 2L) { |
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.
Why return empty set when conditionCount >= 2
?
It's tricky to use magic numbers 0L and 2L.
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.
I only need one condition at most, otherwise it doesn't fit the function
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.
Then just verify the conditionCount == 1, and throw an exception if not.
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.
👌
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.
BTW, this method is not readable. The caller is not aware that you only accept one of the parameters. Think about what you will do when you are required to accept more parameters in future features.
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.
BTW, this method is not readable. The caller is not aware that you only accept one of the parameters. Think about what you will do when you are required to accept more parameters in future features.
If there are multiple conditions, all I can think of is using Map, or using Function
, leaving the decision to the caller
What type of PR is this?
type-feature
What this PR does / why we need it:
Databases can be queried by tenantName, clusterName and dataSourceName