MCPcopy Index your code
hub / github.com/upper/db / TestUpdateWithNullColumn

Method TestUpdateWithNullColumn

internal/testsuite/sql_suite.go:1241–1272  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1239}
1240
1241func (s *SQLTestSuite) TestUpdateWithNullColumn() {
1242 sess := s.Session()
1243
1244 artist := sess.Collection("artist")
1245 err := artist.Truncate()
1246 s.NoError(err)
1247
1248 type Artist struct {
1249 ID int64 `db:"id,omitempty"`
1250 Name *string `db:"name"`
1251 }
1252
1253 name := "José"
1254 id, err := artist.Insert(Artist{0, &name})
1255 s.NoError(err)
1256
1257 var item Artist
1258 err = artist.Find(id).One(&item)
1259 s.NoError(err)
1260
1261 s.NotEqual(nil, item.Name)
1262 s.Equal(name, *item.Name)
1263
1264 err = artist.Find(id).Update(Artist{Name: nil})
1265 s.NoError(err)
1266
1267 var item2 Artist
1268 err = artist.Find(id).One(&item2)
1269 s.NoError(err)
1270
1271 s.Equal((*string)(nil), item2.Name)
1272}
1273
1274func (s *SQLTestSuite) TestBatchInsert() {
1275 sess := s.Session()

Callers

nothing calls this directly

Calls 7

SessionMethod · 0.65
CollectionMethod · 0.65
TruncateMethod · 0.65
InsertMethod · 0.65
OneMethod · 0.65
FindMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected