Boost logo

Boost :

Subject: [boost] [rdb] 0.11
From: Jean-Louis Leroy (jl_at_[hidden])
Date: 2009-10-03 19:00:01


In this drop :

* Everything related to SQL composition has been moved to namespace
boost::rdb::odbc

* Update syntax has changed, instead of .set().set() chains it is now
closer to SQL syntax (an deasier to implement):

    update(p).set(p.id = 1, p.first_name = "Homer")

* Qualified table names:

    person::qualified p;
    partner::qualified l;
    select(p.id).from(p, l).where(p.id == l.wife)

gives:

    select person.id from person, partner where person.id = partner.wife

* in predicate:

    select(p.id).from(p, l).where(p.id.in(select(l.husband).from(l)))
    select(p.id).from(p).where(p.id.in(p.age + 1, 2))

* NULL:

    insert_into(p)(p.id, p.age).values(1, null)
    update(p).set(p.age = null).where(p.id == 1)

    select(p.id).from(p).where(p.age == null)

Whoa! This gives:

    select id from person where age is null

I'm only 80% sure about this one. Like everybody I suppose I have tried
one day to compare with NULL, only to realize that the result is always
false. After a while, ahem...So I have implemented operator == to do the
right thing. It could have been:

    select(p.id).from(p).where(p.age.is_null())

Does anyone has an example where it makes sense to truly compare (using
=) with NULL ?

As for returning the NULL indicator when reading results, I chose not to
use Boost.Optional (although I will probably add support for optional as
well) because:
1. it would cost one bool (most likely the size of an integer) per column
2. IMHO the automatic conversion to bool is a bad idea
3. the value inside an optional<> cannot be addressed

Instead I have complemented a fusion::vector with a std::bitset.

The tutorial shows how to use this. I am hesitating a bit about pushing
fusion::vector inside the implementation (i.e. nullable<int, char...>
instead of nullable< fusion::vector<int, char> >).

* Result sets: execute(Select) now returns a ResultSet object that
allows retrieval row by row: also see the tutorial here :
http://yorel.be/boost/libs/rdb/doc/html/rdb/tutorial.html#retrieve_data

There is also a "Jumbo select" at the bottom of the tutorial that recaps
everything that is supported for the moment.

J-L


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk