MCPcopy
hub / github.com/sqldef/sqldef / GetDataType

Method GetDataType

database/postgres/database.go:858–886  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

856}
857
858func (c *column) GetDataType() string {
859 switch c.dataType {
860 case "smallint":
861 if c.IsAutoIncrement {
862 return "smallserial" + strings.TrimPrefix(c.formattedDataType, "smallint")
863 }
864 return c.dataType
865 case "integer":
866 if c.IsAutoIncrement {
867 return "serial" + strings.TrimPrefix(c.formattedDataType, "integer")
868 }
869 return c.dataType
870 case "bigint":
871 if c.IsAutoIncrement {
872 return "bigserial" + strings.TrimPrefix(c.formattedDataType, "bigint")
873 }
874 return c.dataType
875 case "timestamp without time zone":
876 // Note:
877 // The SQL standard requires that writing just timestamp be equivalent to timestamp without time zone, and PostgreSQL honors that behavior.
878 // timestamptz is accepted as an abbreviation for timestamp with time zone; this is a PostgreSQL extension.
879 // https://www.postgresql.org/docs/9.6/datatype-datetime.html
880 return strings.TrimSuffix(c.formattedDataType, " without time zone")
881 case "time without time zone":
882 return strings.TrimSuffix(c.formattedDataType, " without time zone")
883 default:
884 return c.formattedDataType
885 }
886}
887
888func (d *PostgresDatabase) getIndexDefs(table string) ([]string, error) {
889 // Exclude indexes that are implicitly created for primary keys or unique constraints or exclusion constraints.

Callers 1

buildExportTableDDLMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected