Skip to content

Commit

Permalink
upgrade(version): 0.0.4 适配 nacos 2.4.1
Browse files Browse the repository at this point in the history
注意更新SQL , users 表字段不兼容
  • Loading branch information
lltx committed Aug 25, 2024
1 parent e196290 commit c7f3023
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Nacos 从 2.2.0 版本开始,可通过 SPI 机制注入多数据源实现插件,
|---------------|-------|
| 2.2.0 - 2.3.0 | 0.0.2 |
| 2.3.1 - 2.3.2 | 0.0.3 |
| 2.4.0 - 2.4.1 | 0.0.4 |

```xml
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.pig4cloud.plugin</groupId>
<artifactId>nacos-datasource-plugin-pg</artifactId>
<version>0.0.3</version>
<version>0.0.4</version>
<name>nacos-datasource-plugin-pg</name>
<description>nacos-datasource-plugin-pg</description>
<url>https://pig4cloud.com</url>
Expand All @@ -23,7 +23,7 @@
</licenses>

<properties>
<nacos.version>2.3.2</nacos.version>
<nacos.version>2.4.1</nacos.version>
<spring.checkstyle.plugin>0.0.32</spring.checkstyle.plugin>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,14 @@ public String count(List<String> where) {
return sql.toString();
}

/**
* Get function by functionName.
* @param functionName functionName
* @return function
*/
@Override
public String getFunction(String functionName) {
return TrustedPgFunctionEnum.getFunctionByName(functionName);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.pig4cloud.plugin.impl.postgresql;

import java.util.HashMap;
import java.util.Map;

/**
* @author lengleng
* @date 2024/8/25
*/
public enum TrustedPgFunctionEnum {

/**
* NOW().
*/
NOW("NOW()", "NOW()");

private static final Map<String, TrustedPgFunctionEnum> LOOKUP_MAP = new HashMap<>();

static {
for (TrustedPgFunctionEnum entry : TrustedPgFunctionEnum.values()) {
LOOKUP_MAP.put(entry.functionName, entry);
}
}

private final String functionName;

private final String function;

TrustedPgFunctionEnum(String functionName, String function) {
this.functionName = functionName;
this.function = function;
}

/**
* Get the function name.
* @param functionName function name
* @return function
*/
public static String getFunctionByName(String functionName) {
TrustedPgFunctionEnum entry = LOOKUP_MAP.get(functionName);
if (entry != null) {
return entry.function;
}
throw new IllegalArgumentException(String.format("Invalid function name: %s", functionName));
}

}

0 comments on commit c7f3023

Please sign in to comment.