@@ -37,6 +37,7 @@ class Ints : public oatpp::DTO {
37
37
38
38
#include OATPP_CODEGEN_END(DTO)
39
39
40
+ #include OATPP_CODEGEN_BEGIN(DTO)
40
41
#include OATPP_CODEGEN_BEGIN(DbClient)
41
42
42
43
class MyClient : public oatpp ::orm::DbClient {
@@ -62,10 +63,27 @@ class MyClient : public oatpp::orm::DbClient {
62
63
QUERY(insertStrs,
63
64
" INSERT INTO test_strs "
64
65
" (f_str1, f_str2, f_str3) VALUES "
65
- " (:f_str1, :f_str2, :f_str3);" ,
66
- PARAM (oatpp::String, f_str1),
67
- PARAM(oatpp::String, f_str2),
68
- PARAM(oatpp::String, f_str3))
66
+ " (:f_str1.param, :f_str2.param, :f_str3.param);" ,
67
+ PARAM (oatpp::String, f_str1, " f_str1.param" ),
68
+ PARAM(oatpp::String, f_str2, " f_str2.param" ),
69
+ PARAM(oatpp::String, f_str3, " f_str3.param" ))
70
+
71
+
72
+ class InsertStrsDto : public oatpp::DTO {
73
+
74
+ DTO_INIT (InsertStrsDto, DTO)
75
+
76
+ DTO_FIELD (oatpp::String, f_str1);
77
+ DTO_FIELD (oatpp::String, f_str2);
78
+ DTO_FIELD (oatpp::String, f_str3);
79
+
80
+ };
81
+
82
+ QUERY (insertStrsWithDtoParams,
83
+ " INSERT INTO test_strs "
84
+ " (f_str1, f_str2, f_str3) VALUES "
85
+ " (:dto.f_str1, :dto.f_str2, :dto.f_str3);" ,
86
+ PARAMS_DTO (oatpp::Object<InsertStrsDto>, rowDto, " dto" ))
69
87
70
88
QUERY(selectStrs, " SELECT * FROM test_strs" )
71
89
@@ -91,6 +109,7 @@ class MyClient : public oatpp::orm::DbClient {
91
109
};
92
110
93
111
#include OATPP_CODEGEN_END(DbClient)
112
+ #include OATPP_CODEGEN_END(DTO)
94
113
95
114
class Test : public oatpp ::test::UnitTest {
96
115
public:
@@ -119,10 +138,18 @@ class Test : public oatpp::test::UnitTest {
119
138
// client.insertFloats(0.32, 0.64, connection);
120
139
// client.insertFloats(-0.32, -0.64, connection);
121
140
122
- // client.insertStrs("Hello", "World ", "Oat++ ");
141
+ // client.insertStrs("Hello", "Dot ", "Param ");
123
142
// client.insertStrs("Hello", "World", "oatpp");
124
143
// client.insertStrs("Yeah", "Ops", "!!!");
125
144
145
+ {
146
+ auto row = MyClient::InsertStrsDto::createShared ();
147
+ row->f_str1 = " A" ;
148
+ row->f_str2 = " B" ;
149
+ row->f_str3 = " C" ;
150
+ client.insertStrsWithDtoParams (row);
151
+ }
152
+
126
153
{
127
154
128
155
auto res = client.selectStrs ();
0 commit comments