#785 add defaultValue

This commit is contained in:
e-mhui
2023-11-09 19:25:56 +08:00
parent a80ccc7258
commit 732b4f54d4

View File

@ -16,11 +16,19 @@ public class SQLConst {
+ "array_to_string"
+ "(\n"
+ " array(\n"
+ " select ' ' || concat_ws(' ',fieldName, fieldType, isNullStr"
+ " select ' ' || concat_ws(' ',fieldName, fieldType, defaultValue, isNullStr"
+ " ) as "
+ "column_line\n"
+ " from (\n"
+ " select a.attname as fieldName,format_type(a.atttypid,a.atttypmod) as fieldType,"
+ " CASE WHEN \n"
+ " (SELECT substring(pg_catalog.pg_get_expr(B.adbin, B.adrelid) for 128)\n"
+ " FROM pg_catalog.pg_attrdef B WHERE B.adrelid = A.attrelid AND B.adnum = A.attnum AND A.atthasdef) IS NOT NULL THEN\n"
+ " 'DEFAULT '|| (SELECT substring(pg_catalog.pg_get_expr(B.adbin, B.adrelid) for 128)\n"
+ " FROM pg_catalog.pg_attrdef B WHERE B.adrelid = A.attrelid AND B.adnum = A.attnum AND A.atthasdef)\n"
+ " ELSE\n"
+ " ''\n"
+ " END as defaultValue,"
+ " (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"