Giter VIP home page Giter VIP logo

Comments (11)

silverqx avatar silverqx commented on September 25, 2024 1

Ok, if you don't know how to call something you can also inspire from tst_model_relations.cpp, tst_relations_buildsqueries.cpp, tst_relations_inserting_updating.cpp, tst_queriesrelationships.cpp, huge amount of these API-s is unit and functional tested.

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

If I don't see an exact example code I can't tell where the problem can be.

from tinyorm.

Redmanacac avatar Redmanacac commented on September 25, 2024
#pragma once
#ifndef MODELS_USER_HPP
#define MODELS_USER_HPP

#include <QStringList>

#include <orm/tiny/model.hpp>


namespace Models {

using Orm::Tiny::Model;
using Orm::Tiny::Relations::Pivot;

// NOLINTNEXTLINE(misc-no-recursion)
class Role;

class User final : public Model<User, Role, Pivot> {
   friend Model;
   using Model::Model;

 public:
   /*! The roles that belong to the user. */
   std::unique_ptr<BelongsToMany<User, Role>>
   roles() {
      return belongsToMany<Role>();
   }

 private:
   /*! Map of relation names to methods. */
   QHash<QString, RelationVisitor> u_relations{
       {"roles", [](auto& v) { v(&User::roles); }},
   };
};

class Role final : public Model<Role, User, Pivot> {
   friend Model;
   using Model::Model;

 public:
   /*! The users that belong to the role. */
   std::unique_ptr<BelongsToMany<Role, User>>
   users() {
      return belongsToMany<User>();
   }

 private:
   /*! Map of relation names to methods. */
   QHash<QString, RelationVisitor> u_relations{
       {"users", [](auto& v) { v(&Role::users); }},
   };
};
}  // namespace Models

#endif  // MODELS_USER_HPP

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

You are missing the #include:

#include <orm/tiny/relations/pivot.hpp>

This includes like pivot.hpp or basepivot.hpp are not included inside the orm/tiny/model.hpp, they can't be because you maybe don't need them.

from tinyorm.

Redmanacac avatar Redmanacac commented on September 25, 2024

I just added the missing include, and the error persist.

If I do this, it compiles

class User final : public Model<User, Role, Pivot> {
   friend Model;
   using Model::Model;

 public:
   // /*! The roles that belong to the user. */
   // std::unique_ptr<BelongsToMany<User, Role>>
   // roles() {
   //    return belongsToMany<Role>();
   // }

 private:
   // /*! Map of relation names to methods. */
   // QHash<QString, RelationVisitor> u_relations{
   //     {"roles", [](auto& v) { v(&User::roles); }},
   // };
};

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

For me it compiles on msvc, can you post the rest of your code?

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

What OS, compiler and version do you use? Also try to #include <optional>.

from tinyorm.

Redmanacac avatar Redmanacac commented on September 25, 2024

Compiler: Microsoft Visual C++ Compiler 17.7.34024.191 (amd64)

There is no other code to the models except the one I posted.

What else could be of relevance to that?

Edit:
#include <optional> made no difference

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

Paste a whole file here I try to compile it on my side.

from tinyorm.

silverqx avatar silverqx commented on September 25, 2024

What else could be of relevance to that?

I don't know code looks correct, maybe its in build system, pack whole folder with source and build system and I try it to recompile if I find something.

from tinyorm.

Redmanacac avatar Redmanacac commented on September 25, 2024

Ah, well. Mutually including the headers of the other table breaks it. Moved it all into one file and now it compiles.

from tinyorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.