mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-22 12:19:24 +00:00
fix(h2): refine SQL condition check for custom database flag (#4216)
# Description of Changes - Refactored `H2SQLCondition.matches` to use `env.getProperty` with proper default values and types. - Adjusted logic to only return `false` when a custom database is enabled and datasource type is not `h2`. - Simplified environment variable handling for better readability and robustness. --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
parent
246a59a794
commit
c10474fd30
@ -8,16 +8,15 @@ public class H2SQLCondition implements Condition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||||
|
var env = context.getEnvironment();
|
||||||
boolean enableCustomDatabase =
|
boolean enableCustomDatabase =
|
||||||
Boolean.parseBoolean(
|
env.getProperty("system.datasource.enableCustomDatabase", Boolean.class, false);
|
||||||
context.getEnvironment()
|
|
||||||
.getProperty("system.datasource.enableCustomDatabase"));
|
|
||||||
|
|
||||||
if (!enableCustomDatabase) {
|
if (enableCustomDatabase) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dataSourceType = context.getEnvironment().getProperty("system.datasource.type");
|
String dataSourceType = env.getProperty("system.datasource.type", String.class, "");
|
||||||
return "h2".equalsIgnoreCase(dataSourceType);
|
return "h2".equalsIgnoreCase(dataSourceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user