update query

This commit is contained in:
techknowlogick 2018-06-06 16:52:36 -04:00 committed by GitHub
parent e09c69d374
commit 48b0253baf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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