Skip to content

Commit

Permalink
Rename .RunResult returning Result (DML) type to .RunWrite. Moves tow…
Browse files Browse the repository at this point in the history
…ard #43.
  • Loading branch information
bchavez committed Feb 24, 2019
1 parent a85fad1 commit d59471d
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 49 deletions.
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v2.3.25
* **POSSIBLE BREAKING CHANGE:** `.RunResult` for `Result` (DML) type responses that correspond to inserts, deletes, updates has been renamed to `.RunWrite`. Please use the new method name instead. **Note:** The `.RunResult<T>` for `T` type responses will not be obsoleted. The reason for the former `.RunResult` method rename is to avoid confusion between `.RunResult` and `.RunResult<T>`. The obsoleted methods produce compiler warnings in this version. If no compiler warnings are produced, no changes are necessary. The obsolete methods will be removed in the next major RethinkDB driver release (2.4).

## v2.3.24
* Issue #138 - Better error handling in cursors.
* **POSSIBLE BREAKING CHANGE:** Previously, when an error response was received during cursor enumeration a `NotSupportedException` was thrown. Issue #138 changes this behavior by throwing more detailed (and more specific) exception based on the response from the server. For example, the driver will throw a `ReqlOpFailedError` exception if a cursor change feed is interrupted behind a RethinkDB proxy instead of throwing a generic `NotSupportedException`.
Expand Down
4 changes: 2 additions & 2 deletions Source/RethinkDb.Driver.Linq.Tests/LinqExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void basic_example()
R.Db(DbName)
.Table(TableName)
.Insert(games)
.RunResult(conn)
.RunWrite(conn)
.AssertInserted(4);

// Query games table via LINQ to ReQL
Expand Down Expand Up @@ -92,7 +92,7 @@ public void linq_can_query_by_index()
//Insert some games
R.Db(DbName).Table(TableName)
.Insert(games)
.RunResult(conn)
.RunWrite(conn)
.AssertInserted(4);

// Query games table via LINQ to ReQL
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.ReGrid.Tests/BucketTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void BeforeEachTest()

protected void DropFilesTable()
{
var result = db.TableDrop(this.fileTableName).RunResult(this.conn);
var result = db.TableDrop(this.fileTableName).RunWrite(this.conn);
result.AssertTablesDropped(1);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/RethinkDb.Driver.ReGrid/Bucket.Purge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task PurgeAsync(CancellationToken cancelToken = default)
{
try
{
await this.db.TableDrop(this.fileTableName).RunResultAsync(this.conn, cancelToken)
await this.db.TableDrop(this.fileTableName).RunWriteAsync(this.conn, cancelToken)
.ConfigureAwait(false);
}
catch
Expand All @@ -30,7 +30,7 @@ await this.db.TableDrop(this.fileTableName).RunResultAsync(this.conn, cancelToke

try
{
await this.db.TableDrop(this.chunkTableName).RunResultAsync(this.conn, cancelToken)
await this.db.TableDrop(this.chunkTableName).RunWriteAsync(this.conn, cancelToken)
.ConfigureAwait(false);
}
catch
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.ReGrid/Bucket.Upload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private async Task<UploadStream> CreateUploadStreamAsync(string filename, Upload
ChunkSizeBytes = options.ChunkSizeBytes
};

var result = await fileTable.Insert(fileInfo).RunResultAsync(conn, cancelToken)
var result = await fileTable.Insert(fileInfo).RunWriteAsync(conn, cancelToken)
.ConfigureAwait(false);

result.AssertNoErrors();
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.ReGrid/Bucket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected internal async Task<Result> EnsureTable(string tableName, Cancellation
return await this.db.TableList().Contains(tableName)
.Do_(tableExists =>
R.Branch(tableExists, new {tables_created = 0}, db.TableCreate(tableName)[this.tableCreateOpts])
).RunResultAsync(this.conn, cancelToken)
).RunWriteAsync(this.conn, cancelToken)
.ConfigureAwait(false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions Source/RethinkDb.Driver.ReGrid/FileSystemMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static void DeleteRevision(this Bucket bucket, Guid fileId, DeleteMode mo
R.HashMap(FileInfo.StatusJsonName, Status.Deleted)
.With(FileInfo.DeletedDateJsonName, DateTimeOffset.UtcNow)
)[deleteOpts]
.RunResultAsync(bucket.conn, cancelToken)
.RunWriteAsync(bucket.conn, cancelToken)
.ConfigureAwait(false);

result.AssertReplaced(1);
Expand All @@ -197,12 +197,12 @@ public static void DeleteRevision(this Bucket bucket, Guid fileId, DeleteMode mo
R.Array(fileId, R.Minval()),
R.Array(fileId, R.Maxval()))[new {index = bucket.chunkIndexName}]
.Delete()[deleteOpts]
.RunResultAsync(bucket.conn, cancelToken)
.RunWriteAsync(bucket.conn, cancelToken)
.ConfigureAwait(false);

//then delete the file.
await bucket.fileTable.Get(fileId).Delete()[deleteOpts]
.RunResultAsync(bucket.conn, cancelToken)
.RunWriteAsync(bucket.conn, cancelToken)
.ConfigureAwait(false);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/RethinkDb.Driver.ReGrid/UploadStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private async Task WriteBatchAsync(CancellationToken cancelToken)
{
var chunks = PrepareChunks();

await chunkTable.Insert(chunks.ToArray())[chunkInsertOpts].RunResultAsync(conn, cancelToken)
await chunkTable.Insert(chunks.ToArray())[chunkInsertOpts].RunWriteAsync(conn, cancelToken)
.ConfigureAwait(false);

this.batch.Clear();
Expand Down Expand Up @@ -208,7 +208,7 @@ private async Task WriteFinalFileInfoAsync(CancellationToken cancelToken)
this.FileInfo.FinishedAtDate = DateTimeOffset.UtcNow;
this.FileInfo.Status = Status.Completed;

await this.fileTable.Replace(this.FileInfo).RunResultAsync(conn, cancelToken)
await this.fileTable.Replace(this.FileInfo).RunWriteAsync(conn, cancelToken)
.ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.Tests/Network/AuthTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void AfterRunningTestSession()
.Connect();

R.Db("rethinkdb").Table("users").Get(bogusUsername)
.Delete().RunResult(adminConn);
.Delete().RunWrite(adminConn);

adminConn.Close();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.Tests/Network/Benchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void many_write()
{
R.db(DbName).table(TableName)
.insert(docs.Generate())
.RunResult(conn);
.RunWrite(conn);
}


Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.Tests/ReQL/AsyncAwaitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public async Task async_insert()

var result = await R.Db(DbName).Table(TableName)
.Insert(games)
.RunResultAsync(conn);
.RunWriteAsync(conn);

result.AssertInserted(4);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.Tests/ReQL/BinaryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void can_serdez_null_byte_array()

var result = R.Db(DbName).Table(TableName)
.Insert(arr)
.RunResult(conn);
.RunWrite(conn);

result.AssertInserted(1);

Expand Down
6 changes: 3 additions & 3 deletions Source/RethinkDb.Driver.Tests/ReQL/ChangeFeedTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void change_feeds_without_rx()
{
var result = R.Db(DbName).Table(TableName)
.Delete()[new { return_changes = true }]
.RunResult(conn)
.RunWrite(conn)
.AssertNoErrors();

var changes = R.Db(DbName).Table(TableName)
Expand Down Expand Up @@ -76,7 +76,7 @@ public void can_enumerate_though_change_feed_manually()
{
var result = R.Db(DbName).Table(TableName)
.Delete()[new { return_changes = true }]
.RunResult(conn)
.RunWrite(conn)
.AssertNoErrors();

var changes = R.Db(DbName).Table(TableName)
Expand Down Expand Up @@ -135,7 +135,7 @@ public void can_get_change_type()
{
var result = R.Db(DbName).Table(TableName)
.Delete()[new { return_changes = true }]
.RunResult(conn)
.RunWrite(conn)
.AssertNoErrors();

var changes = R.Db(DbName).Table(TableName)
Expand Down
2 changes: 1 addition & 1 deletion Source/RethinkDb.Driver.Tests/ReQL/Examples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void check_if_table_exists()
new {tables_created = 0}, /* If False */
R.Db(DbName).TableCreate("newTable") /* If true */
);
}).RunResult(conn);
}).RunWrite(conn);

newTableResult.Dump();
}
Expand Down
14 changes: 7 additions & 7 deletions Source/RethinkDb.Driver.Tests/ReQL/GitHubIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public void issue_20()
table.Delete().Run(conn);

Console.WriteLine(">>> INSERT");
var result = table.Insert(new {foo = "bar"}).RunResult(conn);
var result = table.Insert(new {foo = "bar"}).RunWrite(conn);
var id = result.GeneratedKeys[0];
result.AssertInserted(1);

Console.WriteLine(">>> UPDATE 1 / VALUE 1");
var value = "VALUE1";
result = table.Get(id).update(new {Target = value}).RunResult(conn);
result = table.Get(id).update(new {Target = value}).RunWrite(conn);
result.Dump();

Console.WriteLine(">>> UPDATE 2 / VALUE 2");
Expand Down Expand Up @@ -121,7 +121,7 @@ public void issue_21_raw_json_test()
var table = R.Db(DbName).Table(TableName);
table.Delete().Run(conn);

var result = table.Insert(jObject).RunResult(conn);
var result = table.Insert(jObject).RunWrite(conn);
var id = result.GeneratedKeys[0];
result.Dump();

Expand Down Expand Up @@ -173,7 +173,7 @@ public void issue_41_ensure_run_helpers_throw_error_first_before_direct_conversi
// ignored
}

Action action = () => R.DbCreate(DbName).RunResult(conn);
Action action = () => R.DbCreate(DbName).RunWrite(conn);

action.ShouldThrow<ReqlRuntimeError>();
}
Expand All @@ -197,7 +197,7 @@ public void issue_49_use_reqldatetimeconverter_for_dates_in_ast()
.Db(DbName)
.Table(TableName)
.Insert(new Issue49 {BigBang = mindate})
.RunResult(conn);
.RunWrite(conn);

insertResult.Errors.Should().Be(0);

Expand All @@ -211,7 +211,7 @@ public void issue_49_use_reqldatetimeconverter_for_dates_in_ast()
return R.Error(unchanged.CoerceTo("string"));
})
.OptArg("return_changes", true)
.RunResult(conn);
.RunWrite(conn);

updateResult.Errors.Should().Be(1);
updateResult.FirstError.Should().Be("true");
Expand Down Expand Up @@ -279,7 +279,7 @@ public void issue_86_group_using_index()
DropTable(DbName, TableName);
CreateTable(DbName, TableName);

var insertResult = table.Insert(R.Json(issues)).RunResult(conn);
var insertResult = table.Insert(R.Json(issues)).RunWrite(conn);

insertResult.AssertInserted(3);

Expand Down
4 changes: 2 additions & 2 deletions Source/RethinkDb.Driver.Tests/ReQL/JObjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void issue_21_allow_JObject_inserts()
};

Console.WriteLine(">>> INSERT");
var result = table.Insert(state).RunResult(conn);
var result = table.Insert(state).RunWrite(conn);
var id = result.GeneratedKeys[0];
result.Dump();

Expand Down Expand Up @@ -107,7 +107,7 @@ public void issue_39()
var table = R.Db(DbName).Table(TableName);
table.Delete().Run(conn);

var result = table.Insert(obj).RunResult(conn);
var result = table.Insert(obj).RunWrite(conn);
var id = result.GeneratedKeys[0];

var check = table.Get(id).RunAtom<JObject>(conn);
Expand Down
8 changes: 4 additions & 4 deletions Source/RethinkDb.Driver.Tests/ReQL/PocoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void can_bracket_on_table()
new {name = "Session 4", track = "trackB"},
new {name = "Session 5", track = "trackC"},
new {name = "Session 6", track = "trackD"},
}).RunResult(conn);
}).RunWrite(conn);

R.Db(DbName).Table(speakers)
.Insert(new[]
Expand All @@ -147,7 +147,7 @@ public void can_bracket_on_table()
new {name = "Name D"},
new {name = "Name E"},
new {name = "Name F"},
}).RunResult(conn);
}).RunWrite(conn);


var projection = new
Expand Down Expand Up @@ -188,7 +188,7 @@ public void serdes_poco_with_ignored_guid_id()
};

var result = table.Insert(poco)
.RunResult(conn);
.RunWrite(conn);

result.Dump();
result.GeneratedKeys[0].Should().NotBeEmpty();
Expand Down Expand Up @@ -216,7 +216,7 @@ public void serdes_poco_with_proper_guid()
};

var result = table.Insert(poco)
.RunResult(conn);
.RunWrite(conn);

result.Dump();
var id = result.GeneratedKeys[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void basic_change_feed_with_reactive_extensions()

var result = R.Db(DbName).Table(TableName)
.Delete()[new { return_changes = true }]
.RunResult(conn)
.RunWrite(conn)
.AssertNoErrors();

result.ChangesAs<JObject>().Dump();
Expand Down
8 changes: 4 additions & 4 deletions Source/RethinkDb.Driver.Tests/ReQL/SlackIssues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void should_be_able_to_use_getall_with_listofguid()

var inserts = R.Db(DbName).Table(TableName)
.Insert(items)
.RunResult(conn);
.RunWrite(conn);

var guids = inserts.GeneratedKeys.ToList();

Expand Down Expand Up @@ -65,7 +65,7 @@ public void jakes_serilization_of_jobject_issue()
}
};

var result = R.Db(DbName).Table(TableName).Insert(poco).RunResult(conn);
var result = R.Db(DbName).Table(TableName).Insert(poco).RunWrite(conn);
result.AssertInserted(1);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ public void olivers_datetimeoffset_issue()
};

var insertResult = R.Db(DbName).Table(TableName).Insert(obj)
.RunResult(conn);
.RunWrite(conn);

insertResult.Dump();

Expand All @@ -110,7 +110,7 @@ public void olivers_datetimeoffset_issue()
timeThing.Type.Should().Be(JTokenType.String);

var putBack = R.Db(DbName).Table(TableName).Update(getResult)
.RunResult(conn);
.RunWrite(conn);

putBack.Dump();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/RethinkDb.Driver.Tests/ReQL/StackOverflowQuestions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void question_34818423()
}
}
})
.RunResult(conn);
.RunWrite(conn);

var insertedId = result.GeneratedKeys[0];

Expand All @@ -43,7 +43,7 @@ public void question_34818423()
locations = new[] { "Seattle", "San Francisco" }
}
})
.RunResult(conn);
.RunWrite(conn);


var newObj = R.Db(DbName).Table(TableName)
Expand Down
Loading

0 comments on commit d59471d

Please sign in to comment.