Skip to content

Commit

Permalink
[Fix-2877] Fix postgre type converter (DataLinkDC#3052)
Browse files Browse the repository at this point in the history
Co-authored-by: wenmo <32723967+wenmo@users.noreply.github.com>
  • Loading branch information
aiwenmo and aiwenmo authored Jan 24, 2024
1 parent 5b2a3e6 commit f570b5a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class PostgreSqlTypeConvert extends AbstractJdbcTypeConvert {

public PostgreSqlTypeConvert() {
this.convertMap.clear();
register("smallint", ColumnType.SHORT, ColumnType.JAVA_LANG_SHORT);
register("smallint", ColumnType.INT, ColumnType.INTEGER);
register("int2", ColumnType.SHORT, ColumnType.JAVA_LANG_SHORT);
register("smallserial", ColumnType.SHORT, ColumnType.JAVA_LANG_SHORT);
register("serial2", ColumnType.SHORT, ColumnType.JAVA_LANG_SHORT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ public String tablesSql(String schemaName) {
@Override
public String columnsSql(String schemaName, String tableName) {

return "SELECT col.column_name as name\n"
+ " , col.character_maximum_length as length\n"
return "SELECT col.column_name as name\n"
+ " , COALESCE(col.character_maximum_length,datetime_precision)"
+ " as length\n"
+ " , col.is_nullable as is_nullable\n"
+ " , col.numeric_precision as numeric_precision\n"
+ " , col.numeric_scale as numeric_scale\n"
+ " , col.ordinal_position as ordinal_position\n"
+ " , col.udt_name as type\n"
+ " , (CASE WHEN (SELECT COUNT(*) FROM pg_constraint AS PC WHERE b.attnum"
+ " = ANY(PC.conkey) AND PC.contype = 'p' and PC.conrelid = c.oid) > 0 \n"
+ "THEN 'PRI' ELSE '' END) AS key\n"
+ " , col_description(c.oid, col.ordinal_position) AS comment\n"
+ " , col.column_default AS column_default\n"
+ "THEN 'PRI' ELSE '' END) as key\n"
+ " , col_description(c.oid, col.ordinal_position) as comment\n"
+ " , col.column_default as column_default\n"
+ "FROM information_schema.columns AS col\n"
+ " LEFT JOIN pg_namespace ns ON ns.nspname = col.table_schema\n"
+ " LEFT JOIN pg_class c ON col.table_name = c.relname AND"
Expand Down

0 comments on commit f570b5a

Please sign in to comment.