aboutsummaryrefslogtreecommitdiff
path: root/evolution/soft-delete
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-16 07:07:33 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-17 12:04:03 +0200
commitb6ebd340651eaf347c86d3ba0dbed82c6cc8fb8d (patch)
tree78f43b3355d87424a000bb6f2ccd2a117f3affa7 /evolution/soft-delete
parentea176df42469417c37ad050616db23a01277b4e0 (diff)
Implement logical column drop for SQLite
Diffstat (limited to 'evolution/soft-delete')
-rw-r--r--evolution/soft-delete/driver.cxx99
-rw-r--r--evolution/soft-delete/makefile2
-rw-r--r--evolution/soft-delete/model.hxx8
3 files changed, 70 insertions, 39 deletions
diff --git a/evolution/soft-delete/driver.cxx b/evolution/soft-delete/driver.cxx
index a5e9927..7c53f28 100644
--- a/evolution/soft-delete/driver.cxx
+++ b/evolution/soft-delete/driver.cxx
@@ -14,6 +14,7 @@
#include <odb/schema-catalog.hxx>
#include <common/common.hxx>
+#include <common/config.hxx> // DATABASE_XXX
#include "test2.hxx"
#include "test3.hxx"
@@ -68,10 +69,6 @@ main (int argc, char* argv[])
}
}
- // SQLite doesn't support dropping of columns.
- //
-#ifndef DATABASE_SQLITE
-
// Test basic soft-deleted member logic.
//
{
@@ -265,8 +262,6 @@ main (int argc, char* argv[])
}
}
-#endif // DATABASE_SQLITE
-
// Test soft-deleted container member in a non-versioned object.
//
{
@@ -325,10 +320,6 @@ main (int argc, char* argv[])
}
}
- // SQLite doesn't support dropping of columns.
- //
-#ifndef DATABASE_SQLITE
-
// Test basic soft-deleted member logic.
//
{
@@ -938,8 +929,6 @@ main (int argc, char* argv[])
}
}
-#endif // DATABASE_SQLITE
-
// Test soft-deleted container member in a non-versioned object.
//
{
@@ -1083,10 +1072,6 @@ main (int argc, char* argv[])
catch (const odb::exception&) {}
}
- // SQLite doesn't support dropping of columns.
- //
-#ifndef DATABASE_SQLITE
-
// Test basic soft-deleted member logic.
//
{
@@ -1114,13 +1099,18 @@ main (int argc, char* argv[])
i->str == "" && i->num == 123 &&
i->vec.empty () && i->ptr == 0);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1275,13 +1265,18 @@ main (int argc, char* argv[])
result::iterator i (r.begin ());
assert (i != r.end () && i->str == "" && i->num == 123);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
}
@@ -1298,13 +1293,16 @@ main (int argc, char* argv[])
transaction t (db->begin ());
auto_ptr<object> p (db->load<object> (1));
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->load (*p, p->s); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#endif
t.commit ();
}
@@ -1364,13 +1362,18 @@ main (int argc, char* argv[])
db->load (*i, i->s);
assert (i->str == "" && i->num == 123 && i->vec.empty ());
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1445,13 +1448,18 @@ main (int argc, char* argv[])
object& o (static_cast<object&> (*i));
assert (o.bstr == "" && o.dstr == "" && o.num == 123);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<base> (query::bstr == "ab"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<base> (query::bstr.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1465,13 +1473,18 @@ main (int argc, char* argv[])
assert (i != r.end () &&
i->bstr == "" && i->dstr == "" && i->num);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::dstr == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::dstr.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1519,13 +1532,16 @@ main (int argc, char* argv[])
transaction t (db->begin ());
auto_ptr<base> p (db->load<base> (1));
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->load (*p, p->s); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#endif
t.commit ();
}
@@ -1587,13 +1603,18 @@ main (int argc, char* argv[])
object& o (static_cast<object&> (*i));
assert (o.bstr == "" && o.dstr == "" && o.num == 123);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<base> (query::bstr == "ab"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<base> (query::bstr.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1608,13 +1629,18 @@ main (int argc, char* argv[])
assert (i != r.end () &&
i->bstr == "" && i->dstr == "" && i->num);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::dstr == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::dstr.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1703,13 +1729,18 @@ main (int argc, char* argv[])
result::iterator i (r.begin ());
assert (i != r.end () && i->str == "" && i->num == 123);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1762,13 +1793,18 @@ main (int argc, char* argv[])
result::iterator i (r.begin ());
assert (i != r.end () && i->str == "" && i->num == 123);
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1813,13 +1849,18 @@ main (int argc, char* argv[])
assert (i != r.end () && i->str == "" && i->num == 123);
id = i->id;
+ // Logical delete in SQLite.
+ //
+#ifndef DATABASE_SQLITE
try
{
db->query<object> (query::str == "abc"); // No such column.
assert (false);
}
catch (const odb::exception&) {}
-
+#else
+ assert (size (db->query<object> (query::str.is_null ())) == 1);
+#endif
t.commit ();
}
@@ -1860,8 +1901,6 @@ main (int argc, char* argv[])
}
}
-#endif // DATABASE_SQLITE
-
// Test soft-deleted container member in a non-versioned object.
//
{
diff --git a/evolution/soft-delete/makefile b/evolution/soft-delete/makefile
index 12d02a3..f4c5091 100644
--- a/evolution/soft-delete/makefile
+++ b/evolution/soft-delete/makefile
@@ -37,7 +37,7 @@ $(cxx_obj) $(cxx_od): $(common.l.cpp-options)
$(gen): $(odb)
$(gen): odb := $(odb)
$(gen) $(dist): odb_common_options = --generate-query --generate-prepared \
---generate-schema --at-once --table-prefix evo_soft_d_
+--generate-schema --at-once --sqlite-override-null --table-prefix evo_soft_d_
$(gen): odb_common_options += --database $(db_id)
$(gen1) $(dist): export odb_options1 = $(odb_common_options) --init-changelog
$(gen2) $(dist): export odb_options2 = $(odb_common_options) --omit-create \
diff --git a/evolution/soft-delete/model.hxx b/evolution/soft-delete/model.hxx
index ef5bc68..0a81116 100644
--- a/evolution/soft-delete/model.hxx
+++ b/evolution/soft-delete/model.hxx
@@ -13,8 +13,6 @@
#include <odb/section.hxx>
#include <odb/lazy-ptr.hxx>
-#include <common/config.hxx> // DATABASE_XXX
-
#pragma db model version(1, MODEL_VERSION)
#define MODEL_NAMESPACE_IMPL(V) v##V
@@ -43,10 +41,6 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
#endif
}
- // SQLite doesn't support dropping of columns.
- //
-#ifndef DATABASE_SQLITE
-
// Test basic soft-deleted member logic.
//
#pragma db namespace table("t2_")
@@ -433,8 +427,6 @@ namespace MODEL_NAMESPACE(MODEL_VERSION)
#endif
}
-#endif // DATABASE_SQLITE
-
// Test soft-deleted container member in a non-versioned object.
//
#pragma db namespace table("t21_")