MCPcopy
hub / github.com/dgraph-io/dgraph / getValue

Function getValue

dgraph/cmd/migrate/table_guide.go:151–180  ·  view source on GitHub ↗
(dataType dataType, value interface{})

Source from the content-addressed store, hash-verified

149}
150
151func getValue(dataType dataType, value interface{}) (string, error) {
152 if value == nil {
153 return "", errors.Errorf("nil value found")
154 }
155
156 switch dataType {
157 case stringType:
158 return fmt.Sprintf("%s", value), nil
159 case intType:
160 if !value.(sql.NullInt64).Valid {
161 return "", errors.Errorf("found invalid nullint")
162 }
163 intVal, _ := value.(sql.NullInt64).Value()
164 return fmt.Sprintf("%v", intVal), nil
165 case datetimeType:
166 if !value.(mysql.NullTime).Valid {
167 return "", errors.Errorf("found invalid nulltime")
168 }
169 dateVal, _ := value.(mysql.NullTime).Value()
170 return fmt.Sprintf("%v", dateVal), nil
171 case floatType:
172 if !value.(sql.NullFloat64).Valid {
173 return "", errors.Errorf("found invalid nullfloat")
174 }
175 floatVal, _ := value.(sql.NullFloat64).Value()
176 return fmt.Sprintf("%v", floatVal), nil
177 default:
178 return fmt.Sprintf("%v", value), nil
179 }
180}
181
182type ref struct {
183 allColumns map[string]*columnInfo

Callers 4

generateMethod · 0.70
createLabelFunction · 0.70
outputPlainCellMethod · 0.70
convertYAMLFunction · 0.50

Calls 2

ErrorfMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected