github.com/gocaveman/caveman@v0.0.0-20191211162744-0ddf99dbdf6e/ddl/data-types.go (about)

     1  package ddl
     2  
     3  //go:generate stringer -type=DataType -output=data-types_string.go
     4  
     5  type DataType int
     6  
     7  // enum so we can refer to data types with a simple value
     8  const (
     9  	Invalid DataType = iota
    10  	Custom
    11  	VarCharPK
    12  	BigIntAutoPK
    13  	VarCharFK
    14  	BigIntFK
    15  	Int
    16  	IntU
    17  	BigInt
    18  	BigIntU
    19  	Double
    20  	DateTime
    21  	VarChar
    22  	Bool
    23  	Text
    24  	Blob
    25  	// TODO: We actually need to add a DECIMAL type - in MySQL in can be DECIMAL/NUMERIC
    26  	// and in SQLite3 it can be just a string.  This is vital for financial and other
    27  	// calculations where rounding errors and the general imprecision of floating points
    28  	// have big bad consequences.  It will be important to also think about what the recommended
    29  	// corresponding type(s) are in Go, e.g. big.Rat or something else.
    30  )
    31  
    32  // DataTypeDef describes a column.  It includes the name and various common options.
    33  type DataTypeDef struct {
    34  	DataTypeValue      DataType    // which basic data type
    35  	NameValue          string      // SQL name
    36  	CustomSQLValue     string      // if DataType is Custom this is the full SQL of the type (not including the name)
    37  	NullValue          bool        // NULL (or default of NOT NULL)
    38  	DefaultValue       interface{} // if you want a DEFAULT included
    39  	LengthValue        int         // for types that support a length part
    40  	CaseSensitiveValue bool        // for cases where a string should be forced to be case sensitive
    41  }
    42  
    43  type DataTypeDefPtrList []*DataTypeDef