feat(dialect): 添加 PostgreSQL 方言实现

添加了 PostgreSQLJdbcDialect 类的实现,以支持 Postgres 数据库的代码生成功能。

主要避免关键词导致的生成失败比如 user
This commit is contained in:
StringKe 2024-05-26 12:46:02 +08:00
parent adb43c6c47
commit 1b21708c30
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";
}
}