Explorar o código

Merge pull request #3763 from liaosnet/3.0

增加对南大通用GBase 8s数据库的支持
qmdx %!s(int64=3) %!d(string=hai) anos
pai
achega
22c471608e

+ 2 - 1
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java

@@ -99,7 +99,8 @@ public enum DbType {
     /**
      * GBase
      */
-    GBASE("gbase", "南大通用数据库"),
+    GBASE("gbase", "南大通用(华库)数据库"),
+    GBASEDBT("gbasedbt", "南大通用数据库"),
     /**
      * Oscar
      */

+ 2 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java

@@ -74,6 +74,8 @@ public class DialectFactory {
                 dialect = new SQLServerDialect();
             } else if (dbType == DbType.SYBASE) {
                 dialect = new SybaseDialect();
+            } else if (dbType == DbType.GBASEDBT){
+                dialect = new GBasedbtDialect();
             }
             DIALECT_ENUM_MAP.put(dbType, dialect);
         }

+ 35 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/dialects/GBasedbtDialect.java

@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.baomidou.mybatisplus.extension.plugins.pagination.dialects;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.DialectModel;
+
+/**
+ * GBase 8s V8.8 数据库分页语句组装实现
+ * 通用分页版本
+ *
+ * @author liaojinqing
+ * @since 2021-07-20
+ */
+public class GBasedbtDialect implements IDialect {
+
+    @Override
+    public DialectModel buildPaginationSql(String originalSql, long offset, long limit) {
+        StringBuilder sql = new StringBuilder(originalSql)
+            .insert(6, " SKIP " + FIRST_MARK + " FIRST " + SECOND_MARK);
+        return new DialectModel(sql.toString(), offset, limit).setConsumerChain();
+    }
+}

+ 2 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/JdbcUtils.java

@@ -93,6 +93,8 @@ public class JdbcUtils {
             return DbType.GAUSS;
         } else if (jdbcUrl.contains(":gbase:")) {
             return DbType.GBASE;
+        } else if (jdbcUrl.contains(":gbasedbt-sqli:")) {
+            return DbType.GBASEDBT;
         } else if (jdbcUrl.contains(":clickhouse:")) {
             return DbType.CLICK_HOUSE;
         } else if (jdbcUrl.contains(":oscar:")) {