aboutsummaryrefslogtreecommitdiff
path: root/odb/relational/source.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-01-14 16:01:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-01-14 16:01:06 +0200
commit0e6be616e40c86ff03df7c0806bcbd0cc3c4489f (patch)
tree410e7ab2e10bb3dd0df30aab2135ed4544555157 /odb/relational/source.cxx
parent604517928701b3ef2783ede9a0b3b2f80c92ec92 (diff)
Add support for MSSQL ROWVERSION
ODB can now use ROWVERSION column as an optimistic concurrency version.
Diffstat (limited to 'odb/relational/source.cxx')
-rw-r--r--odb/relational/source.cxx26
1 files changed, 19 insertions, 7 deletions
diff --git a/odb/relational/source.cxx b/odb/relational/source.cxx
index f133750..0ec7cc4 100644
--- a/odb/relational/source.cxx
+++ b/odb/relational/source.cxx
@@ -687,6 +687,8 @@ traverse_object (type& c)
os << strlit (c + (++i != e ? "," : "")) << endl;
}
+ update_statement_extra (c);
+
for (object_columns_list::iterator b (id_cols->begin ()), i (b);
i != id_cols->end (); ++i)
{
@@ -980,12 +982,13 @@ traverse_object (type& c)
// If we don't have auto id, then obj is a const reference.
//
string obj (auto_id ? "obj" : "const_cast< object_type& > (obj)");
+ string init (optimimistic_version_init (*opt));
if (!opt_ma_set->synthesized)
os << "// From " << location_string (opt_ma_set->loc, true) << endl;
if (opt_ma_set->placeholder ())
- os << opt_ma_set->translate (obj, "1") << ";"
+ os << opt_ma_set->translate (obj, init) << ";"
<< endl;
else
{
@@ -1002,7 +1005,7 @@ traverse_object (type& c)
if (cast)
os << ")";
- os << " = 1;"
+ os << " = " << init << ";"
<< endl;
}
}
@@ -1397,6 +1400,7 @@ traverse_object (type& c)
// constness.
//
string obj ("const_cast< object_type& > (obj)");
+ string inc (optimimistic_version_increment (*opt));
if (!opt_ma_set->synthesized)
os << "// From " << location_string (opt_ma_set->loc, true) << endl;
@@ -1407,9 +1411,13 @@ traverse_object (type& c)
os << "// From " << location_string (opt_ma_get->loc, true) <<
endl;
- os << opt_ma_set->translate (
- obj, opt_ma_get->translate ("obj") + " + 1") << ";"
- << endl;
+ if (inc == "1")
+ os << opt_ma_set->translate (
+ obj, opt_ma_get->translate ("obj") + " + 1") << ";";
+ else
+ os << opt_ma_set->translate (obj, inc) << ";";
+
+ os << endl;
}
else
{
@@ -1426,8 +1434,12 @@ traverse_object (type& c)
if (cast)
os << ")";
- os << "++;"
- << endl;
+ if (inc == "1")
+ os << "++;";
+ else
+ os << " = " << inc << ";";
+
+ os << endl;
}
}