Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix-2877] Fix postgre type converter #3052

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Fix-2877] Fix postgre type converter
  • Loading branch information
aiwenmo committed Jan 23, 2024
commit 5c8545b2165bc95eb651ed75a776620fedcb7091
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
Loading