From 06712594f44e8300570103c05f54d686dfc4fb53 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 26 Oct 2011 15:37:32 +0200 Subject: Add BLOB comparison and null predicate test cases to query test --- common/query/test.hxx | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'common/query/test.hxx') diff --git a/common/query/test.hxx b/common/query/test.hxx index 74f5f73..db09f32 100644 --- a/common/query/test.hxx +++ b/common/query/test.hxx @@ -7,12 +7,17 @@ #define TEST_HXX #include +#include #include #include #include +#include + #include // DATABASE_XXX +typedef odb::nullable > nullable_vector; + #pragma db object struct person { @@ -20,12 +25,14 @@ struct person const std::string& fn, const std::string& ln, unsigned short age, - bool married) + bool married, + const nullable_vector& public_key = nullable_vector ()) : id_ (id), first_name_ (fn), last_name_ (ln), age_ (age), - married_ (married) + married_ (married), + public_key_ (public_key) { } @@ -38,11 +45,8 @@ struct person #pragma db column ("first") std::string first_name_; -#ifndef DATABASE_ORACLE - #pragma db column ("middle") type ("TEXT") null -#else - #pragma db column ("middle") type ("CLOB") null -#endif + + #pragma db column ("middle") null std::auto_ptr middle_name_; #pragma db column ("last") @@ -50,6 +54,13 @@ struct person unsigned short age_; bool married_; + +#ifdef DATABASE_PGSQL + #pragma db column ("key") type ("BYTEA") null +#else + #pragma db column ("key") type ("BLOB") null +#endif + nullable_vector public_key_; }; inline std::ostream& @@ -63,6 +74,16 @@ operator<< (std::ostream& os, const person& p) os << ' ' << p.last_name_ << ' ' << p.age_ << (p.married_ ? " married" : " single"); + if (p.public_key_ && p.public_key_->size () > 0) + { + os << ' '; + + for (std::size_t i (0), e (p.public_key_->size () - 1); i < e; ++i) + os << (unsigned int)(*p.public_key_)[i] << '-'; + + os << (unsigned int)p.public_key_->back (); + } + return os; } -- cgit v1.1