diff --git a/doc/qbk/08_prepared_statements.qbk b/doc/qbk/08_prepared_statements.qbk index 6fdadd112..a376e8f3d 100644 --- a/doc/qbk/08_prepared_statements.qbk +++ b/doc/qbk/08_prepared_statements.qbk @@ -162,7 +162,10 @@ is interpreted by MySQL, depeding on `v`'s type. [`DATETIME`, `TIMESTAMP`] ] [ - [[reflink time]] + [ + [reflink time][br] + Any `std::chrono::duration` convertible to `time` + ] [`TIME`] [`TIME`] ] diff --git a/test/unit/test/detail/writable_field_traits.cpp b/test/unit/test/detail/writable_field_traits.cpp index 5ba2472ee..547e2b580 100644 --- a/test/unit/test/detail/writable_field_traits.cpp +++ b/test/unit/test/detail/writable_field_traits.cpp @@ -98,6 +98,14 @@ static_assert(!is_writable_field::value, ""); static_assert(!is_writable_field::value, ""); static_assert(!is_writable_field::value, ""); +// durations accepted as long as they can be converted to time +static_assert(is_writable_field::value, ""); +static_assert(is_writable_field::value, ""); +static_assert(is_writable_field::value, ""); +static_assert(is_writable_field::value, ""); +static_assert(is_writable_field::value, ""); +static_assert(!is_writable_field::value, ""); + // characters (except signed/unsigned char) not accepted static_assert(!is_writable_field::value, ""); static_assert(!is_writable_field::value, ""); diff --git a/test/unit/test/format_sql/individual_value.cpp b/test/unit/test/format_sql/individual_value.cpp index d1bc8aaf8..33c20cb23 100644 --- a/test/unit/test/format_sql/individual_value.cpp +++ b/test/unit/test/format_sql/individual_value.cpp @@ -393,6 +393,18 @@ BOOST_AUTO_TEST_CASE(individual_time) BOOST_TEST(format_sql(single_fmt, opts, (mysql_time::max)()) == "SELECT '2562047788:00:54.775807';"); } +BOOST_AUTO_TEST_CASE(individual_duration) +{ + // Durations work as long as they're compatible with time + using namespace std::chrono; + + BOOST_TEST(format_sql(single_fmt, opts, hours(21)) == "SELECT '21:00:00.000000';"); + BOOST_TEST(format_sql(single_fmt, opts, minutes(3)) == "SELECT '00:03:00.000000';"); + BOOST_TEST(format_sql(single_fmt, opts, seconds(-10)) == "SELECT '-00:00:10.000000';"); + BOOST_TEST(format_sql(single_fmt, opts, milliseconds(-9)) == "SELECT '-00:00:00.009000';"); + BOOST_TEST(format_sql(single_fmt, opts, microseconds(3214)) == "SELECT '00:00:00.003214';"); +} + BOOST_AUTO_TEST_CASE(individual_field_view) { field referenced("def\\");