Merge pull request #346 from StringKe/main

feat(dialect): 添加 PostgreSQL 方言实现
This commit is contained in:
Michael Yang 2024-06-03 11:51:11 +08:00 committed by GitHub
commit 43513ee64a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import com.mybatisflex.codegen.dialect.impl.DefaultJdbcDialect;
import com.mybatisflex.codegen.dialect.impl.MySqlJdbcDialect;
import com.mybatisflex.codegen.dialect.impl.OracleJdbcDialect;
import com.mybatisflex.codegen.dialect.impl.SqliteDialect;
import com.mybatisflex.codegen.dialect.impl.PostgreSQLJdbcDialect;
import com.mybatisflex.codegen.entity.Table;
import java.sql.Connection;
@ -54,6 +55,11 @@ public interface IDialect {
*/
IDialect SQLITE = new SqliteDialect();
/**
* PostgreSQL 方言
*/
IDialect POSTGRESQL = new PostgreSQLJdbcDialect();
/**
* 构建表和列的信息
*

View File

@ -0,0 +1,29 @@
/*
* Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.mybatisflex.codegen.dialect.impl;
import com.mybatisflex.codegen.dialect.AbstractJdbcDialect;
import com.mybatisflex.core.util.StringUtil;
/**
* @author strignke
*/
public class PostgreSQLJdbcDialect extends AbstractJdbcDialect {
@Override
protected String forBuildColumnsSql(String schema, String tableName) {
return "SELECT * FROM " + (StringUtil.isNotBlank(schema) ? schema + "." : "") + "\"" + tableName + "\"" + " WHERE 1 = 2";
}
}