[odb-users] ODB 1.6.0.a2 available

Boris Kolpackov boris at codesynthesis.com
Thu Sep 22 08:02:35 EDT 2011


Hi,

The second alpha version for the upcoming ODB 1.6.0 is now available.
The major new feature in this release compared to the earlier 1.6.0.a1
is support for views.

View is a light-weight, read-only projection of one or more persistent
objects, ad-hoc database tables, or some combination of the two. For
example:

#pragma db view object(employee) object(employer)
struct employee_info
{
  std::string first_name;
  std::string last_name;

  #pragma db column(employer::name)
  std::string employer_name;
};

typedef odb::query<employee_info> query;
typedef odb::result<employee_info> result;

result r = db.query<employee_info> (
  query::employee::last_name == "Doe" &&
  query::employer::name == "Simple Tech, Inc");

We are still working on the documentation and examples for this feature,
but seeing that a lot of people asked for it, we have decided to make a
pre-release as soon as possible. In the meantime the test.hxx file in
the common/view test in the odb-tests package gives a good overview of
what's possible.

Other NEWS file entries so far are:

  * New function, database::erase_query(), allows the deletion of the
    database state of multiple objects matching certain criteria. It uses
    the same query expression as the database::query() function. For more
    information, refer to Section 3.10, "Deleting Persistent Objects" in
    the ODB manual.

  * Support for value wrappers. An ODB value wrapper is a class template
    that wraps a value type or a container. Common examples of wrappers
    are smart pointers, holders, and "optional value" containers such as
    boost::optional. A wrapper can be transparent or it can handle the
    NULL semantics. To allow the easy conversion of value types that do
    not support the NULL semantics into the ones that do, the odb::nullable
    class template has been added. ODB also now includes built-in support for
    std::auto_ptr and std::tr1::shared_ptr smart pointers as value wrappers
    as well as for boost::shared_ptr and QSharedPointer via the Boost and Qt
    profiles. Currently, the NULL semantics is only supported for simple
    values but smart pointers can still be used with composite values and
    containers. For more information, refer to Section 7.3, "NULL Value
    Semantics" in the ODB manual.

  * Support for the boost::optional container in the Boost profile. A data
    member of the boost::optional type is mapped to a column that can have
    a NULL value. For more information, refer to Section 15.3 "Optional
    Library" in the ODB manual.

  * Support for mapping std::vector<char> to the BLOB (or equivalent) types.
    For more information, refer to chapters 11 (for MySQL), 12 (for SQLite)
    and 13 (for PostgreSQL) in the ODB manual.

  * New option, --table-prefix, allows the specification of a prefix that
    is added to table and index names. For more information, refer to the
    ODB compiler command line interface documentation (man pages).

  * New ODB runtime interface, odb::connection, represents a connection
    to the database. The primary use case for a connection is to execute
    native statements outside of a transaction. For more information, refer
    to Section 3.5, "Connections" in the ODB manual.

  * Support for multiplexing several transaction on the same thread. For
    more information, refer to Section 3.4, "Transactions" in the ODB
    manual.

  * All the concrete connection classes now have a second constructor which
    allows the creation of a connection instance from an already established
    underlying connection handle. The connection_pool_factory and, in case of
    SQLite, single_connection_factory now have a virtual create() function
    that can be overridden to implement custom connection establishment and
    configuration.

  * The query expression syntax for object pointers and composite values has
    changed. Now, instead of using the scope resolution operator ('::') the
    member access via pointer operator (->) is used for object pointers and
    the member access operator (.) is used for composite values. Examples of
    old and new syntax for pointers, old: query<employee>::employer::name
    and new: query<employee>::employer->name. For composites values, old:
    query<employee>::name::first and new: query<employee>::name.first.

  * SQLite ODB runtime now enables foreign key constraints checking by
    default. While this should not affect correct applications, due to
    bugs in SQLite DDL foreign keys support, you may need to temporarily
    disable foreign key constraints checking when re-creating the database
    schema (the sign that you may need to do so is the "foreign key
    constraint failed" exception thrown by the commit() function after the
    call to schema_catalog::create_schema()). For more information, refer
    to Section 12.5.3, "Foreign Key Constraints" in the ODB manual.

  * Support for specifying the client character set for the MySQL database.
    For more information, refer to Section 11.2, "MySQL Database Class" in
    the ODB manual.

  * Object cache maintained by a session nor longer distinguishes between
    const and non-const objects. Instead, const objects are treated as
    non-const by casting away constness. For more information on this new
    behavior, refer to Section 9.1, "Object Cache" in the ODB manual.

This pre-release (as well as all the future pre-releases) is available
from:

http://www.codesynthesis.com/download/odb/pre-release/

The ODB compiler binaries are only available for Windows and GNU/Linux
(x86 and x86_64).

Testing and feedback are appreciated.

Enjoys,
	Boris



More information about the odb-users mailing list