File tree Expand file tree Collapse file tree 4 files changed +52
-6
lines changed Expand file tree Collapse file tree 4 files changed +52
-6
lines changed Original file line number Diff line number Diff line change @@ -749,6 +749,12 @@ class SndViewCrud
749
749
return m_has_opts ? this : NULL ;
750
750
}
751
751
752
+ const protocol::mysqlx::api::Args_map*
753
+ get_args ()
754
+ {
755
+ return m_find->m_param_conv .get ();
756
+ }
757
+
752
758
753
759
Proto_op* start ()
754
760
{
@@ -758,11 +764,12 @@ class SndViewCrud
758
764
case REPLACE:
759
765
return &m_protocol.snd_CreateView (DM, *this , *m_find,
760
766
get_cols (), REPLACE == m_type,
761
- get_opts ());
767
+ get_opts (), get_args () );
762
768
763
769
case UPDATE:
764
770
return &m_protocol.snd_ModifyView (DM, *this , *m_find,
765
- get_cols (), get_opts ());
771
+ get_cols (), get_opts (),
772
+ m_find->m_param_conv .get ());
766
773
default :
767
774
assert (false );
768
775
return NULL ; // quiet compile warnings
Original file line number Diff line number Diff line change @@ -623,9 +623,14 @@ class Op_base
623
623
624
624
// Parameters
625
625
626
- void add_param (const mysqlx::string &name, Value val)
626
+ void add_param (const mysqlx::string &name, Value && val)
627
627
{
628
- m_map.emplace (name, std::move (val));
628
+ auto el = m_map.emplace (name, std::move (val));
629
+ // substitute if exists
630
+ if (!el.second )
631
+ {
632
+ el.first ->second = std::move (val);
633
+ }
629
634
}
630
635
631
636
void clear_params ()
Original file line number Diff line number Diff line change @@ -589,6 +589,40 @@ TEST_F(Sess, view)
589
589
590
590
}
591
591
592
+ std::cout << " Create view with select bind" << std::endl;
593
+
594
+ {
595
+ TableSelect sel = tbl.select ();
596
+ sel.where (" age = :age" ).bind (" age" , 40 );
597
+
598
+ sch.dropView (view_name).execute ();
599
+
600
+ sch.createView (view_name).definedAs (sel).execute ();
601
+
602
+ Table view = sch.getTable (view_name);
603
+
604
+ RowResult res = view.select ().execute ();
605
+
606
+ EXPECT_EQ (1 , res.count ());
607
+
608
+ Row row = res.fetchOne ();
609
+
610
+ EXPECT_EQ (40 , row.get (1 ).get <int >());
611
+
612
+ sel.bind (" age" , 30 );
613
+
614
+ sch.alterView (view_name).definedAs (sel).execute ();
615
+
616
+ res = view.select ().execute ();
617
+
618
+ EXPECT_EQ (1 , res.count ());
619
+
620
+ row = res.fetchOne ();
621
+
622
+ EXPECT_EQ (30 , row.get (1 ).get <int >());
623
+
624
+ }
625
+
592
626
std::cout << " Drop view" << std::endl;
593
627
594
628
sch.dropView (view_name).execute ();
Original file line number Diff line number Diff line change @@ -136,7 +136,7 @@ namespace internal {
136
136
137
137
struct Statement_impl : public Executable_impl
138
138
{
139
- virtual void add_param (const string&, Value) = 0;
139
+ virtual void add_param (const string&, Value&& ) = 0;
140
140
};
141
141
142
142
} // internal
@@ -190,7 +190,7 @@ class Statement
190
190
Statement& bind (const string ¶meter, Value val)
191
191
{
192
192
try {
193
- get_impl ()->add_param (parameter, val);
193
+ get_impl ()->add_param (parameter, std::move ( val) );
194
194
return *this ;
195
195
}
196
196
CATCH_AND_WRAP
You can’t perform that action at this time.
0 commit comments