@@ -60,7 +60,7 @@ public CqlCommand(CqlConnection connection, string cql = "", CqlConsistency leve
60
60
_load = 1 ;
61
61
_useBuffering = connection . Config . UseBuffering ;
62
62
_commandType = CommandType . Text ;
63
- _commandTimeout = 30 ;
63
+ _commandTimeout = connection . Config . CommandTimeout ;
64
64
}
65
65
66
66
/// <summary>
@@ -78,8 +78,10 @@ public CqlCommand(IDbConnection connection, string cql = "", CqlConsistency leve
78
78
/// Initializes a new instance of the <see cref="CqlCommand" /> class.
79
79
/// </summary>
80
80
public CqlCommand ( )
81
- : this ( null )
82
81
{
82
+ _prepared = false ;
83
+ _load = 1 ;
84
+ _commandType = CommandType . Text ;
83
85
}
84
86
85
87
/// <summary>
@@ -439,7 +441,7 @@ private CancellationToken SetupCancellationToken()
439
441
//setup new token
440
442
_cancelTokenSource = CommandTimeout > 0
441
443
? new CancellationTokenSource ( CommandTimeout * 1000 )
442
- : new CancellationTokenSource ( ) ;
444
+ : new CancellationTokenSource ( ) ;
443
445
return _cancelTokenSource . Token ;
444
446
}
445
447
@@ -525,7 +527,7 @@ protected override async Task<DbDataReader> ExecuteDbDataReaderAsync(CommandBeha
525
527
/// <param name="cancellationToken"> The cancellation token. </param>
526
528
/// <returns> </returns>
527
529
public new virtual async Task < CqlDataReader > ExecuteReaderAsync ( CommandBehavior behavior ,
528
- CancellationToken cancellationToken )
530
+ CancellationToken cancellationToken )
529
531
{
530
532
var result = await ExecuteReaderAsyncInternal ( behavior , cancellationToken ) . ConfigureAwait ( false ) ;
531
533
@@ -640,8 +642,8 @@ internal async Task<ResultFrame> ExecuteReaderAsyncInternal(CommandBehavior beha
640
642
UseBuffering = false ;
641
643
642
644
if ( behavior . HasFlag ( CommandBehavior . KeyInfo ) ||
643
- behavior . HasFlag ( CommandBehavior . SchemaOnly ) ||
644
- behavior . HasFlag ( CommandBehavior . SingleRow ) )
645
+ behavior . HasFlag ( CommandBehavior . SchemaOnly ) ||
646
+ behavior . HasFlag ( CommandBehavior . SingleRow ) )
645
647
{
646
648
var ex = new ArgumentException ( "Command behavior not supported" , "behavior" ) ;
647
649
_queryResult = new CqlError ( ex ) ;
@@ -958,9 +960,6 @@ private void FinalizePrepare(ResultFrame result, bool fromCache)
958
960
/// <returns> </returns>
959
961
private async Task PrepareAsyncInternal ( CancellationToken token , Logger logger )
960
962
{
961
- //continue?
962
- token . ThrowIfCancellationRequested ( ) ;
963
-
964
963
logger . LogVerbose ( "Waiting on Throttle" ) ;
965
964
966
965
//wait until allowed
@@ -1020,7 +1019,7 @@ private async Task<ResultFrame> RunWithRetry(
1020
1019
{
1021
1020
//set correct database if necessary
1022
1021
if ( ! string . IsNullOrWhiteSpace ( _connection . Database ) &&
1023
- ! _connection . Database . Equals ( connection . CurrentKeySpace ) )
1022
+ ! _connection . Database . Equals ( connection . CurrentKeySpace ) )
1024
1023
{
1025
1024
var useQuery = "use \" " + _connection . Database . Trim ( ) + "\" ;" ;
1026
1025
@@ -1239,11 +1238,11 @@ private bool EnlistInTransactionIfAny()
1239
1238
if ( Transaction != null )
1240
1239
{
1241
1240
var batchedCommand = new BatchFrame . BatchedCommand
1242
- {
1243
- IsPrepared = IsPrepared ,
1244
- CqlQuery = Query ,
1241
+ {
1242
+ IsPrepared = IsPrepared ,
1243
+ CqlQuery = Query ,
1245
1244
ParameterValues = HasParameters ? Parameters . Serialize ( ) : null
1246
- } ;
1245
+ } ;
1247
1246
1248
1247
Transaction . Commands . Add ( batchedCommand ) ;
1249
1248
@@ -1303,4 +1302,4 @@ private async Task<ResultFrame> SendBatchAsync(Connection connection, Logger log
1303
1302
1304
1303
#endregion
1305
1304
}
1306
- }
1305
+ }
0 commit comments