Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit da84b37

Browse files
committed
Rename UpdateIncrement to UpdateAdd
1 parent a8734e9 commit da84b37

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

src/ServiceStack.OrmLite/Expressions/WriteExpressionCommandExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,26 @@ public static int UpdateOnly<T, TKey>(this IDbCommand dbCmd, T obj,
5151
return dbCmd.UpdateOnly(obj, q);
5252
}
5353

54-
public static int UpdateIncrement<T>(this IDbCommand dbCmd, T model, SqlExpression<T> fields)
54+
public static int UpdateAdd<T>(this IDbCommand dbCmd, T model, SqlExpression<T> fields)
5555
{
56-
UpdateIncrementSql(dbCmd, model, fields);
56+
UpdateAddSql(dbCmd, model, fields);
5757
return dbCmd.ExecNonQuery();
5858
}
5959

60-
internal static void UpdateIncrementSql<T>(this IDbCommand dbCmd, T model, SqlExpression<T> fields)
60+
internal static void UpdateAddSql<T>(this IDbCommand dbCmd, T model, SqlExpression<T> fields)
6161
{
6262
if (OrmLiteConfig.UpdateFilter != null)
6363
OrmLiteConfig.UpdateFilter(dbCmd, model);
6464

6565
fields.CopyParamsTo(dbCmd);
6666

67-
dbCmd.GetDialectProvider().PrepareUpdateRowIncrementStatement(dbCmd, model, fields.UpdateFields);
67+
dbCmd.GetDialectProvider().PrepareUpdateRowAddStatement(dbCmd, model, fields.UpdateFields);
6868

6969
if (!fields.WhereExpression.IsNullOrEmpty())
7070
dbCmd.CommandText += " " + fields.WhereExpression;
7171
}
7272

73-
public static int UpdateIncrement<T, TKey>(this IDbCommand dbCmd, T obj,
73+
public static int UpdateAdd<T, TKey>(this IDbCommand dbCmd, T obj,
7474
Expression<Func<T, TKey>> fields = null,
7575
Expression<Func<T, bool>> where = null)
7676
{
@@ -80,7 +80,7 @@ public static int UpdateIncrement<T, TKey>(this IDbCommand dbCmd, T obj,
8080
var q = dbCmd.GetDialectProvider().SqlExpression<T>();
8181
q.Update(fields);
8282
q.Where(where);
83-
return dbCmd.UpdateIncrement(obj, q);
83+
return dbCmd.UpdateAdd(obj, q);
8484
}
8585

8686
public static int UpdateNonDefaults<T>(this IDbCommand dbCmd, T item, Expression<Func<T, bool>> obj)

src/ServiceStack.OrmLite/IOrmLiteDialectProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ string GetColumnDefinition(
121121

122122
void PrepareUpdateRowStatement(IDbCommand dbCmd, object objWithProperties, ICollection<string> UpdateFields = null);
123123

124-
void PrepareUpdateRowIncrementStatement(IDbCommand dbCmd, object objWithProperties, ICollection<string> UpdateFields);
124+
void PrepareUpdateRowAddStatement(IDbCommand dbCmd, object objWithProperties, ICollection<string> UpdateFields);
125125

126126
string ToDeleteStatement(Type tableType, string sqlFilter, params object[] filterParams);
127127

src/ServiceStack.OrmLite/OrmLiteDialectProviderBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ public virtual void PrepareUpdateRowStatement(IDbCommand dbCmd, object objWithPr
949949
throw new Exception("No valid update properties provided (e.g. p => p.FirstName): " + dbCmd.CommandText);
950950
}
951951

952-
public virtual void PrepareUpdateRowIncrementStatement(IDbCommand dbCmd, object objWithProperties, ICollection<string> updateFields)
952+
public virtual void PrepareUpdateRowAddStatement(IDbCommand dbCmd, object objWithProperties, ICollection<string> updateFields)
953953
{
954954
if (updateFields.Count == 0)
955955
throw new Exception("No valid update properties provided (e.g. p => p.FirstName): " + dbCmd.CommandText);
@@ -994,7 +994,7 @@ public virtual void PrepareUpdateRowIncrementStatement(IDbCommand dbCmd, object
994994
}
995995
catch (Exception ex)
996996
{
997-
Log.Error("ERROR in ToUpdateIncrementRowStatement(): " + ex.Message, ex);
997+
Log.Error("ERROR in PrepareUpdateRowAddStatement(): " + ex.Message, ex);
998998
}
999999
}
10001000

src/ServiceStack.OrmLite/OrmLiteWriteExpressionsApi.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,35 @@ public static int UpdateOnly<T, TKey>(this IDbConnection dbConn, T obj,
6262
/// avoiding concurrency conflicts
6363
///
6464
/// var q = db.From&gt;Person&lt;());
65-
/// db.UpdateIncrement(new Person { Age = 5 }, db.From<Person>().Update(p => p.Age).Where(x => x.FirstName == "Jimi"));
65+
/// db.UpdateAdd(new Person { Age = 5 }, db.From<Person>().Update(p => p.Age).Where(x => x.FirstName == "Jimi"));
6666
/// UPDATE "Person" SET "Age" = "Age" + 5 WHERE ("FirstName" = 'Jimi')
6767
///
6868
/// What's not in the update expression doesn't get updated. No where expression updates all rows. E.g:
6969
///
70-
/// db.UpdateIncrement(new Person { Age = 5, FirstName = "JJ", LastName = "Hendo" }, ev.Update(p => p.Age));
70+
/// db.UpdateAdd(new Person { Age = 5, FirstName = "JJ", LastName = "Hendo" }, ev.Update(p => p.Age));
7171
/// UPDATE "Person" SET "Age" = "Age" + 5
7272
/// </summary>
73-
public static int UpdateIncrement<T>(this IDbConnection dbConn, T model, SqlExpression<T> fields)
73+
public static int UpdateAdd<T>(this IDbConnection dbConn, T model, SqlExpression<T> fields)
7474
{
75-
return dbConn.Exec(dbCmd => dbCmd.UpdateIncrement(model, fields));
75+
return dbConn.Exec(dbCmd => dbCmd.UpdateAdd(model, fields));
7676
}
7777

7878
/// <summary>
7979
/// Update record, updating only fields specified in updateOnly that matches the where condition (if any), E.g:
8080
/// Numeric fields generates an increment sql which is usefull to increment counters, etc...
8181
/// avoiding concurrency conflicts
8282
///
83-
/// db.UpdateIncrement(new Person { Age = 5 }, p => p.Age, p => p.LastName == "Hendrix");
83+
/// db.UpdateAdd(new Person { Age = 5 }, p => p.Age, p => p.LastName == "Hendrix");
8484
/// UPDATE "Person" SET "Age" = "Age" + 5 WHERE ("LastName" = 'Hendrix')
8585
///
86-
/// db.UpdateIncrement(new Person { Age = 5 }, p => p.FirstName);
86+
/// db.UpdateAdd(new Person { Age = 5 }, p => p.FirstName);
8787
/// UPDATE "Person" SET "Age" = "Age" + 5
8888
/// </summary>
89-
public static int UpdateIncrement<T, TKey>(this IDbConnection dbConn, T obj,
89+
public static int UpdateAdd<T, TKey>(this IDbConnection dbConn, T obj,
9090
Expression<Func<T, TKey>> fields = null,
9191
Expression<Func<T, bool>> where = null)
9292
{
93-
return dbConn.Exec(dbCmd => dbCmd.UpdateIncrement(obj, fields, where));
93+
return dbConn.Exec(dbCmd => dbCmd.UpdateAdd(obj, fields, where));
9494
}
9595

9696
/// <summary>

tests/ServiceStack.OrmLite.Tests/ApiSqlServerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,16 @@ public void API_SqlServer_Parameterized_Examples()
324324
db.UpdateOnly(new Person { FirstName = "JJ" }, q => q.Update(x => x.FirstName).Where(x => x.FirstName == "Jimi"));
325325
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"FirstName\"=@1 WHERE (\"FirstName\" = @0)"));
326326

327-
db.UpdateIncrement(new Person { Age = 3 }, x => x.Age);
327+
db.UpdateAdd(new Person { Age = 3 }, x => x.Age);
328328
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@0"));
329329

330-
db.UpdateIncrement(new Person { Age = 5 }, x => x.Age, x => x.LastName == "Presley");
330+
db.UpdateAdd(new Person { Age = 5 }, x => x.Age, x => x.LastName == "Presley");
331331
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@1 WHERE (\"LastName\" = @0)"));
332332

333-
db.UpdateIncrement(new Person { Age = -2, LastName = "Hendo" }, db.From<Person>().Update(x => new { x.Age, x.LastName }));
333+
db.UpdateAdd(new Person { Age = -2, LastName = "Hendo" }, db.From<Person>().Update(x => new { x.Age, x.LastName }));
334334
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"LastName\"=@0, \"Age\"=\"Age\"+@1"));
335335

336-
db.UpdateIncrement(new Person { Age = 10}, db.From<Person>().Update(x => x.Age).Where(x => x.FirstName == "JJ"));
336+
db.UpdateAdd(new Person { Age = 10}, db.From<Person>().Update(x => x.Age).Where(x => x.FirstName == "JJ"));
337337
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@1 WHERE (\"FirstName\" = @0)"));
338338

339339
db.UpdateFmt<Person>(set: "FirstName = {0}".SqlFmt("JJ"), where: "LastName = {0}".SqlFmt("Hendrix"));

tests/ServiceStack.OrmLite.Tests/ApiSqliteTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,16 +328,16 @@ public void API_Sqlite_Parameterized_Examples()
328328
db.UpdateOnly(new Person { FirstName = "JJ" }, q => q.Update(p => p.FirstName).Where(x => x.FirstName == "Jimi"));
329329
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"FirstName\"=@1 WHERE (\"FirstName\" = @0)"));
330330

331-
db.UpdateIncrement(new Person { Age = 3 }, x => x.Age);
331+
db.UpdateAdd(new Person { Age = 3 }, x => x.Age);
332332
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@0"));
333333

334-
db.UpdateIncrement(new Person { Age = 5 }, x => x.Age, x => x.LastName == "Presley");
334+
db.UpdateAdd(new Person { Age = 5 }, x => x.Age, x => x.LastName == "Presley");
335335
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@1 WHERE (\"LastName\" = @0)"));
336336

337-
db.UpdateIncrement(new Person { Age = -2, LastName = "Hendo" }, db.From<Person>().Update(x => new { x.Age, x.LastName }));
337+
db.UpdateAdd(new Person { Age = -2, LastName = "Hendo" }, db.From<Person>().Update(x => new { x.Age, x.LastName }));
338338
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"LastName\"=@0, \"Age\"=\"Age\"+@1"));
339339

340-
db.UpdateIncrement(new Person { Age = 10 }, db.From<Person>().Update(x => x.Age).Where(x => x.FirstName == "JJ"));
340+
db.UpdateAdd(new Person { Age = 10 }, db.From<Person>().Update(x => x.Age).Where(x => x.FirstName == "JJ"));
341341
Assert.That(db.GetLastSql(), Is.EqualTo("UPDATE \"Person\" SET \"Age\"=\"Age\"+@1 WHERE (\"FirstName\" = @0)"));
342342

343343
db.UpdateFmt<Person>(set: "FirstName = {0}".SqlFmt("JJ"), where: "LastName = {0}".SqlFmt("Hendrix"));

0 commit comments

Comments
 (0)