diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-30 22:51:50 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-06-30 22:51:50 +0100 | 
| commit | b711e23dc10c222f3e141d8a733b360559f338b6 (patch) | |
| tree | 6565a7442cec8ad7e60e76df0a8b93101bd16fb4 | |
| parent | Add default conversions and throw if conversion solution can't be found (diff) | |
| download | slicer-b711e23dc10c222f3e141d8a733b360559f338b6.tar.bz2 slicer-b711e23dc10c222f3e141d8a733b360559f338b6.tar.xz slicer-b711e23dc10c222f3e141d8a733b360559f338b6.zip | |
Fix case of type level metadata not being picked up if the type is a classslicer-1.3.1.1
| -rw-r--r-- | slicer/db/testInsert.cpp | 7 | ||||
| -rw-r--r-- | slicer/db/testSelect.cpp | 8 | ||||
| -rw-r--r-- | slicer/slicer/parser.cpp | 3 | ||||
| -rw-r--r-- | slicer/test/conversions.cpp | 8 | ||||
| -rw-r--r-- | slicer/test/types.ice | 2 | 
5 files changed, 17 insertions, 11 deletions
| diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index 2068de3..e2118b8 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -144,14 +144,17 @@ BOOST_AUTO_TEST_CASE( insert_converted )  	DB::SpecificTypesPtr st = new DB::SpecificTypes {  		{2015, 10, 16, 19, 12, 34},  		{2015, 10, 16}, -		{1, 2, 3, 4} +		new DB::Timespan(1, 2, 3, 4)  	};  	Slicer::SerializeAny<Slicer::SqlInsertSerializer>(st, db.get(), "converted");  	auto sel = SelectPtr(db->newSelectCommand("SELECT * FROM converted"));  	auto st2 = Slicer::DeserializeAny<Slicer::SqlSelectDeserializer, DB::SpecificTypesPtr>(*sel);  	BOOST_REQUIRE_EQUAL(st->date, st2->date);  	BOOST_REQUIRE_EQUAL(st->dt, st2->dt); -	BOOST_REQUIRE_EQUAL(st->ts, st2->ts); +	BOOST_REQUIRE_EQUAL(st->ts->days, st2->ts->days); +	BOOST_REQUIRE_EQUAL(st->ts->hours, st2->ts->hours); +	BOOST_REQUIRE_EQUAL(st->ts->minutes, st2->ts->minutes); +	BOOST_REQUIRE_EQUAL(st->ts->seconds, st2->ts->seconds);  }  BOOST_AUTO_TEST_CASE( insert_unsupportedModel ) diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index afea1d3..b5664a1 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -141,10 +141,10 @@ BOOST_AUTO_TEST_CASE( select_inherit_datetime )  	BOOST_REQUIRE_EQUAL(2015, bi->date.year);  	BOOST_REQUIRE_EQUAL(3, bi->date.month);  	BOOST_REQUIRE_EQUAL(27, bi->date.day); -	BOOST_REQUIRE_EQUAL(1, bi->ts.days); -	BOOST_REQUIRE_EQUAL(13, bi->ts.hours); -	BOOST_REQUIRE_EQUAL(13, bi->ts.minutes); -	BOOST_REQUIRE_EQUAL(12, bi->ts.seconds); +	BOOST_REQUIRE_EQUAL(1, bi->ts->days); +	BOOST_REQUIRE_EQUAL(13, bi->ts->hours); +	BOOST_REQUIRE_EQUAL(13, bi->ts->minutes); +	BOOST_REQUIRE_EQUAL(12, bi->ts->seconds);  }  template <typename T, typename ... P> diff --git a/slicer/slicer/parser.cpp b/slicer/slicer/parser.cpp index 1159fee..7e795be 100644 --- a/slicer/slicer/parser.cpp +++ b/slicer/slicer/parser.cpp @@ -548,6 +548,9 @@ namespace Slicer {  		auto conversions = getConversions(dm->getMetaData());  		auto typec = Slice::ContainedPtr::dynamicCast(dm->type());  		if (typec) { +			if (auto cd = Slice::ClassDeclPtr::dynamicCast(typec)) { +				typec = cd->definition(); +			}  			auto typeConversions = getConversions(typec->getMetaData());  			std::copy(typeConversions.begin(), typeConversions.end(), std::back_inserter(conversions));  		} diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index 5f7e699..aaad378 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -89,17 +89,17 @@ namespace Slicer {  	}  	DLL_PUBLIC -	::DB::Timespan +	::DB::TimespanPtr  	timedurationToTimespan(const boost::posix_time::time_duration & td)  	{ -		return ::DB::Timespan({ SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds()) }); +		return new ::DB::Timespan(SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds()));  	}  	DLL_PUBLIC  	boost::posix_time::time_duration -	timespanToTimeduration(const ::DB::Timespan & ts) +	timespanToTimeduration(const ::DB::TimespanPtr & ts)  	{ -		return boost::posix_time::time_duration((ts.days * 24) + ts.hours, ts.minutes, ts.seconds); +		return boost::posix_time::time_duration((ts->days * 24) + ts->hours, ts->minutes, ts->seconds);  	}  } diff --git a/slicer/test/types.ice b/slicer/test/types.ice index 97df71b..b119df0 100644 --- a/slicer/test/types.ice +++ b/slicer/test/types.ice @@ -152,7 +152,7 @@ module TestModule2 {  module DB {  	[	"slicer:conversion:boost.posix_time.time_duration:timedurationToTimespan:timespanToTimeduration" ] -	struct Timespan { +	class Timespan {  		int days;  		short hours;  		short minutes; | 
