From 548f0b10aa3adfc722198bf31f773ba85047f344 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 3 Jul 2013 12:27:59 +0200 Subject: Document sub-second precision support in MySQL --- NEWS | 8 +++++++ doc/manual.xhtml | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/NEWS b/NEWS index 225a38a..720834c 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,14 @@ Version 2.3.0 to the ODB compiler command line interface documentation (man pages) for details. + * Starting with MySQL version 5.6.4 it is possible to store fractional + seconds up to microsecond precision in TIME, DATETIME, and TIMESTAMP + columns. Both Boost and Qt profiles have been updated to support this + new functionality. Note, however, that to enable sub-second precision, + the corresponding type with the desired precision has to be specified + explicitly. For details, refer to the "MySQL Database Type Mapping" + sections in the Boost and Qt profile chapters. + * New SQLite-specific exception, odb::sqlite::forced_rollback, which is thrown if SQLite forces a transaction to roll back. For more information, refer to Section 16.5.6, "Forced Rollback" in the ODB manual. diff --git a/doc/manual.xhtml b/doc/manual.xhtml index c879248..2746a0c 100644 --- a/doc/manual.xhtml +++ b/doc/manual.xhtml @@ -20264,6 +20264,38 @@ class person }; +

Starting with MySQL version 5.6.4 it is possible to store fractional + seconds up to microsecond precision in TIME, + DATETIME, and TIMESTAMP columns. However, + to enable sub-second precision, the corresponding type with the + desired precision has to be specified explicitly, as shown in the + following example:

+ +
+#pragma db object
+class person
+{
+  ...
+  #pragma db type("DATETIME(6)")     // Microsecond precision.
+  boost::posix_time::ptime updated_;
+};
+  
+ +

Alternatively, you can enable sub-second precision on the per-type + basis, for example:

+ +
+#pragma db value(boost::posix_time::ptime) type("DATETIME(6)")
+
+#pragma db object
+class person
+{
+  ...
+  boost::posix_time::ptime created_; // Microsecond precision.
+  boost::posix_time::ptime updated_; // Microsecond precision.
+};
+  
+

Some valid Boost date-time values cannot be stored in a MySQL database. An attempt to persist any Boost date-time special value other than date_time::not_a_date_time will result in the @@ -21414,6 +21446,38 @@ class Person }; +

Starting with MySQL version 5.6.4 it is possible to store fractional + seconds up to microsecond precision in TIME, + DATETIME, and TIMESTAMP columns. However, + to enable sub-second precision, the corresponding type with the + desired precision has to be specified explicitly, as shown in the + following example:

+ +
+#pragma db object
+class Person
+{
+  ...
+  #pragma db type("DATETIME(3)") // Millisecond precision.
+  QDateTime updated_;
+};
+  
+ +

Alternatively, you can enable sub-second precision on the per-type + basis, for example:

+ +
+#pragma db value(QDateTime) type("DATETIME(3)")
+
+#pragma db object
+class Person
+{
+  ...
+  QDateTime created_; // Millisecond precision.
+  QDateTime updated_; // Millisecond precision.
+};
+  
+

Some valid Qt date-time values cannot be stored in a MySQL database. An attempt to persist a Qt date-time value that is out of the MySQL type range will result in the out_of_range exception. Refer to -- cgit v1.1