Feedback for ORM in development



  • Hi, I'm in process of developing active-record like ORM for a Qt. I've done proof of concept for myself, and would very much like a feedback. Currently it works for long/int and QString/text types and Postgres only with parent/child and belongs to relationships.

    Qdbup
    Example of models

    I'm not trying to reinvent the wheel, but I haven't found open source alternative that could satisfy minimum requirements (easy to use, gets out of the way, can be used commercially).

    Before continuing, my idea is to collect feedback and possible requirements for the future directions.


  • Qt Champions 2016

    @Edin-M

    I'm not trying to reinvent the wheel, but I haven't found open source alternative that could satisfy minimum requirements (easy to use, gets out of the way, can be used commercially).

    http://forum.qt.io/topic/67417/advanced-powerful-and-easy-to-use-orm-for-qt5

    What about this? I haven't checked it in details, but it seems to be based on the same idea?

    Before continuing, my idea is to collect feedback and possible requirements for the future directions.

    If I were implementing such a thing I wouldn't do it like this. For one I'd use the class name as table name and property names as table column names (the necessary reflection capabilities can be used by imposing Q_GADGET and Q_PROPERTY macros). After having this in place I'd simply put down an "adapter" of sorts which will push/pull the objects from a standard instance of QSqlDatabase.

    Primary keys and relations can be pulled out of the db (most databases provide meta information readily for PKs and foreign keys).

    Kind regards.



  • I haven't seen this library before, but it's not old. I guess I started working on mine before this one came out.

    Yes, its possible to use class name as table name but there would still need to be DB_TABLE macro, just without arguments.

    As for column names, acctually I use properties, so columns are same as property name so DB_COLUMN(QString, name) creates set_name() and get_name() methods, and name column in a db. set_ and get_ (example) aren't camelCase as rest of Qt but reasoning behind this is (a) recognizable as db bound objects (b) I did't want to clutter DB_COLUMN macro but potentially there could be macro like DB_COLUMN_EX that specifies names for getters and setters like nut library above.

    One thing I'm unable is to retrieve list of all QObjects in a system, or of a specific class so a user of a lib shouldn't manually register classes.

    I did not know about Q_GADGET. Very helpful! Thanks.


  • Qt Champions 2016

    @Edin-M

    but there would still need to be DB_TABLE macro, just without arguments.

    Why, what exactly is that macro supposed to do?

    As for column names, acctually I use properties, so columns are same as property name so DB_COLUMN(QString, name) creates set_name() and get_name() methods

    Look up Q_PROPERTY.

    One thing I'm unable is to retrieve list of all QObjects in a system

    And why should you? There's no central repository for objects ...
    Besides QObjects are not for that, they can't be copied, you should just use regular objects. And my point was that you don't need to have any macros besides Q_GADGET (which will allow to query for the class name with some tweaking) and Q_PROPERTY (which will give you dynamic properties). The relations can be retrieved from the db.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.