We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main_test import ( "errors" "fmt" "log" "strconv" "testing" "github.com/kelindar/column" "github.com/zeebo/assert" ) func TestTransaction(t *testing.T) { players := column.NewCollection() err := errors.Join(players.CreateColumn("name", column.ForString()), players.CreateColumn("class", column.ForString()), players.CreateColumn("balance", column.ForFloat64()), players.CreateColumn("age", column.ForInt16())) if err != nil { log.Fatalf("failed to create columns") } addPlayers := func() { err = players.Query(func(tx *column.Txn) error { for i := 0; i < 20; i++ { _, err := tx.Insert(func(r column.Row) error { r.SetString("name", "merlin") r.SetString("class", "mage") r.SetFloat64("balance", 99.95) r.SetInt16("age", 107) return nil }) if err != nil { return err } } return nil }) } addPlayers() assert.Nil(t, err) assert.Equal(t, players.Count(), 20) addPlayersError := func() error { err = players.Query(func(tx *column.Txn) error { for i := 0; i < 20; i++ { _, err = tx.Insert(func(r column.Row) error { r.SetString("name", "merlin") r.SetString("class", "mage") r.SetFloat64("balance", 99.95) r.SetInt16("age", 107) return nil }) if err != nil { return err } } return errors.New("SHOULD NOT PASS") }) return err } err = addPlayersError() assert.Error(t, err) //should be error. assert.Equal(t, players.Count(), 20) //transaction failed should still be 20. }
Seems like counts are not accounting for rollbacks. The last transaction should fail, and the count should remain 20 but it doesn't?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Seems like counts are not accounting for rollbacks. The last transaction should fail, and the count should remain 20 but it doesn't?
The text was updated successfully, but these errors were encountered: