From c1fc5fb726d47954f8bfb094646b29a1f382844d Mon Sep 17 00:00:00 2001 From: nextv Date: Sat, 12 Oct 2024 15:21:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=96=B0=E5=A2=9EDuckDb=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/noear/wood/DbContextMetaData.java | 3 +++ .../noear/wood/dialect/DbDuckDbDialect.java | 24 +++++++++++++++++++ .../main/java/org/noear/wood/wrap/DbType.java | 1 + 3 files changed, 28 insertions(+) create mode 100644 wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java diff --git a/wood/src/main/java/org/noear/wood/DbContextMetaData.java b/wood/src/main/java/org/noear/wood/DbContextMetaData.java index 3298326..17dc9b9 100644 --- a/wood/src/main/java/org/noear/wood/DbContextMetaData.java +++ b/wood/src/main/java/org/noear/wood/DbContextMetaData.java @@ -290,6 +290,9 @@ public class DbContextMetaData implements Closeable { } else if (pn.startsWith("jdbc:presto:")) { type = DbType.Presto; dialect = new DbPrestoDialect(); + } else if (pn.startsWith("jdbc:duckdb:")) { + type = DbType.DuckDb; + dialect = new DbDuckDbDialect(); } else { //做为默认 dialect = new DbMySQLDialect(); diff --git a/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java b/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java new file mode 100644 index 0000000..a1b3888 --- /dev/null +++ b/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java @@ -0,0 +1,24 @@ +package org.noear.wood.dialect; + +/** + * DuckDb数据库方言处理 + * + * @author noear + * @since 3.2 + * */ +public class DbDuckDbDialect extends DbDialectBase{ + + @Override + public String tableFormat(String tb) { + return tb.replace("`",""); + } + + @Override + public String columnFormat(String col) { + return col.replace("`",""); + } + @Override + public boolean supportsVariablePaging() { + return true; + } +} diff --git a/wood/src/main/java/org/noear/wood/wrap/DbType.java b/wood/src/main/java/org/noear/wood/wrap/DbType.java index eecc5aa..018c48d 100644 --- a/wood/src/main/java/org/noear/wood/wrap/DbType.java +++ b/wood/src/main/java/org/noear/wood/wrap/DbType.java @@ -19,6 +19,7 @@ public enum DbType { ClickHouse, Presto, + DuckDb, /* Unknown(DatabaseType.Unknown, "Unknown", "Unknown", 0), OracleThinServiceName(DatabaseType.Oracle, "oracle.jdbc.driver.OracleDriver", "jdbc:oracle:thin:@//${host}:${port}/${name}", 1521), -- Gitee From ff82bb9fe13519af483b12d5670c96ad76a8d2a5 Mon Sep 17 00:00:00 2001 From: nextv Date: Sat, 12 Oct 2024 15:22:00 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9EDuckDb=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=BF=9E=E6=8E=A5=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _test/src/test/java/wood_rdb/DbUtil.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/_test/src/test/java/wood_rdb/DbUtil.java b/_test/src/test/java/wood_rdb/DbUtil.java index 06a6f9c..d8eaead 100644 --- a/_test/src/test/java/wood_rdb/DbUtil.java +++ b/_test/src/test/java/wood_rdb/DbUtil.java @@ -121,6 +121,14 @@ public class DbUtil { return ds; } + private final static HikariDataSource dbDuckDbCfg(){ + HikariDataSource ds = new HikariDataSource(); + + ds.setJdbcUrl("jdbc:duckdb:/db/duckdb.db"); + ds.setDriverClassName("org.duckdb.DuckDBDriver"); + + return ds; + } public static DbContext getDb() { // -- Gitee From ac50814471637c714cef73406a5e620142084576 Mon Sep 17 00:00:00 2001 From: nextv Date: Tue, 15 Oct 2024 11:28:30 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4DuckDb=20SQL=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=20"`"=E8=BF=87=E6=BB=A4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/noear/wood/dialect/DbDuckDbDialect.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java b/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java index a1b3888..f4a1e07 100644 --- a/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java +++ b/wood/src/main/java/org/noear/wood/dialect/DbDuckDbDialect.java @@ -8,15 +8,7 @@ package org.noear.wood.dialect; * */ public class DbDuckDbDialect extends DbDialectBase{ - @Override - public String tableFormat(String tb) { - return tb.replace("`",""); - } - @Override - public String columnFormat(String col) { - return col.replace("`",""); - } @Override public boolean supportsVariablePaging() { return true; -- Gitee