[odb-users] Bug in qt/basic/pgsql/quuid-traits.hxx

Артём Бодрин abodrin at gmail.com
Tue Jan 19 13:50:54 EST 2016


Hello, developers 8-)
I guess there is a bug in qt/basic/pgsql/quuid-traits.hxx:45:

std::memcpy( i, &v.data1, 16 );

as a result i contains bytes in a host byteorder (littleendian, x86-64), so
this piece of code

QUuid description_id = QUuid( "02797688-2916-4cfb-ad2a-8379c9fb523a" );
result res( m_db->query< protobuf_descriptions >( "id = " + query::_val<
odb::pgsql::id_uuid >( description_id ) ) );

results to SQL statement on the backend (PostgreSQL log lines):

SELECT ""id"", ""class_id"", ""protobuf_description"" FROM
""objects"".""protobuf_descriptions"" WHERE id = $1","parameters: $1 =
'88767902-1629-fb4c-ad2a-8379c9fb523a'

If we fix data type for source of memcpy (2-nd parameter became const char*
), then it is all ok:

std::memcpy( i, v.toRfc4122().constData(), 16 );

PostgreSQL log lines:
SELECT ""id"", ""class_id"", ""protobuf_description"" FROM
""objects"".""protobuf_descriptions"" WHERE id = $1","параметры: $1 =
'02797688-2916-4cfb-ad2a-8379c9fb523a'

PS:

1) protobuf_descriptions defined as follows:

struct protobuf_descriptions {
   QUuid    id;
   QUuid    class_id;
   QString  protobuf_description;
};
#ifdef ODB_COMPILER
#pragma db  view( protobuf_descriptions ) \
            table ( "objects.protobuf_descriptions" )
#pragma db  member ( protobuf_descriptions::id )     \
            column( "id" ) type( "UUID" )
#pragma db  member ( protobuf_descriptions::class_id )     \
            column( "class_id" ) type( "UUID" )
#pragma db  member ( protobuf_descriptions::protobuf_description ) \
            column( "protobuf_description" ) type( "TEXT" )
#endif


2) odb libraries family version 2.4.0

3) gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

4) odb is awesome! 8-))

Regards, Bodrin Artem.


More information about the odb-users mailing list