-
Notifications
You must be signed in to change notification settings - Fork 1
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
add: 新增easy-orm对clickhouse支持 #1
base: main
Are you sure you want to change the base?
Changes from 1 commit
efc3a90
ce44317
c046f58
8f8b887
f855a1d
3b79b74
70057e8
5a8fa4a
e39e1d7
6ad7bf0
bffd0fc
0f2c2d9
72d3914
385ab77
9af65be
2cd2c51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.hswebframework</groupId> | ||
<artifactId>hsweb-incubator-easyorm-clickhouse</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<hsweb.framework.version>4.0.17-SNAPSHOT</hsweb.framework.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.hswebframework.web</groupId> | ||
<artifactId>hsweb-commons-crud</artifactId> | ||
<version>${hsweb.framework.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webflux</artifactId> | ||
<version>5.3.25</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package org.hswebframework.ezorm.rdb.metadata.dialect; | ||
|
||
import org.hswebframework.ezorm.core.meta.Feature; | ||
import org.hswebframework.ezorm.core.utils.StringUtils; | ||
import org.hswebframework.ezorm.rdb.metadata.DataType; | ||
import org.hswebframework.ezorm.rdb.metadata.RDBColumnMetadata; | ||
import org.hswebframework.ezorm.rdb.metadata.RDBFeatureType; | ||
import org.hswebframework.ezorm.rdb.metadata.dialect.DataTypeBuilder; | ||
import org.hswebframework.ezorm.rdb.supports.clickhouse.ClickhouseDialect; | ||
|
||
import java.sql.SQLType; | ||
import java.util.Optional; | ||
|
||
/** | ||
* @author dengpengyu | ||
* @date 2023/9/18 16:14 | ||
*/ | ||
public interface Dialect extends Feature { | ||
|
||
@Override | ||
default RDBFeatureType getType() { | ||
return RDBFeatureType.dialect; | ||
} | ||
|
||
void addDataTypeBuilder(String typeId, DataTypeBuilder mapper); | ||
|
||
String buildColumnDataType(RDBColumnMetadata columnMetaData); | ||
|
||
String getQuoteStart(); | ||
|
||
String getQuoteEnd(); | ||
|
||
String clearQuote(String string); | ||
|
||
boolean isColumnToUpperCase(); | ||
|
||
Optional<SQLType> convertSqlType(Class<?> type); | ||
|
||
DataType convertDataType(String dataType); | ||
|
||
default String quote(String keyword, boolean changeCase) { | ||
if (keyword.startsWith(getQuoteStart()) && keyword.endsWith(getQuoteEnd())) { | ||
return keyword; | ||
} | ||
return StringUtils.concat( | ||
getQuoteStart(), | ||
isColumnToUpperCase() && changeCase ? keyword.toUpperCase() : keyword, | ||
getQuoteEnd() | ||
); | ||
} | ||
|
||
default String quote(String keyword) { | ||
return quote(keyword, true); | ||
} | ||
|
||
default String buildColumnFullName(String tableName, String columnName) { | ||
if (columnName.contains(".")) { | ||
return columnName; | ||
} | ||
if (StringUtils.isNullOrEmpty(tableName)) { | ||
return StringUtils.concat(getQuoteStart(), isColumnToUpperCase() ? columnName.toUpperCase() : columnName, getQuoteEnd()); | ||
} | ||
return StringUtils.concat(tableName, ".", getQuoteStart(), isColumnToUpperCase() ? columnName.toUpperCase() : columnName, getQuoteEnd()); | ||
} | ||
|
||
ClickhouseDialect CLICKHOUSE = new ClickhouseDialect(); | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import java.sql.Date; | ||
import java.sql.JDBCType; | ||
|
||
/** | ||
* @className ClickhouseDire | ||
* @Description TODO | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
/** | ||
* @author dengpengyu | ||
*/ | ||
|
||
/** | ||
* @className ClickhouseUpdateSqlBuilder | ||
* @Description TODO | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,8 @@ | |
import org.hswebframework.ezorm.rdb.metadata.RDBDatabaseMetadata; | ||
import org.hswebframework.ezorm.rdb.metadata.RDBSchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.metadata.dialect.Dialect; | ||
import org.hswebframework.ezorm.rdb.supports.clickhouse.ClickhouseDialect; | ||
import org.hswebframework.ezorm.rdb.supports.clickhouse.ClickhouseSchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.supports.h2.H2SchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.supports.mssql.SqlServerSchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.supports.mysql.MysqlSchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.supports.oracle.OracleSchemaMetadata; | ||
import org.hswebframework.ezorm.rdb.supports.postgres.PostgresqlSchemaMetadata; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
import java.util.Arrays; | ||
|
@@ -23,7 +19,7 @@ | |
@Data | ||
public class EasyormProperties { | ||
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. 不应该覆盖原是包名以及类 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. 好的 |
||
|
||
private String defaultSchema="PUBLIC"; | ||
private String defaultSchema = "PUBLIC"; | ||
|
||
private String[] schemas = {}; | ||
|
||
|
@@ -33,7 +29,7 @@ public class EasyormProperties { | |
|
||
private boolean allowTypeAlter = true; | ||
|
||
private DialectEnum dialect = DialectEnum.h2; | ||
private DialectEnum dialect = DialectEnum.clickhouse; | ||
|
||
private Class<? extends Dialect> dialectType; | ||
|
||
|
@@ -76,43 +72,12 @@ public Dialect createDialect() { | |
@Getter | ||
@AllArgsConstructor | ||
public enum DialectEnum { | ||
mysql(Dialect.MYSQL, "?") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new MysqlSchemaMetadata(name); | ||
} | ||
}, | ||
mssql(Dialect.MSSQL, "@arg") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new SqlServerSchemaMetadata(name); | ||
} | ||
}, | ||
oracle(Dialect.ORACLE, "?") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new OracleSchemaMetadata(name); | ||
} | ||
}, | ||
postgres(Dialect.POSTGRES, "$") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new PostgresqlSchemaMetadata(name); | ||
} | ||
}, | ||
h2(Dialect.H2, "$") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new H2SchemaMetadata(name); | ||
} | ||
}, | ||
clickhouse(Dialect.CLICKHOUSE,"?"){ | ||
clickhouse(Dialect.CLICKHOUSE, "?") { | ||
@Override | ||
public RDBSchemaMetadata createSchema(String name) { | ||
return new ClickhouseSchemaMetadata(name); | ||
} | ||
} | ||
; | ||
}; | ||
|
||
private Dialect dialect; | ||
private String bindSymbol; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Auto Configure | ||
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. spring 2.7已经弃用了这种配置方式,应当使用 META-INF
|--- spring
|------org.springframework.boot.autoconfigure.AutoConfiguration.imports 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. 好的 |
||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
org.hswebframework.web.crud.configuration.ClickhouseHttpSqlExecutorConfiguration |
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.
好的