github.com/kotovmak/go-admin@v1.1.1/modules/db/dialect/postgresql.go (about)

     1  // Copyright 2019 GoAdmin Core Team. All rights reserved.
     2  // Use of this source code is governed by a Apache-2.0 style
     3  // license that can be found in the LICENSE file.
     4  
     5  package dialect
     6  
     7  import (
     8  	"fmt"
     9  	"strings"
    10  )
    11  
    12  type postgresql struct {
    13  	commonDialect
    14  }
    15  
    16  func (postgresql) GetName() string {
    17  	return "postgresql"
    18  }
    19  
    20  func (postgresql) ShowTables() string {
    21  	return "SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname != 'pg_catalog' AND schemaname != 'information_schema';"
    22  }
    23  
    24  func (postgresql) ShowColumns(table string) string {
    25  	tableArr := strings.Split(table, "\".\"")
    26  	if len(tableArr) > 1 {
    27  		return fmt.Sprintf("select * from information_schema.columns where table_name = '%s' and table_schema = '%s'", tableArr[1], tableArr[0])
    28  	} else {
    29  		return fmt.Sprintf("select * from information_schema.columns where table_name = '%s'", table)
    30  	}
    31  }