mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-29 02:32:33 +08:00
#785 fix pg sql error
This commit is contained in:
@ -16,25 +16,12 @@ public class SQLConst {
|
||||
+ "array_to_string"
|
||||
+ "(\n"
|
||||
+ " array(\n"
|
||||
+ " select ' ' || concat_ws(' ',fieldName, fieldType, fieldLen, indexType, isNullStr, fieldComment"
|
||||
+ " select ' ' || concat_ws(' ',fieldName, fieldType, isNullStr"
|
||||
+ " ) as "
|
||||
+ "column_line\n"
|
||||
+ " from (\n"
|
||||
+ " select a.attname as fieldName,format_type(a.atttypid,a.atttypmod) as fieldType,(case when "
|
||||
+ "atttypmod-4>0 then\n"
|
||||
+ " atttypmod-4 else 0 end) as fieldLen,\n"
|
||||
+ " (case when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum "
|
||||
+ "and\n"
|
||||
+ " contype='p')>0 then 'PRI'\n"
|
||||
+ " when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and "
|
||||
+ "contype='u')>0\n"
|
||||
+ " then 'UNI'\n"
|
||||
+ " when (select count(*) from pg_constraint where conrelid = a.attrelid and conkey[1]=attnum and "
|
||||
+ "contype='f')>0\n"
|
||||
+ " then 'FRI'\n"
|
||||
+ " else '' end) as indexType,\n"
|
||||
+ " (case when a.attnotnull=true then 'not null' else 'null' end) as isNullStr,\n"
|
||||
+ " ' comment ' || col_description(a.attrelid,a.attnum) as fieldComment\n"
|
||||
+ " select a.attname as fieldName,format_type(a.atttypid,a.atttypmod) as fieldType,"
|
||||
+ " (case when a.attnotnull=true then 'not null' else 'null' end) as isNullStr\n"
|
||||
+ " from pg_attribute a where attstattarget=-1 and attrelid = (select c.oid from pg_class c,"
|
||||
+ "pg_namespace n"
|
||||
+ " where\n"
|
||||
@ -114,7 +101,7 @@ public class SQLConst {
|
||||
+ " -- COMMENT COMMENT ON COLUMN sys_activity.id IS '主键';\n"
|
||||
+ " tableScript:= tableScript || chr(13)||chr(10) || chr(13)||chr(10) || array_to_string(\n"
|
||||
+ " array(\n"
|
||||
+ " SELECT 'COMMENT ON COLUMN' || tablename || '.' || a.attname ||' IS '|| ''''|| d.description "
|
||||
+ " SELECT 'COMMENT ON COLUMN ' || tablename || '.' || a.attname ||' IS '|| ''''|| d.description "
|
||||
+ "||''''\n"
|
||||
+ " FROM pg_class c\n"
|
||||
+ " JOIN pg_description d ON c.oid=d.objoid\n"
|
||||
|
Reference in New Issue
Block a user