Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Feedback for ORM in development
Forum Updated to NodeBB v4.3 + New Features

Feedback for ORM in development

Scheduled Pinned Locked Moved Brainstorm
4 Posts 2 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Edin-ME Offline
    Edin-ME Offline
    Edin-M
    wrote on last edited by Edin-M
    #1

    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.

    kshegunovK 1 Reply Last reply
    0
    • Edin-ME Edin-M

      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.

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @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.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • Edin-ME Offline
        Edin-ME Offline
        Edin-M
        wrote on last edited by
        #3

        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.

        kshegunovK 1 Reply Last reply
        0
        • Edin-ME Edin-M

          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.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @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.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved