fix(db): 适配KingbaseES schema搜索路径与代码生成器元数据查询
- 在 application-druid.yml 中为连接池配置 SET search_path TO public, sys_catalog,优先访问 public 业务表,解决若依系统表与 Kingbase 内置系统视图同名冲突 - 将代码生成器 GenTableMapper 与 GenTableColumnMapper 中的 table_schema 过滤从 current_database() 调整为 current_schema(),使代码生成器正常识别 Kingbase 表结构与列信息
This commit is contained in:
1 parent
b12ef9c9e4
commit
0fd4a66d81
3 files changed
+6
-5
No files matched your search
@@ -17,9 +17,10 @@ spring:
|
||||
#url: jdbc:mysql://83.102.67.232:3306/judge?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
|
||||
#url: jdbc:mysql://127.0.0.1:3306/s_builder_kj?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
|
||||
#221 local dev env kingbase (via 100.70.157.41 tunnel):
|
||||
url: jdbc:kingbase8://127.0.0.1:4321/training?currentSchema=public&useUnicode=true&characterEncoding=utf8
|
||||
url: jdbc:kingbase8://127.0.0.1:4321/training?currentSchema=public,sys_catalog&useUnicode=true&characterEncoding=utf8
|
||||
username: kingbase
|
||||
password: sict123456
|
||||
connectionInitSqls: ["SET search_path TO public, sys_catalog"]
|
||||
|
||||
# prod env kingbase:
|
||||
#url: jdbc:kingbase8://localhost:54321/graph?currentSchema=public&useUnicode=true&characterEncoding=utf8
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else '0' end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
||||
from information_schema.columns where table_schema = (select current_database()) and table_name = (#{tableName})
|
||||
from information_schema.columns where table_schema = (select current_schema()) and table_name = (#{tableName})
|
||||
order by ordinal_position
|
||||
</select>
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_schema = (select current_database())
|
||||
where table_schema = (select current_schema())
|
||||
AND table_name NOT LIKE 'qrtz\_%' AND table_name NOT LIKE 'gen\_%'
|
||||
AND table_name NOT IN (select table_name from gen_table)
|
||||
<if test="tableName != null and tableName != ''">
|
||||
@@ -98,7 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_name NOT LIKE 'qrtz\_%' and table_name NOT LIKE 'gen\_%' and table_schema = (select current_database())
|
||||
where table_name NOT LIKE 'qrtz\_%' and table_name NOT LIKE 'gen\_%' and table_schema = (select current_schema())
|
||||
and table_name in
|
||||
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||
#{name}
|
||||
@@ -107,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select current_database())
|
||||
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select current_schema())
|
||||
and table_name = #{tableName}
|
||||
</select>
|
||||
|
||||
|
||||
Reference in new issue
Block a user