This commit is contained in:
dengqichen 2025-11-15 15:20:22 +08:00
parent 8f9e16df7b
commit 7e6e46bb4a
2 changed files with 7 additions and 3 deletions

View File

@ -11,9 +11,13 @@ module.exports = {
'numeric': 'DECIMAL', 'numeric': 'DECIMAL',
'varchar': 'VARCHAR', 'varchar': 'VARCHAR',
'timestamp': 'TIMESTAMP', 'timestamp': 'TIMESTAMP',
'timestamptz': 'TIMESTAMP', // PostgreSQL timestamp with time zone
'bool': 'BIT', 'bool': 'BIT',
'text': 'TEXT', 'text': 'TEXT',
'bytea': 'BLOB' 'bytea': 'BLOB',
'float8': 'DOUBLE', // PostgreSQL double precision
'float4': 'REAL', // PostgreSQL real/float
'float': 'REAL' // 通用float
}, },
// 序列DEFAULT值转换规则 // 序列DEFAULT值转换规则

View File

@ -43,8 +43,8 @@ class PG2DMConverter {
convertDataTypes(sql) { convertDataTypes(sql) {
let converted = sql; let converted = sql;
// 1. 转换基本类型 // 1. 转换基本类型(包括浮点类型和时间戳类型)
const typePattern = /\b(int8|int4|int2|numeric|bool)\b/gi; const typePattern = /\b(int8|int4|int2|numeric|bool|float8|float4|float|timestamptz)\b/gi;
converted = converted.replace(typePattern, (match) => { converted = converted.replace(typePattern, (match) => {
const lowerMatch = match.toLowerCase(); const lowerMatch = match.toLowerCase();