aboutsummaryrefslogtreecommitdiff
path: root/mysql/custom
diff options
context:
space:
mode:
Diffstat (limited to 'mysql/custom')
-rw-r--r--mysql/custom/buildfile37
-rw-r--r--mysql/custom/driver.cxx14
-rw-r--r--mysql/custom/makefile110
-rw-r--r--mysql/custom/query.hxx4
-rw-r--r--mysql/custom/test.hxx4
-rw-r--r--mysql/custom/test.std0
-rw-r--r--mysql/custom/testscript11
-rw-r--r--mysql/custom/traits.hxx4
8 files changed, 62 insertions, 122 deletions
diff --git a/mysql/custom/buildfile b/mysql/custom/buildfile
new file mode 100644
index 0000000..4934e7c
--- /dev/null
+++ b/mysql/custom/buildfile
@@ -0,0 +1,37 @@
+# file : mysql/custom/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+assert ($mysql && !$multi || $build.meta_operation == 'dist') \
+"mysql should be configured via config.odb_tests.database variable as a single database"
+
+import libodb = libodb%lib{odb}
+
+import libs = libodb-mysql%lib{odb-mysql}
+import libs += lib{common}
+
+exe{driver}: {hxx cxx}{* -*-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}
+
+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 mysql_custom_ \
+ --generate-schema \
+ --default-database common \
+ --generate-query \
+ --hxx-prologue '#include "traits.hxx"' \
+ --hxx-prologue '#include "query.hxx"'
+
+cxx.poptions =+ "-I$out_base" "-I$src_base"
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../alias{mysql-client}: include = adhoc
diff --git a/mysql/custom/driver.cxx b/mysql/custom/driver.cxx
index e9cc7d9..526dbdc 100644
--- a/mysql/custom/driver.cxx
+++ b/mysql/custom/driver.cxx
@@ -4,18 +4,20 @@
// Test custom database type mapping in MySQL.
//
-#include <memory> // std::auto_ptr
-#include <cassert>
+#include <memory> // std::unique_ptr
#include <iostream>
#include <odb/mysql/database.hxx>
#include <odb/mysql/transaction.hxx>
-#include <common/common.hxx>
+#include <libcommon/common.hxx>
#include "test.hxx"
#include "test-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
namespace mysql = odb::mysql;
using namespace mysql;
@@ -25,7 +27,7 @@ main (int argc, char* argv[])
{
try
{
- auto_ptr<database> db (create_specific_database<database> (argc, argv));
+ unique_ptr<database> db (create_specific_database<database> (argc, argv));
object o (1);
o.p = point (1.1111, 2222222222.2);
@@ -48,7 +50,7 @@ main (int argc, char* argv[])
//
{
transaction t (db->begin ());
- auto_ptr<object> o1 (db->load<object> (1));
+ unique_ptr<object> o1 (db->load<object> (1));
t.commit ();
assert (o == *o1);
@@ -101,7 +103,7 @@ main (int argc, char* argv[])
{
transaction t (db->begin ());
- auto_ptr<object> o1 (db->load<object> (1));
+ unique_ptr<object> o1 (db->load<object> (1));
t.commit ();
assert (o == *o1);
diff --git a/mysql/custom/makefile b/mysql/custom/makefile
deleted file mode 100644
index 575cfa6..0000000
--- a/mysql/custom/makefile
+++ /dev/null
@@ -1,110 +0,0 @@
-# file : mysql/custom/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 += --database mysql --default-database \
-common --generate-schema --generate-query --hxx-prologue \
-'\#include "traits.hxx"' --hxx-prologue '\#include "query.hxx"' \
---table-prefix mysql_custom_
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist
-#
-$(dist): sources := $(cxx_tun)
-$(dist): headers := $(odb_hdr)
-$(dist): export extra_headers := traits.hxx query.hxx
-$(dist): data_dist := test.std
-$(dist): export name := $(subst /,-,$(subst $(src_root)/mysql/,,$(src_base)))
-$(dist): export extra_dist := $(data_dist) \
-$(name)-vc8.vcproj $(name)-vc9.vcproj \
-$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters \
-$(name)-vc11.vcxproj $(name)-vc11.vcxproj.filters \
-$(name)-vc12.vcxproj $(name)-vc12.vcxproj.filters
-$(dist):
- $(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist))
- $(call meta-automake,../template/Makefile.am)
- $(call meta-vc8proj,../template/template-vc8.vcproj,$(name)-vc8.vcproj)
- $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
- $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
- $(call meta-vc11proj,../template/template-vc11.vcxproj,$(name)-vc11.vcxproj)
- $(call meta-vc12proj,../template/template-vc12.vcxproj,$(name)-vc12.vcxproj)
-
-# Test.
-#
-$(eval $(call test-rule))
-
-# 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/mysql/custom/query.hxx b/mysql/custom/query.hxx
index aa0c9ed..2fa8f73 100644
--- a/mysql/custom/query.hxx
+++ b/mysql/custom/query.hxx
@@ -128,8 +128,8 @@ namespace odb
public:
query_column (const char* table, const char* column, const char* conv)
: table_ (table), column_ (column), conversion_ (conv),
- x_table_ ("X(" + std::string (table)), // @@ Not very clean.
- y_table_ ("Y(" + std::string (table)),
+ x_table_ ("ST_X(" + std::string (table)), // @@ Not very clean.
+ y_table_ ("ST_Y(" + std::string (table)),
s_column_ (std::string (column) + ")"), // X & Y column suffix.
x (x_table_.c_str (), s_column_.c_str (), 0),
y (y_table_.c_str (), s_column_.c_str (), 0)
diff --git a/mysql/custom/test.hxx b/mysql/custom/test.hxx
index b6c2c86..82cc59d 100644
--- a/mysql/custom/test.hxx
+++ b/mysql/custom/test.hxx
@@ -13,8 +13,8 @@
//
#pragma db map type("GEOMETRY") \
as("VARCHAR(256)") \
- to("GeomFromText((?))") \
- from("AsText((?))")
+ to("ST_GeomFromText((?))") \
+ from("ST_AsText((?))")
#pragma db value type("GEOMETRY")
struct point
diff --git a/mysql/custom/test.std b/mysql/custom/test.std
deleted file mode 100644
index e69de29..0000000
--- a/mysql/custom/test.std
+++ /dev/null
diff --git a/mysql/custom/testscript b/mysql/custom/testscript
new file mode 100644
index 0000000..9bc8839
--- /dev/null
+++ b/mysql/custom/testscript
@@ -0,0 +1,11 @@
+# file : mysql/custom/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../database-options.testscript
+.include ../../mysql.testscript
+
++$create_schema
+
+: basics
+:
+$*
diff --git a/mysql/custom/traits.hxx b/mysql/custom/traits.hxx
index 9c9ec93..5386d86 100644
--- a/mysql/custom/traits.hxx
+++ b/mysql/custom/traits.hxx
@@ -16,7 +16,7 @@ namespace odb
{
namespace mysql
{
- template <>
+ template <>
class value_traits<point, id_string>
{
public:
@@ -79,7 +79,7 @@ namespace odb
struct conversion
{
- static const char* to () {return "GeomFromText((?))";}
+ static const char* to () {return "ST_GeomFromText((?))";}
};
};
}