Comments (11)
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.
If I don't see an exact example code I can't tell where the problem can be.
from tinyorm.
#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.
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.
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.
For me it compiles on msvc, can you post the rest of your code?
from tinyorm.
What OS, compiler and version do you use? Also try to #include <optional>
.
from tinyorm.
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.
Paste a whole file here I try to compile it on my side.
from tinyorm.
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.
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)
- Assertive TinyOrmConfig.cmake breaks static builds HOT 9
- Insufficiently escaped comment in tinytypes.hpp HOT 2
- VCPKG misplaces debug target export file HOT 2
- Support for Mac OS X, *BSD, and other libc++ environment HOT 3
- VCPKG upstream integration HOT 23
- VCPKG installs header files redundandly HOT 1
- [cmake] Installing mdx documentation HOT 8
- Tag the releases HOT 4
- GitHub Actions ubuntu compilation failure HOT 1
- redefinition of ‘bool __tls_guard’ in orm/tiny/concerns/hasattributes.hpp:412 HOT 1
- Add interface wrapper for CREATE IF NOT EXISTS HOT 2
- Classify Logs HOT 1
- DB::beginTransaction assert()-ing HOT 1
- Column and Table alias assigning HOT 4
- Many-to-many and wrong detach() overload? HOT 5
- Linker error when building with MinGW 11.2 HOT 11
- how are you?do you need any support? HOT 1
- Let TomApplication accept a parent/delegator migration class HOT 6
- Timestamps get formated wrong HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyorm.