Menu

#4 Please add cppdb::result::fetch(bool& value)

open
nobody
None
5
2015-04-25
2011-05-20
Anonymous
No

Please add a cppdb::result::fetch(bool& value) function.

I guess that bool is a common type in all databases.

We can fetch a bool as an int but in some situations it is annoying.

Thanks for great framework.

Discussion

  • Marcel Hellwig

    Marcel Hellwig - 2011-12-26

    Naa,
    i my case, every useable database has not this type.
    Neither MySQL(MyISAM and InnoDB) nor SQLite has this type. It is a int (like in cpp) either 0 for false or 1 for true. Just cast that into a cpp boolean should work.

    bool a = 1;
    std::cout << !(a || false) << std::endl;

    works great :)

     
  • Sergey Lavrov

    Sergey Lavrov - 2013-02-12

    Marcel, I forget to mention that your syntax not working with syntactic sugar like:

    bool b;
    cppdb::result result = sql << "SELECT true::bool;" << cppdb::row;
    result >> b;

     
  • CN Liou

    CN Liou - 2015-04-25

    +1 for bool type!

    The attached incomplete patch file for PostgreSQL appears to be working for myself.

     

Anonymous
Anonymous