aboutsummaryrefslogtreecommitdiff
path: root/common/query
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-12-13 21:57:53 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-01-23 21:20:44 +0300
commitfc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 (patch)
tree6c8c1bfb5fe89f7378b92ac066b4ca8ecfd25228 /common/query
parent02367faedb16b6186e8852de47e5b749dc48c2df (diff)
Switch to build2
Diffstat (limited to 'common/query')
-rw-r--r--common/query/array/buildfile43
-rw-r--r--common/query/array/driver.cxx81
-rw-r--r--common/query/array/makefile117
-rw-r--r--common/query/array/test.hxx12
-rw-r--r--common/query/array/test.std0
-rw-r--r--common/query/array/testscript33
-rw-r--r--common/query/basics/buildfile42
-rw-r--r--common/query/basics/driver.cxx28
-rw-r--r--common/query/basics/makefile117
-rw-r--r--common/query/basics/test.hxx6
-rw-r--r--common/query/basics/test.std112
-rw-r--r--common/query/basics/testscript150
-rw-r--r--common/query/one/buildfile42
-rw-r--r--common/query/one/driver.cxx28
-rw-r--r--common/query/one/makefile117
-rw-r--r--common/query/one/test.std0
-rw-r--r--common/query/one/testscript33
17 files changed, 425 insertions, 536 deletions
diff --git a/common/query/array/buildfile b/common/query/array/buildfile
new file mode 100644
index 0000000..3beb6d0
--- /dev/null
+++ b/common/query/array/buildfile
@@ -0,0 +1,43 @@
+# file : common/query/array/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import libodb = libodb%lib{odb}
+
+libs =
+
+for db: $databases
+ import libs += libodb-$db%lib{odb-$db}
+
+import libs += lib{common}
+
+exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript
+
+# Introduce the metadata library target to make sure the libodb library is
+# resolved for the odb_compile ad hoc rule (see build/root.build for details).
+#
+libue{test-meta}: $libodb
+
+<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta}
+
+for db: $databases
+{
+ exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi
+ <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta}
+}
+
+exe{driver}: libue{test-meta} $libs
+
+# Specify the ODB custom options to be used by the odb_compile ad hoc rule
+# (see build/root.build for details).
+#
+odb_options = --table-prefix t_query_array_ \
+ --generate-schema \
+ --generate-query \
+ --generate-prepared \
+ --sql-name-case oracle:upper
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../../alias{database-client}: include = adhoc
diff --git a/common/query/array/driver.cxx b/common/query/array/driver.cxx
index 4559553..9327751 100644
--- a/common/query/array/driver.cxx
+++ b/common/query/array/driver.cxx
@@ -5,36 +5,39 @@
//
#include <string>
-#include <memory> // std::auto_ptr
+#include <memory> // std::unique_ptr
#include <cstring> // std::memcpy
-#include <cassert>
#include <iostream>
#include <odb/database.hxx>
#include <odb/transaction.hxx>
-#include <common/config.hxx> // DATABASE_*
-#include <common/common.hxx>
+#include <libcommon/config.hxx> // DATABASE_*
+#include <libcommon/common.hxx>
#include "test.hxx"
#include "test-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
using namespace odb::core;
-#if defined(DATABASE_MYSQL)
+#ifndef MULTI_DATABASE
+# if defined(DATABASE_MYSQL)
const odb::mysql::database_type_id bt = odb::mysql::id_blob;
-#elif defined(DATABASE_SQLITE)
+# elif defined(DATABASE_SQLITE)
const odb::sqlite::database_type_id bt = odb::sqlite::id_blob;
-#elif defined(DATABASE_PGSQL)
+# elif defined(DATABASE_PGSQL)
const odb::pgsql::database_type_id bt = odb::pgsql::id_bytea;
-#elif defined(DATABASE_ORACLE)
+# elif defined(DATABASE_ORACLE)
const odb::oracle::database_type_id bt = odb::oracle::id_raw;
-#elif defined(DATABASE_MSSQL)
+# elif defined(DATABASE_MSSQL)
const odb::mssql::database_type_id bt = odb::mssql::id_binary;
-#elif defined(DATABASE_COMMON)
-#else
-# error unknown database
+# else
+# error unknown database
+# endif
#endif
int
@@ -42,7 +45,7 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<database> db (create_database (argc, argv));
+ unique_ptr<database> db (create_database (argc, argv));
typedef odb::query<object> query;
@@ -67,7 +70,7 @@ main (int argc, char* argv[])
// string
//
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == "abc")) == 1);
assert (size (db->query<object> (query::s == query::_val ("bcd"))) == 1);
assert (size (db->query<object> ("s = " + query::_val ("bcd"))) == 1);
@@ -77,12 +80,12 @@ main (int argc, char* argv[])
{
char a[] = "bcd";
char* ra = a;
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == a)) == 1);
assert (size (db->query<object> (query::s == query::_val (a))) == 1);
#endif
assert (size (db->query<object> (query::s == query::_ref (ra))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("s = " + query::_val (a))) == 1);
assert (size (db->query<object> ("s = " + query::_ref (a))) == 1);
#endif
@@ -91,12 +94,12 @@ main (int argc, char* argv[])
{
const char a[] = "bcd";
const char* ra = a;
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == a)) == 1);
assert (size (db->query<object> (query::s == query::_val (a))) == 1);
#endif
assert (size (db->query<object> (query::s == query::_ref (ra))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("s = " + query::_val (a))) == 1);
assert (size (db->query<object> ("s = " + query::_ref (a))) == 1);
#endif
@@ -104,12 +107,12 @@ main (int argc, char* argv[])
{
const char* p = "cde";
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == p)) == 1);
assert (size (db->query<object> (query::s == query::_val (p))) == 1);
#endif
assert (size (db->query<object> (query::s == query::_ref (p))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("s = " + query::_val (p))) == 1);
assert (size (db->query<object> ("s = " + query::_ref (p))) == 1);
#endif
@@ -118,18 +121,18 @@ main (int argc, char* argv[])
{
char a[] = "cde";
char* p = a;
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == p)) == 1);
assert (size (db->query<object> (query::s == query::_val (p))) == 1);
#endif
assert (size (db->query<object> (query::s == query::_ref (p))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("s = " + query::_val (p))) == 1);
assert (size (db->query<object> ("s = " + query::_ref (p))) == 1);
#endif
}
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
string s ("abc");
//assert (size (db->query<object> (query::s == s)) == 1);
assert (size (db->query<object> (query::s == s.c_str ())) == 1);
@@ -140,24 +143,42 @@ main (int argc, char* argv[])
assert (size (db->query<object> ("s = " + query::_ref (s))) == 1);
#endif
+ // @@ BUILD2 Ends up with the following warning, but strangely only in the
+ // multi-database mode:
+ //
+ // In file included from odb/odb-tests/common/query/array/test-odb.hxx:31,
+ // from odb/odb-tests/common/query/array/driver.cxx:20:
+ // odb/libodb/odb/query-dynamic.hxx: In instantiation of ‘odb::query_base odb::query_column<T>::operator==(const odb::query_column<T2>&) const [with T2 = char [17]; T = char [17]]’:
+ // odb/odb-tests/common/query/array/driver.cxx:144:7: required from here
+ // odb/libodb/odb/query-dynamic.hxx:895:43: error: comparison between two arrays is deprecated in C++20 [-Werror=array-compare]
+ // 895 | (void) (sizeof (type_instance<T> () == type_instance<T2> ()));
+ // | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
+ // odb/libodb/odb/query-dynamic.hxx:895:43: note: use unary ‘+’ which decays operands to pointers or ‘&‘indirect_ref’ not supported by dump_decl<declaration error>[0] == &‘indirect_ref’ not supported by dump_decl<declaration error>[0]’ to compare the addresses
+ //
+ // Looks like compile-time assertion. Doesn't make much sense for
+ // arrays since compares pointers to objects rather than objects.
+ // Should we somehow suppress the assertion for arrays or similar?
+ //
+ // Note: temporarily ifndef-ed.
+ //
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::s == query::s1)) == 3);
+#endif
// std::array
//
-#ifdef ODB_CXX11
array<char, 17> a;
memcpy (a.data (), "abc", 4); // VC++ strcpy deprecation.
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::a == a)) == 1);
assert (size (db->query<object> (query::a == query::_val (a))) == 1);
#endif
assert (size (db->query<object> (query::a == query::_ref (a))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("a = " + query::_val (a))) == 1);
assert (size (db->query<object> ("a = " + query::_ref (a))) == 1);
#endif
-#endif
// char
//
@@ -167,7 +188,7 @@ main (int argc, char* argv[])
assert (size (db->query<object> (query::c == query::_val (c))) == 1);
assert (size (db->query<object> (query::c == query::_ref (c))) == 1);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("c = " + query::_val ('c'))) == 1);
assert (size (db->query<object> ("c = " + query::_ref (c))) == 1);
#endif
@@ -176,14 +197,14 @@ main (int argc, char* argv[])
// buffer
//
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> (query::b == buf)) == 3);
assert (size (db->query<object> (query::b == query::_val (buf))) == 3);
#endif
assert (size (db->query<object> (query::b == query::_ref (buf))) == 3);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
assert (size (db->query<object> ("b = " + query::_val<bt> (buf))) == 3);
assert (size (db->query<object> ("b = " + query::_ref<bt> (buf))) == 3);
#endif
diff --git a/common/query/array/makefile b/common/query/array/makefile
deleted file mode 100644
index e873a34..0000000
--- a/common/query/array/makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# file : common/query/array/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := test.hxx
-genf := $(call odb-gen,$(odb_hdr))
-gen := $(addprefix $(out_base)/,$(genf))
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o))
-cxx_od := $(cxx_obj:.o=.o.d)
-
-common.l := $(out_root)/libcommon/common/common.l
-common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
-
-# Import.
-#
-$(call import,\
- $(scf_root)/import/odb/stub.make,\
- odb: odb,odb-rules: odb_rules)
-
-# Build.
-#
-$(driver): $(cxx_obj) $(common.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --generate-schema --generate-query \
---generate-prepared --sql-name-case oracle:upper --table-prefix t_query_array_
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-ifneq ($(db_id),common)
-$(gen): odb_options += --database $(db_id)
-else
-$(gen): odb_options += --multi-database dynamic
-endif
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base)))
-
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): data_dist := test.std
-$(dist): export name := $(name)
-$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \
-$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \
-$(call vc12projs,$(name))
-$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist))
- $(call meta-automake,../../template/Makefile.am)
- $(call meta-vc8projs,../../template/template,$(name))
- $(call meta-vc9projs,../../template/template,$(name))
- $(call meta-vc10projs,../../template/template,$(name))
- $(call meta-vc11projs,../../template/template,$(name))
- $(call meta-vc12projs,../../template/template,$(name))
-
-# Test.
-#
-ifneq ($(db_id),common)
-$(eval $(call test-rule))
-else
-$(foreach d,$(databases),$(eval $(call test-rule,$d)))
-endif
-
-# Clean.
-#
-$(clean): \
- $(driver).o.clean \
- $(addsuffix .cxx.clean,$(cxx_obj)) \
- $(addsuffix .cxx.clean,$(cxx_od)) \
- $(addsuffix .hxx.clean,$(filter %.cxx,$(gen)))
- $(call message,,rm -f $(out_base)/test.out)
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(driver): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := driver $(genf)
-$(clean): $(out_base)/.gitignore.clean
-
-$(call include,$(bld_root)/git/gitignore.make)
-endif
-
-# How to.
-#
-$(call include,$(bld_root)/dist.make)
-$(call include,$(bld_root)/meta/vc8proj.make)
-$(call include,$(bld_root)/meta/vc9proj.make)
-$(call include,$(bld_root)/meta/vc10proj.make)
-$(call include,$(bld_root)/meta/vc11proj.make)
-$(call include,$(bld_root)/meta/vc12proj.make)
-$(call include,$(bld_root)/meta/automake.make)
-
-$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
-ifdef cxx_standard
-$(gen): odb_options += --std $(cxx_standard)
-$(call include,$(odb_rules))
-endif
-
-$(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(bld_root)/cxx/cxx-o.make)
-$(call include,$(bld_root)/cxx/o-e.make)
-
-# Dependencies.
-#
-$(call import,$(src_root)/libcommon/makefile)
diff --git a/common/query/array/test.hxx b/common/query/array/test.hxx
index d280f02..f0d5f3b 100644
--- a/common/query/array/test.hxx
+++ b/common/query/array/test.hxx
@@ -4,14 +4,9 @@
#ifndef TEST_HXX
#define TEST_HXX
-#include <common/config.hxx> // HAVE_CXX11
-
+#include <array>
#include <cstring> // std::memcpy, std::strlen
-#ifdef HAVE_CXX11
-# include <array>
-#endif
-
#include <odb/core.hxx>
#pragma db object
@@ -23,10 +18,7 @@ struct object
{
std::memcpy (s_, s, std::strlen (s) + 1); // VC++ strncpy deprecation.
std::memcpy (s1_, s, std::strlen (s) + 1);
-
-#ifdef HAVE_CXX11
std::memcpy (a_.data (), s, std::strlen (s) + 1);
-#endif
c_ = c1_ = *s;
std::memcpy (b_, b, sizeof (b_));
}
@@ -37,7 +29,6 @@ struct object
char s_[17];
char s1_[17];
-#ifdef HAVE_CXX11
#ifdef ODB_COMPILER
# if defined(ODB_DATABASE_MYSQL) || \
defined(ODB_DATABASE_PGSQL) || \
@@ -53,7 +44,6 @@ struct object
# endif
#endif
std::array<char, 17> a_;
-#endif
char c_;
char c1_;
diff --git a/common/query/array/test.std b/common/query/array/test.std
deleted file mode 100644
index e69de29..0000000
--- a/common/query/array/test.std
+++ /dev/null
diff --git a/common/query/array/testscript b/common/query/array/testscript
new file mode 100644
index 0000000..631ae24
--- /dev/null
+++ b/common/query/array/testscript
@@ -0,0 +1,33 @@
+# file : common/query/array/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../../database-options.testscript
+
+: mysql
+:
+if $mysql
+{
+ .include ../../../mysql.testscript
+
+ $create_schema;
+ $*
+}
+
+: sqlite
+:
+if $sqlite
+{
+ .include ../../../sqlite.testscript
+
+ $*
+}
+
+: pgsql
+:
+if $pgsql
+{
+ .include ../../../pgsql.testscript
+
+ $create_schema;
+ $*
+}
diff --git a/common/query/basics/buildfile b/common/query/basics/buildfile
new file mode 100644
index 0000000..e38e6fe
--- /dev/null
+++ b/common/query/basics/buildfile
@@ -0,0 +1,42 @@
+# file : common/query/basics/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import libodb = libodb%lib{odb}
+
+libs =
+
+for db: $databases
+ import libs += libodb-$db%lib{odb-$db}
+
+import libs += lib{common}
+
+exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript
+
+# Introduce the metadata library target to make sure the libodb library is
+# resolved for the odb_compile ad hoc rule (see build/root.build for details).
+#
+libue{test-meta}: $libodb
+
+<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta}
+
+for db: $databases
+{
+ exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi
+ <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta}
+}
+
+exe{driver}: libue{test-meta} $libs
+
+# Specify the ODB custom options to be used by the odb_compile ad hoc rule
+# (see build/root.build for details).
+#
+odb_options = --table-prefix t_query_basics_ \
+ --generate-schema \
+ --generate-query \
+ --generate-prepared
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../../alias{database-client}: include = adhoc
diff --git a/common/query/basics/driver.cxx b/common/query/basics/driver.cxx
index 86bae4b..73b81d2 100644
--- a/common/query/basics/driver.cxx
+++ b/common/query/basics/driver.cxx
@@ -4,19 +4,21 @@
// Test basic query support.
//
-#include <memory> // std::auto_ptr
-#include <cassert>
+#include <memory> // std::unique_ptr
#include <iostream>
#include <odb/database.hxx>
#include <odb/transaction.hxx>
-#include <common/config.hxx> // DATABASE_XXX
-#include <common/common.hxx>
+#include <libcommon/config.hxx> // DATABASE_XXX
+#include <libcommon/common.hxx>
#include "test.hxx"
#include "test-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
using namespace odb::core;
@@ -25,7 +27,7 @@ print (result<person>& r)
{
for (result<person>::iterator i (r.begin ()); i != r.end (); ++i)
{
- auto_ptr<person> o (i.load ());
+ unique_ptr<person> o (i.load ());
cout << *o << endl;
}
cout << endl;
@@ -46,7 +48,7 @@ main (int argc, char* argv[])
try
{
- auto_ptr<database> db (create_database (argc, argv));
+ unique_ptr<database> db (create_database (argc, argv));
odb::database_id db_id (db->id ());
typedef odb::query<person> query;
@@ -76,7 +78,7 @@ main (int argc, char* argv[])
// Compilation tests.
//
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
if (false)
{
string name;
@@ -164,7 +166,7 @@ main (int argc, char* argv[])
const char* name = "Doe";
-#if defined(DATABASE_COMMON)
+#if defined(MULTI_DATABASE)
result r (
db->query<person> (
query::age >= query::_val (30) &&
@@ -195,7 +197,7 @@ main (int argc, char* argv[])
string name;
unsigned short age;
-#if defined(DATABASE_COMMON)
+#if defined(MULTI_DATABASE)
query q (query::age >= query::_ref (age) &&
query::last_name == query::_ref (name));
#elif defined(DATABASE_ORACLE)
@@ -249,7 +251,7 @@ main (int argc, char* argv[])
//db->query<person> (query::age == query::_ref (name));
db->query<person> (query::last_name == "Doe");
db->query<person> (query::last_name == name);
-#ifndef DATABASE_COMMON
+#ifndef MULTI_DATABASE
db->query<person> (query::last_name == query::_val ("Doe"));
#endif
db->query<person> (query::last_name == query::_val (name));
@@ -450,7 +452,7 @@ main (int argc, char* argv[])
assert (i != r.end ());
{
- auto_ptr<person> joe (db->load<person> (3));
+ unique_ptr<person> joe (db->load<person> (3));
}
{
@@ -467,7 +469,7 @@ main (int argc, char* argv[])
// Overwrite object image again.
//
- auto_ptr<person> joe (db->load<person> (3));
+ unique_ptr<person> joe (db->load<person> (3));
person p;
i.load (p);
assert (p.last_name_ == "Doe");
@@ -499,7 +501,7 @@ main (int argc, char* argv[])
// Oracle does not support LOB comparisons.
//
-#ifndef DATABASE_ORACLE
+#if defined(MULTI_DATABASE) || !defined(DATABASE_ORACLE)
if (db_id != odb::id_oracle)
{
r = db->query<person> (query::public_key == key2);
diff --git a/common/query/basics/makefile b/common/query/basics/makefile
deleted file mode 100644
index b1749e7..0000000
--- a/common/query/basics/makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# file : common/query/basics/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := test.hxx
-genf := $(call odb-gen,$(odb_hdr))
-gen := $(addprefix $(out_base)/,$(genf))
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o))
-cxx_od := $(cxx_obj:.o=.o.d)
-
-common.l := $(out_root)/libcommon/common/common.l
-common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
-
-# Import.
-#
-$(call import,\
- $(scf_root)/import/odb/stub.make,\
- odb: odb,odb-rules: odb_rules)
-
-# Build.
-#
-$(driver): $(cxx_obj) $(common.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --generate-schema --generate-query \
---generate-prepared --table-prefix t_query_basics_
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-ifneq ($(db_id),common)
-$(gen): odb_options += --database $(db_id)
-else
-$(gen): odb_options += --multi-database dynamic
-endif
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base)))
-
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): data_dist := test.std
-$(dist): export name := $(name)
-$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \
-$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \
-$(call vc12projs,$(name))
-$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist))
- $(call meta-automake,../../template/Makefile.am)
- $(call meta-vc8projs,../../template/template,$(name))
- $(call meta-vc9projs,../../template/template,$(name))
- $(call meta-vc10projs,../../template/template,$(name))
- $(call meta-vc11projs,../../template/template,$(name))
- $(call meta-vc12projs,../../template/template,$(name))
-
-# Test.
-#
-ifneq ($(db_id),common)
-$(eval $(call test-rule))
-else
-$(foreach d,$(databases),$(eval $(call test-rule,$d)))
-endif
-
-# Clean.
-#
-$(clean): \
- $(driver).o.clean \
- $(addsuffix .cxx.clean,$(cxx_obj)) \
- $(addsuffix .cxx.clean,$(cxx_od)) \
- $(addsuffix .hxx.clean,$(filter %.cxx,$(gen)))
- $(call message,,rm -f $(out_base)/test.out)
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(driver): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := driver $(genf)
-$(clean): $(out_base)/.gitignore.clean
-
-$(call include,$(bld_root)/git/gitignore.make)
-endif
-
-# How to.
-#
-$(call include,$(bld_root)/dist.make)
-$(call include,$(bld_root)/meta/vc8proj.make)
-$(call include,$(bld_root)/meta/vc9proj.make)
-$(call include,$(bld_root)/meta/vc10proj.make)
-$(call include,$(bld_root)/meta/vc11proj.make)
-$(call include,$(bld_root)/meta/vc12proj.make)
-$(call include,$(bld_root)/meta/automake.make)
-
-$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
-ifdef cxx_standard
-$(gen): odb_options += --std $(cxx_standard)
-$(call include,$(odb_rules))
-endif
-
-$(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(bld_root)/cxx/cxx-o.make)
-$(call include,$(bld_root)/cxx/o-e.make)
-
-# Dependencies.
-#
-$(call import,$(src_root)/libcommon/makefile)
diff --git a/common/query/basics/test.hxx b/common/query/basics/test.hxx
index 22a8d32..239f6d6 100644
--- a/common/query/basics/test.hxx
+++ b/common/query/basics/test.hxx
@@ -4,8 +4,6 @@
#ifndef TEST_HXX
#define TEST_HXX
-#include <common/config.hxx> // HAVE_CXX11
-
#include <string>
#include <vector>
#include <memory>
@@ -56,11 +54,7 @@ struct person
std::string first_name_;
#pragma db column ("middle") null
-#ifdef HAVE_CXX11
std::unique_ptr<std::string> middle_name_;
-#else
- std::auto_ptr<std::string> middle_name_;
-#endif
#pragma db column ("last")
std::string last_name_;
diff --git a/common/query/basics/test.std b/common/query/basics/test.std
deleted file mode 100644
index d420dc4..0000000
--- a/common/query/basics/test.std
+++ /dev/null
@@ -1,112 +0,0 @@
-test 001
-John Doe 30 married
-Jane Doe 29 married
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-test 002
-Jane Doe 29 married
-John Doe 30 married
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-test 003
-John Doe 30 married
-
-test 004
-John Doe 30 married
-
-test 005
-John Doe 30 married
-
-Joe Squeaky Dirt 31 single
-
-test 006
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-test 007
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-test 008
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-
-John Doe 30 married
-Jane Doe 29 married
-
-test 009
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-John Doe 30 married
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-test 010
-Jane Doe 29 married
-
-John Doe 30 married
-Jane Doe 29 married
-Joe Squeaky Dirt 31 single
-
-Jane Doe 29 married
-
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-Jane Doe 29 married
-John Doe 30 married
-
-test 011
-John Doe 30 married
-Jane Doe 29 married
-
-John Doe 30 married
-Jane Doe 29 married
-Joe Squeaky Dirt 31 single
-
-test 012
-Johansen J Johansen 32 single
-
-test 013
-Joe Squeaky Dirt 31 single
-
-test 014
-test 015
-John Doe 30 married
-Jane Doe 29 married
-
-test 016
-test 017
-test 018
-test 019
-test 020
-John Doe 30 married
-Joe Squeaky Dirt 31 single
-Johansen J Johansen 32 single
-
-Jane Doe 29 married
-
-
-Jane Doe 29 married
-
diff --git a/common/query/basics/testscript b/common/query/basics/testscript
new file mode 100644
index 0000000..9086b66
--- /dev/null
+++ b/common/query/basics/testscript
@@ -0,0 +1,150 @@
+# file : common/query/basics/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../../database-options.testscript
+
++cat <<EOI >=output
+ test 001
+ John Doe 30 married
+ Jane Doe 29 married
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+ test 002
+ Jane Doe 29 married
+ John Doe 30 married
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ test 003
+ John Doe 30 married
+
+ test 004
+ John Doe 30 married
+
+ test 005
+ John Doe 30 married
+
+ Joe Squeaky Dirt 31 single
+
+ test 006
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ test 007
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ test 008
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+
+ John Doe 30 married
+ Jane Doe 29 married
+
+ test 009
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ John Doe 30 married
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ test 010
+ Jane Doe 29 married
+
+ John Doe 30 married
+ Jane Doe 29 married
+ Joe Squeaky Dirt 31 single
+
+ Jane Doe 29 married
+
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ Jane Doe 29 married
+ John Doe 30 married
+
+ test 011
+ John Doe 30 married
+ Jane Doe 29 married
+
+ John Doe 30 married
+ Jane Doe 29 married
+ Joe Squeaky Dirt 31 single
+
+ test 012
+ Johansen J Johansen 32 single
+
+ test 013
+ Joe Squeaky Dirt 31 single
+
+ test 014
+ test 015
+ John Doe 30 married
+ Jane Doe 29 married
+
+ test 016
+ test 017
+ test 018
+ test 019
+ test 020
+ John Doe 30 married
+ Joe Squeaky Dirt 31 single
+ Johansen J Johansen 32 single
+
+ Jane Doe 29 married
+
+
+ Jane Doe 29 married
+
+ EOI
+
+test.redirects += >>>../output
+
+: mysql
+:
+if $mysql
+{
+ .include ../../../mysql.testscript
+
+ $create_schema;
+ $*
+}
+
+: sqlite
+:
+if $sqlite
+{
+ .include ../../../sqlite.testscript
+
+ $*
+}
+
+: pgsql
+:
+if $pgsql
+{
+ .include ../../../pgsql.testscript
+
+ $create_schema;
+ $*
+}
diff --git a/common/query/one/buildfile b/common/query/one/buildfile
new file mode 100644
index 0000000..76a36b0
--- /dev/null
+++ b/common/query/one/buildfile
@@ -0,0 +1,42 @@
+# file : common/query/one/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import libodb = libodb%lib{odb}
+
+libs =
+
+for db: $databases
+ import libs += libodb-$db%lib{odb-$db}
+
+import libs += lib{common}
+
+exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript
+
+# Introduce the metadata library target to make sure the libodb library is
+# resolved for the odb_compile ad hoc rule (see build/root.build for details).
+#
+libue{test-meta}: $libodb
+
+<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta}
+
+for db: $databases
+{
+ exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi
+ <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta}
+}
+
+exe{driver}: libue{test-meta} $libs
+
+# Specify the ODB custom options to be used by the odb_compile ad hoc rule
+# (see build/root.build for details).
+#
+odb_options = --table-prefix t_query_one_ \
+ --generate-schema \
+ --generate-query \
+ --generate-prepared
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../../alias{database-client}: include = adhoc
diff --git a/common/query/one/driver.cxx b/common/query/one/driver.cxx
index f3ab921..4c3dcdc 100644
--- a/common/query/one/driver.cxx
+++ b/common/query/one/driver.cxx
@@ -8,18 +8,20 @@
// specific to query_one() and query_value().
//
-#include <memory> // std::auto_ptr
-#include <cassert>
+#include <memory> // std::unique_ptr
#include <iostream>
#include <odb/database.hxx>
#include <odb/transaction.hxx>
-#include <common/common.hxx>
+#include <libcommon/common.hxx>
#include "test.hxx"
#include "test-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
using namespace odb::core;
@@ -28,7 +30,7 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<database> db (create_database (argc, argv));
+ unique_ptr<database> db (create_database (argc, argv));
odb::database_id db_id (db->id ());
transaction t (db->begin ());
@@ -36,7 +38,7 @@ main (int argc, char* argv[])
// query_one()
//
{
- auto_ptr<object> o (db->query_one<object> ());
+ unique_ptr<object> o (db->query_one<object> ());
assert (o.get () == 0);
}
@@ -57,7 +59,7 @@ main (int argc, char* argv[])
db->persist (o);
{
- auto_ptr<object> o (db->query_one<object> ());
+ unique_ptr<object> o (db->query_one<object> ());
assert (o.get () != 0 && o->str_ == "value 1");
}
@@ -77,12 +79,12 @@ main (int argc, char* argv[])
const char* q0_c (db_id == odb::id_oracle ? "\"id\" = 2" : "id = 2");
{
- auto_ptr<object> o (db->query_one<object> (q1_c));
+ unique_ptr<object> o (db->query_one<object> (q1_c));
assert (o.get () != 0 && o->str_ == "value 1");
}
{
- auto_ptr<object> o (db->query_one<object> (q0_c));
+ unique_ptr<object> o (db->query_one<object> (q0_c));
assert (o.get () == 0);
}
@@ -108,12 +110,12 @@ main (int argc, char* argv[])
string q0_s (q0_c);
{
- auto_ptr<object> o (db->query_one<object> (q1_s));
+ unique_ptr<object> o (db->query_one<object> (q1_s));
assert (o.get () != 0 && o->str_ == "value 1");
}
{
- auto_ptr<object> o (db->query_one<object> (q0_s));
+ unique_ptr<object> o (db->query_one<object> (q0_s));
assert (o.get () == 0);
}
@@ -141,12 +143,12 @@ main (int argc, char* argv[])
query q0 (query::id == 2);
{
- auto_ptr<object> o (db->query_one<object> (q1));
+ unique_ptr<object> o (db->query_one<object> (q1));
assert (o.get () != 0 && o->str_ == "value 1");
}
{
- auto_ptr<object> o (db->query_one<object> (q0));
+ unique_ptr<object> o (db->query_one<object> (q0));
assert (o.get () == 0);
}
@@ -175,7 +177,7 @@ main (int argc, char* argv[])
/*
{
- auto_ptr<object> o (db->query_one<object> ());
+ unique_ptr<object> o (db->query_one<object> ());
assert (false);
}
*/
diff --git a/common/query/one/makefile b/common/query/one/makefile
deleted file mode 100644
index fa3b557..0000000
--- a/common/query/one/makefile
+++ /dev/null
@@ -1,117 +0,0 @@
-# file : common/query/one/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := test.hxx
-genf := $(call odb-gen,$(odb_hdr))
-gen := $(addprefix $(out_base)/,$(genf))
-cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.o))
-cxx_od := $(cxx_obj:.o=.o.d)
-
-common.l := $(out_root)/libcommon/common/common.l
-common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
-
-# Import.
-#
-$(call import,\
- $(scf_root)/import/odb/stub.make,\
- odb: odb,odb-rules: odb_rules)
-
-# Build.
-#
-$(driver): $(cxx_obj) $(common.l)
-$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen) $(dist): export odb_options += --generate-schema --generate-query \
---generate-prepared --table-prefix t_query_one_
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-ifneq ($(db_id),common)
-$(gen): odb_options += --database $(db_id)
-else
-$(gen): odb_options += --multi-database dynamic
-endif
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base)))
-
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): data_dist := test.std
-$(dist): export name := $(name)
-$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \
-$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \
-$(call vc12projs,$(name))
-$(dist):
- $(call dist-data,$(sources) $(headers) $(data_dist))
- $(call meta-automake,../../template/Makefile.am)
- $(call meta-vc8projs,../../template/template,$(name))
- $(call meta-vc9projs,../../template/template,$(name))
- $(call meta-vc10projs,../../template/template,$(name))
- $(call meta-vc11projs,../../template/template,$(name))
- $(call meta-vc12projs,../../template/template,$(name))
-
-# Test.
-#
-ifneq ($(db_id),common)
-$(eval $(call test-rule))
-else
-$(foreach d,$(databases),$(eval $(call test-rule,$d)))
-endif
-
-# Clean.
-#
-$(clean): \
- $(driver).o.clean \
- $(addsuffix .cxx.clean,$(cxx_obj)) \
- $(addsuffix .cxx.clean,$(cxx_od)) \
- $(addsuffix .hxx.clean,$(filter %.cxx,$(gen)))
- $(call message,,rm -f $(out_base)/test.out)
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(driver): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := driver $(genf)
-$(clean): $(out_base)/.gitignore.clean
-
-$(call include,$(bld_root)/git/gitignore.make)
-endif
-
-# How to.
-#
-$(call include,$(bld_root)/dist.make)
-$(call include,$(bld_root)/meta/vc8proj.make)
-$(call include,$(bld_root)/meta/vc9proj.make)
-$(call include,$(bld_root)/meta/vc10proj.make)
-$(call include,$(bld_root)/meta/vc11proj.make)
-$(call include,$(bld_root)/meta/vc12proj.make)
-$(call include,$(bld_root)/meta/automake.make)
-
-$(call include,$(bld_root)/cxx/standard.make) # cxx_standard
-ifdef cxx_standard
-$(gen): odb_options += --std $(cxx_standard)
-$(call include,$(odb_rules))
-endif
-
-$(call include,$(bld_root)/cxx/cxx-d.make)
-$(call include,$(bld_root)/cxx/cxx-o.make)
-$(call include,$(bld_root)/cxx/o-e.make)
-
-# Dependencies.
-#
-$(call import,$(src_root)/libcommon/makefile)
diff --git a/common/query/one/test.std b/common/query/one/test.std
deleted file mode 100644
index e69de29..0000000
--- a/common/query/one/test.std
+++ /dev/null
diff --git a/common/query/one/testscript b/common/query/one/testscript
new file mode 100644
index 0000000..963a206
--- /dev/null
+++ b/common/query/one/testscript
@@ -0,0 +1,33 @@
+# file : common/query/one/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../../database-options.testscript
+
+: mysql
+:
+if $mysql
+{
+ .include ../../../mysql.testscript
+
+ $create_schema;
+ $*
+}
+
+: sqlite
+:
+if $sqlite
+{
+ .include ../../../sqlite.testscript
+
+ $*
+}
+
+: pgsql
+:
+if $pgsql
+{
+ .include ../../../pgsql.testscript
+
+ $create_schema;
+ $*
+}