func (self *Table) AddColumn(name string, columnType string, defval sqltypes.Value, extra string, isPk, nullable bool) { index := len(self.Columns) self.Columns = append(self.Columns, TableColumn{Name: name}) self.Columns[index].IsPk = isPk self.Columns[index].Nullable = nullable if strings.Contains(columnType, "int") { self.Columns[index].Category = CAT_NUMBER } else if strings.HasPrefix(columnType, "varbinary") { self.Columns[index].Category = CAT_VARBINARY } else if strings.HasPrefix(columnType, "fractional") { self.Columns[index].Category = CAT_FRACTIONAL } else { self.Columns[index].Category = CAT_OTHER } if extra == "auto_increment" { self.Columns[index].IsAuto = true self.Columns[index].NextId = 0 // Ignore default value, if any return } else if extra == "uuid" { self.Columns[index].IsUUID = true } if defval.IsNull() { return } if self.Columns[index].Category == CAT_NUMBER { self.Columns[index].Default = sqltypes.MakeNumeric(defval.Raw()) } else { self.Columns[index].Default = sqltypes.MakeString(defval.Raw()) } }
func buildValue(bytes []byte, fieldType uint32) sqltypes.Value { switch fieldType { case schema.TYPE_FRACTIONAL: return sqltypes.MakeFractional(bytes) case schema.TYPE_NUMERIC: return sqltypes.MakeNumeric(bytes) } return sqltypes.MakeString(bytes) }
func buildValue(bytes []byte, fieldType int64) sqltypes.Value { switch fieldType { case schema.CAT_FRACTIONAL: return sqltypes.MakeFractional(bytes) case schema.CAT_NUMBER: return sqltypes.MakeNumeric(bytes) } return sqltypes.MakeString(bytes) }