File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1272,6 +1272,15 @@ func (q *Query) SerialConsistency(cons Consistency) *Query {
12721272 return q
12731273}
12741274
1275+ // GetSerialConsistency returns the currently configured serial consistency level
1276+ // for the query. If the serial consistency level has not been set, it returns nil.
1277+ func (q * Query ) GetSerialConsistency () * Consistency {
1278+ if ! q .serialCons .isSerial () {
1279+ return nil
1280+ }
1281+ return & q .serialCons
1282+ }
1283+
12751284// PageState sets the paging state for the query to resume paging from a specific
12761285// point in time. Setting this will disable to query paging for this query, and
12771286// must be used for all subsequent pages.
@@ -2079,6 +2088,15 @@ func (b *Batch) SerialConsistency(cons Consistency) *Batch {
20792088 return b
20802089}
20812090
2091+ // GetSerialConsistency returns the currently configured serial consistency level
2092+ // for the batch. If the serial consistency level has not been set, it returns nil.
2093+ func (b * Batch ) GetSerialConsistency () * Consistency {
2094+ if ! b .serialCons .isSerial () {
2095+ return nil
2096+ }
2097+ return & b .serialCons
2098+ }
2099+
20822100// DefaultTimestamp will enable the with default timestamp flag on the query.
20832101// If enable, this will replace the server side assigned
20842102// timestamp as default timestamp. Note that a timestamp in the query itself
Original file line number Diff line number Diff line change @@ -108,6 +108,15 @@ func TestQueryBasicAPI(t *testing.T) {
108108 t .Fatalf ("expected Query.GetConsistency to return 'All', got '%s'" , qry .GetConsistency ())
109109 }
110110
111+ if sc := qry .GetSerialConsistency (); sc != nil {
112+ t .Fatalf ("expected Query.GetSerialConsistency to return nil when not set, got '%s'" , sc )
113+ }
114+
115+ qry .SerialConsistency (Serial )
116+ if sc := qry .GetSerialConsistency (); sc == nil || * sc != Serial {
117+ t .Fatalf ("expected Query.GetSerialConsistency to return 'Serial', got '%v'" , sc )
118+ }
119+
111120 trace := & traceWriter {}
112121 qry .Trace (trace )
113122 if qry .trace != trace {
@@ -194,6 +203,16 @@ func TestBatchBasicAPI(t *testing.T) {
194203 t .Fatalf ("expected batch.GetConsistency() to return 'One', got '%s'" , b .GetConsistency ())
195204 }
196205
206+ // Test Serial Consistency
207+ if sc := b .GetSerialConsistency (); sc != nil {
208+ t .Fatalf ("expected batch.GetSerialConsistency() to return nil when not set, got '%s'" , sc )
209+ }
210+
211+ b .SerialConsistency (Serial )
212+ if sc := b .GetSerialConsistency (); sc == nil || * sc != Serial {
213+ t .Fatalf ("expected batch.GetSerialConsistency() to return 'Serial', got '%v'" , sc )
214+ }
215+
197216 trace := & traceWriter {}
198217 b .Trace (trace )
199218 if b .trace != trace {
You can’t perform that action at this time.
0 commit comments