From 48b0253bafebe52b0bed22fd06bb677e42faeaae Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Wed, 6 Jun 2018 16:52:36 -0400 Subject: [PATCH] update query --- dialect_postgres.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dialect_postgres.go b/dialect_postgres.go index c2fa3f96..ac2d0986 100644 --- a/dialect_postgres.go +++ b/dialect_postgres.go @@ -952,7 +952,13 @@ func (db *postgres) IsColumnExist(tableName, colName string) (bool, error) { func (db *postgres) GetColumns(tableName string) ([]string, map[string]*core.Column, error) { args := []interface{}{tableName} - s := `SELECT column_name, column_default, is_nullable, data_type, character_maximum_length, numeric_precision , + s := `SELECT column_name, column_default, is_nullable, replace(data_type,'STRING','VARCHAR'), + character_maximum_length, numeric_precision, + CASE + WHEN numeric_precision IS NOT NULL AND lower(data_type) = 'decimal' THEN 10 + WHEN numeric_precision IS NOT NULL AND lower(data_type) != 'decimal' THEN 2 + ELSE NULL + END AS numeric_precision_radix, CASE WHEN p.contype = 'p' THEN true ELSE false END AS primarykey, CASE WHEN p.contype = 'u' THEN true ELSE false END AS uniquekey FROM pg_attribute f