[odb-users] Reuse inheritance and id column names
Артём Бодрин
abodrin at gmail.com
Sat May 21 07:10:36 EDT 2016
Greetings, developers 8-)
I've encountered a problem with subject, when tried to reflect odb-ready
classes onto existing database tables. Consider a small test:
reflection.h with contents:
#pragma once
#include <QUuid>
class CommonBase {
public:
QUuid id;
QUuid class_id;
};
#ifdef ODB_COMPILER
#pragma db object( CommonBase ) abstract
#endif
class Object : public CommonBase {
public:
quint32 num1;
};
#ifdef ODB_COMPILER
#pragma db object( Object ) table( "object" )
#pragma db member( Object::id ) column( "id" ) id
#pragma db member( Object::class_id ) column( "class_id" )
#endif
class Extension : public CommonBase {
public:
quint32 num2;
};
#ifdef ODB_COMPILER
#pragma db object( Extension ) table( "extension" )
#pragma db member( Extension::id ) column( "object_id" ) id
#pragma db member( Extension::class_id ) column( "object_class_id" )
#endif
processed by odb compiler:
/opt/odb-2.4.0/bin/odb -I/opt/Qt5.3.0/5.3/gcc_64/include/QtCore
-I/opt/Qt5.3.0/5.3/gcc_64/include/ -d pgsql --generate-query
--generate-schema --profile qt reflection.h
and produced a following sql file with schema:
/* This file was generated by ODB, object-relational mapping (ORM)
* compiler for C++.
*/
DROP TABLE IF EXISTS "extension" CASCADE;
DROP TABLE IF EXISTS "object" CASCADE;
CREATE TABLE "object" (
"object_id" UUID NOT NULL PRIMARY KEY,
"object_class_id" UUID NULL,
"num1" INTEGER NOT NULL);
CREATE TABLE "extension" (
"object_id" UUID NOT NULL PRIMARY KEY,
"object_class_id" UUID NULL,
"num2" INTEGER NOT NULL);
everything seems fine and simple, except column names for table "objects".
I've expected "id" an "class_id" respectively as defined by pragmas...
Is this an odb-compiler bug, or i must do something else to meet my needs?
Thanks in advance, Artem.
More information about the odb-users
mailing list