@@ -457,7 +457,7 @@ func TestCAS(t *testing.T) {
457
457
458
458
successBatch := session .Batch (LoggedBatch )
459
459
successBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES (?, ?, ?) IF NOT EXISTS" , title , revid , modified )
460
- if applied , _ , err := session . ExecuteBatchCAS ( successBatch , & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
460
+ if applied , _ , err := successBatch . ExecCAS ( & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
461
461
t .Fatal ("insert:" , err )
462
462
} else if ! applied {
463
463
t .Fatalf ("insert should have been applied: title=%v revID=%v modified=%v" , titleCAS , revidCAS , modifiedCAS )
@@ -466,15 +466,15 @@ func TestCAS(t *testing.T) {
466
466
successBatch = session .Batch (LoggedBatch )
467
467
successBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES (?, ?, ?) IF NOT EXISTS" , title + "_foo" , revid , modified )
468
468
casMap := make (map [string ]interface {})
469
- if applied , _ , err := session . MapExecuteBatchCAS ( successBatch , casMap ); err != nil {
469
+ if applied , _ , err := successBatch . MapExecCAS ( casMap ); err != nil {
470
470
t .Fatal ("insert:" , err )
471
471
} else if ! applied {
472
472
t .Fatal ("insert should have been applied" )
473
473
}
474
474
475
475
failBatch := session .Batch (LoggedBatch )
476
476
failBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES (?, ?, ?) IF NOT EXISTS" , title , revid , modified )
477
- if applied , _ , err := session . ExecuteBatchCAS ( successBatch , & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
477
+ if applied , _ , err := successBatch . ExecCAS ( & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
478
478
t .Fatal ("insert:" , err )
479
479
} else if applied {
480
480
t .Fatalf ("insert should have not been applied: title=%v revID=%v modified=%v" , titleCAS , revidCAS , modifiedCAS )
@@ -483,14 +483,14 @@ func TestCAS(t *testing.T) {
483
483
insertBatch := session .Batch (LoggedBatch )
484
484
insertBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 2c3af400-73a4-11e5-9381-29463d90c3f0, TOTIMESTAMP(NOW()))" )
485
485
insertBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES ('_foo', 3e4ad2f1-73a4-11e5-9381-29463d90c3f0, TOTIMESTAMP(NOW()))" )
486
- if err := session . ExecuteBatch ( insertBatch ); err != nil {
486
+ if err := insertBatch . Exec ( ); err != nil {
487
487
t .Fatal ("insert:" , err )
488
488
}
489
489
490
490
failBatch = session .Batch (LoggedBatch )
491
491
failBatch .Query ("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=2c3af400-73a4-11e5-9381-29463d90c3f0 IF last_modified=TOTIMESTAMP(NOW());" )
492
492
failBatch .Query ("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified=TOTIMESTAMP(NOW());" )
493
- if applied , iter , err := session . ExecuteBatchCAS ( failBatch , & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
493
+ if applied , iter , err := failBatch . ExecCAS ( & titleCAS , & revidCAS , & modifiedCAS ); err != nil {
494
494
t .Fatal ("insert:" , err )
495
495
} else if applied {
496
496
t .Fatalf ("insert should have not been applied: title=%v revID=%v modified=%v" , titleCAS , revidCAS , modifiedCAS )
@@ -521,20 +521,20 @@ func TestCAS(t *testing.T) {
521
521
notCASBatch := session .Batch (LoggedBatch )
522
522
notCASBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES (?, ?, ?)" , title + "_baz" , revid , modified )
523
523
casMap = make (map [string ]interface {})
524
- if _ , _ , err := session . MapExecuteBatchCAS ( notCASBatch , casMap ); err != ErrNotFound {
524
+ if _ , _ , err := notCASBatch . MapExecCAS ( casMap ); err != ErrNotFound {
525
525
t .Fatal ("insert should have returned not found:" , err )
526
526
}
527
527
528
528
notCASBatch = session .Batch (LoggedBatch )
529
529
notCASBatch .Query ("INSERT INTO cas_table (title, revid, last_modified) VALUES (?, ?, ?)" , title + "_baz" , revid , modified )
530
530
casMap = make (map [string ]interface {})
531
- if _ , _ , err := session . ExecuteBatchCAS ( notCASBatch , & revidCAS ); err != ErrNotFound {
531
+ if _ , _ , err := notCASBatch . ExecCAS ( & revidCAS ); err != ErrNotFound {
532
532
t .Fatal ("insert should have returned not found:" , err )
533
533
}
534
534
535
535
failBatch = session .Batch (LoggedBatch )
536
536
failBatch .Query ("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?" , modified )
537
- if _ , _ , err := session . ExecuteBatchCAS ( failBatch , new (bool )); err == nil {
537
+ if _ , _ , err := failBatch . ExecCAS ( new (bool )); err == nil {
538
538
t .Fatal ("update should have errored" )
539
539
}
540
540
// make sure MapScanCAS does not panic when MapScan fails
@@ -550,7 +550,7 @@ func TestCAS(t *testing.T) {
550
550
failBatch .Query ("UPDATE cas_table SET last_modified = TOTIMESTAMP(NOW()) WHERE title='_foo' AND revid=3e4ad2f1-73a4-11e5-9381-29463d90c3f0 IF last_modified = ?" , modified )
551
551
casMap = make (map [string ]interface {})
552
552
casMap ["last_modified" ] = false
553
- if _ , _ , err := session . MapExecuteBatchCAS ( failBatch , casMap ); err == nil {
553
+ if _ , _ , err := failBatch . MapExecCAS ( casMap ); err == nil {
554
554
t .Fatal ("update should have errored" )
555
555
}
556
556
}
@@ -752,7 +752,7 @@ func TestBatch(t *testing.T) {
752
752
batch .Query (`INSERT INTO batch_table (id) VALUES (?)` , i )
753
753
}
754
754
755
- if err := session . ExecuteBatch ( batch ); err != nil {
755
+ if err := batch . Exec ( ); err != nil {
756
756
t .Fatal ("execute batch:" , err )
757
757
}
758
758
@@ -788,7 +788,7 @@ func TestUnpreparedBatch(t *testing.T) {
788
788
batch .Query (`UPDATE batch_unprepared SET c = c + 1 WHERE id = 1` )
789
789
}
790
790
791
- if err := session . ExecuteBatch ( batch ); err != nil {
791
+ if err := batch . Exec ( ); err != nil {
792
792
t .Fatal ("execute batch:" , err )
793
793
}
794
794
@@ -824,8 +824,8 @@ func TestBatchLimit(t *testing.T) {
824
824
for i := 0 ; i < 65537 ; i ++ {
825
825
batch .Query (`INSERT INTO batch_table2 (id) VALUES (?)` , i )
826
826
}
827
- if err := session . ExecuteBatch ( batch ); err != ErrTooManyStmts {
828
- t .Fatal ("gocql attempted to execute a batch larger than the support limit of statements." )
827
+ if err := batch . Exec ( ); err != ErrTooManyStmts {
828
+ t .Fatalf ("gocql attempted to execute a batch larger than the support limit of statements: expected %v, got %v" , ErrTooManyStmts , err )
829
829
}
830
830
831
831
}
@@ -876,7 +876,7 @@ func TestTooManyQueryArgs(t *testing.T) {
876
876
877
877
batch := session .Batch (UnloggedBatch )
878
878
batch .Query ("INSERT INTO too_many_query_args (id, value) VALUES (?, ?)" , 1 , 2 , 3 )
879
- err = session . ExecuteBatch ( batch )
879
+ err = batch . Exec ( )
880
880
881
881
if err == nil {
882
882
t .Fatal ("'`INSERT INTO too_many_query_args (id, value) VALUES (?, ?)`, 1, 2, 3' should return an error" )
@@ -908,7 +908,7 @@ func TestNotEnoughQueryArgs(t *testing.T) {
908
908
909
909
batch := session .Batch (UnloggedBatch )
910
910
batch .Query ("INSERT INTO not_enough_query_args (id, cluster, value) VALUES (?, ?, ?)" , 1 , 2 )
911
- err = session . ExecuteBatch ( batch )
911
+ err = batch . Exec ( )
912
912
913
913
if err == nil {
914
914
t .Fatal ("'`INSERT INTO not_enough_query_args (id, cluster, value) VALUES (?, ?, ?)`, 1, 2' should return an error" )
@@ -1534,7 +1534,7 @@ func TestBatchQueryInfo(t *testing.T) {
1534
1534
batch := session .Batch (LoggedBatch )
1535
1535
batch .Bind ("INSERT INTO batch_query_info (id, cluster, value) VALUES (?, ?,?)" , write )
1536
1536
1537
- if err := session . ExecuteBatch ( batch ); err != nil {
1537
+ if err := batch . Exec ( ); err != nil {
1538
1538
t .Fatalf ("batch insert into batch_query_info failed, err '%v'" , err )
1539
1539
}
1540
1540
@@ -2047,7 +2047,7 @@ func TestBatchStats(t *testing.T) {
2047
2047
b .Query ("INSERT INTO batchStats (id) VALUES (?)" , 1 )
2048
2048
b .Query ("INSERT INTO batchStats (id) VALUES (?)" , 2 )
2049
2049
2050
- if err := session . ExecuteBatch ( b ); err != nil {
2050
+ if err := b . Exec ( ); err != nil {
2051
2051
t .Fatalf ("query failed. %v" , err )
2052
2052
} else {
2053
2053
if b .Attempts () < 1 {
@@ -2104,7 +2104,7 @@ func TestBatchObserve(t *testing.T) {
2104
2104
batch .Query (fmt .Sprintf (`INSERT INTO batch_observe_table (id,other) VALUES (?,%d)` , i ), i )
2105
2105
}
2106
2106
2107
- if err := session . ExecuteBatch ( batch ); err != nil {
2107
+ if err := batch . Exec ( ); err != nil {
2108
2108
t .Fatal ("execute batch:" , err )
2109
2109
}
2110
2110
if observedBatch == nil {
@@ -3408,7 +3408,7 @@ func TestUnsetColBatch(t *testing.T) {
3408
3408
b .Query ("INSERT INTO gocql_test.batchUnsetInsert(id, my_int, my_text) VALUES (?,?,?)" , 1 , UnsetValue , "" )
3409
3409
b .Query ("INSERT INTO gocql_test.batchUnsetInsert(id, my_int, my_text) VALUES (?,?,?)" , 2 , 2 , UnsetValue )
3410
3410
3411
- if err := session . ExecuteBatch ( b ); err != nil {
3411
+ if err := b . Exec ( ); err != nil {
3412
3412
t .Fatalf ("query failed. %v" , err )
3413
3413
} else {
3414
3414
if b .Attempts () < 1 {
0 commit comments