File tree Expand file tree Collapse file tree 6 files changed +65
-2
lines changed Expand file tree Collapse file tree 6 files changed +65
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ set(LazyORM_HEADERS
16
16
include /FilterVariant.h
17
17
include /AbstractLazy.h
18
18
include /FilteringAbstractLazy.h
19
+ include /LazyOrm.h
19
20
20
21
include /MariadbLazy.h
21
22
include /MariadbFilteringLazy.h
@@ -27,6 +28,7 @@ set(LazyORM_HEADERS
27
28
include /PostgreFilteringLazy.h
28
29
29
30
include /Transaction.h
31
+
30
32
)
31
33
32
34
add_library (LazyOrm STATIC
@@ -36,6 +38,7 @@ add_library(LazyOrm STATIC
36
38
src/DbList.cpp
37
39
src/WhereFilter.cpp
38
40
src/FilterVariant.cpp
41
+ src/LazyOrm.cpp
39
42
40
43
src/AbstractLazy.cpp
41
44
src/FilteringAbstractLazy.cpp
Original file line number Diff line number Diff line change
1
+ #ifndef LAZYORM_H
2
+ #define LAZYORM_H
3
+
4
+ #include " MariadbLazy.h"
5
+ #include " PostgreLazy.h"
6
+ #include " SqliteLazy.h"
7
+
8
+
9
+
10
+ namespace LazyOrm {
11
+
12
+ class LazyOrm : public MariadbLazy , public PostgreLazy , public SqliteLazy
13
+ {
14
+ public:
15
+ enum DBMS_TYPE
16
+ {
17
+ MariaDB =1 ,
18
+ Postgre,
19
+ Sqlite
20
+ };
21
+
22
+ LazyOrm ();
23
+
24
+ std::string queryString (const DBMS_TYPE &dbms);
25
+ };
26
+
27
+ }
28
+
29
+
30
+ #endif // LAZYORM_H
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ class PostgreLazy : public AbstractLazy
10
10
{
11
11
private:
12
12
PostgreFilteringLazy mFilter ;
13
+ std::string primaryKey=" id" ;
13
14
14
15
protected:
15
16
std::string insert_query () const override ;
@@ -33,6 +34,8 @@ class PostgreLazy : public AbstractLazy
33
34
34
35
void setFilter (const PostgreFilteringLazy filter);
35
36
37
+ void setPrimaryKey (const std::string &primaryKey);
38
+
36
39
};
37
40
}
38
41
#endif // POSTGRELAZY_H
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ FilteringAbstractLazy& AbstractLazy::operator[](const LazyOrm::Filters &filter)
135
135
136
136
WhereFilter& AbstractLazy::operator [](const LazyOrm::NestedWhere &nestedWhere)
137
137
{
138
- return mWhereFilter ;// getCurrentFilters()[nestedWhere];
138
+ return mWhereFilter ;
139
139
}
140
140
141
141
// void AbstractLazy::operator=(const LazyOrm::FilterVariant &variant)
Original file line number Diff line number Diff line change
1
+ #include " LazyOrm.h"
2
+
3
+ namespace LazyOrm {
4
+
5
+ LazyOrm::LazyOrm ()
6
+ {
7
+
8
+ }
9
+
10
+ std::string LazyOrm::queryString (const DBMS_TYPE &dbms)
11
+ {
12
+ switch (dbms) {
13
+ case MariaDB:
14
+ return static_cast <MariadbLazy*>(this )->queryString ();
15
+ case Postgre:
16
+ return static_cast <PostgreLazy*>(this )->queryString ();
17
+ case Sqlite:
18
+ return static_cast <SqliteLazy*>(this )->queryString ();
19
+ }
20
+ }
21
+
22
+ }
Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ PostgreLazy::PostgreLazy()
8
8
9
9
}
10
10
11
+ void PostgreLazy::setPrimaryKey (const std::string &primaryKey)
12
+ {
13
+ this ->primaryKey = primaryKey;
14
+ }
15
+
11
16
PostgreLazy::PostgreLazy (const std::string &table, const Query &queryType)
12
17
{
13
18
setTabeName (table);
@@ -35,7 +40,7 @@ std::string PostgreLazy::insert_query() const
35
40
queryString.append (" (" +string_join (" ," ,keys)+" ) " );
36
41
queryString.append (" VALUES" );
37
42
queryString.append (" (" +string_join (" ," ,values)+" ) " );
38
- // TODO: RETURNING id; i dont now id name
43
+ queryString. append ( " returning " +primaryKey);
39
44
queryString.append (" ;" );
40
45
return queryString;
41
46
}
You can’t perform that action at this time.
0 commit comments