Skip to content

Commit cd3f7eb

Browse files
committed
Bug#94324: FIX RANGE FOR DOES NOT WORK FOR LIST_INITIALIZER<>
1 parent 106411f commit cd3f7eb

File tree

3 files changed

+83
-9
lines changed

3 files changed

+83
-9
lines changed

devapi/tests/bugs-t.cc

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,84 @@ TEST_F(Bugs, modify_clone)
297297
//Should not crash
298298
Result mod = cModify.execute();
299299
}
300+
301+
TEST_F(Bugs, list_initializer)
302+
{
303+
SKIP_IF_NO_XPLUGIN;
304+
305+
auto sch = get_sess().getSchema("test", true);
306+
307+
auto coll = sch.createCollection("c1");
308+
coll.remove("true").execute();
309+
310+
for(auto collection : sch.getCollectionNames())
311+
{
312+
std::cout << collection << std::endl;
313+
}
314+
315+
for(auto collections : sch.getCollections())
316+
{
317+
std::cout << collections.getName() << std::endl;
318+
}
319+
320+
for(auto tables : sch.getTables())
321+
{
322+
std::cout << tables.getName() << std::endl;
323+
}
324+
325+
Result add_res = coll.add(
326+
"{ \"_id\": \"myuuid-1\", \"name\": \"foo\", \"age\": 7 }",
327+
"{ \"name\": \"buz\", \"age\": 17 }",
328+
"{ \"name\": \"bar\", \"age\": 3 }"
329+
).execute();
330+
331+
int count = 0;
332+
for(const string& id : add_res.getGeneratedIds())
333+
{
334+
std::cout << id << std::endl;
335+
++count;
336+
}
337+
EXPECT_EQ(2, count);
338+
339+
for(auto w : add_res.getWarnings())
340+
{
341+
std::cout << w.getCode() << ": " << w.getMessage() << std::endl;
342+
}
343+
344+
count = 0;
345+
for(const std::string& id : add_res.getGeneratedIds())
346+
{
347+
std::cout << id << std::endl;
348+
++count;
349+
}
350+
EXPECT_EQ(2, count);
351+
352+
count = 0;
353+
for(auto id : add_res.getGeneratedIds())
354+
{
355+
std::cout << id << std::endl;
356+
++count;
357+
}
358+
EXPECT_EQ(2, count);
359+
360+
DocResult fin_res = coll.find().execute();
361+
362+
for(auto doc : fin_res)
363+
{
364+
std::cout << doc << std::endl;
365+
}
366+
367+
auto tbl = sch.getCollectionAsTable("c1");
368+
369+
auto tbl_res = tbl.select("_id").execute();
370+
for (Row r : tbl_res)
371+
{
372+
std::cout << r.get(0).get<string>() << std::endl;
373+
}
374+
375+
RowResult sql_res = get_sess().sql("select _id from test.c1").execute();
376+
for(Row r : sql_res)
377+
{
378+
std::cout << r.get(0).get<string>() << std::endl;
379+
}
380+
}

include/mysqlx/devapi/common.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,6 @@ class List_initializer
471471

472472
public:
473473

474-
typedef typename std::remove_reference<Source>::type::iterator iterator;
475474

476475
/*
477476
Arguments given to the constructor are passed to the internal
@@ -492,9 +491,6 @@ class List_initializer
492491

493492
template <
494493
typename U
495-
, typename std::is_constructible<
496-
U, const iterator&, const iterator&
497-
>::type* = nullptr
498494
, typename std::enable_if<
499495
!std::is_same< U, std::initializer_list<typename U::value_type> >::value
500496
>::type* = nullptr
@@ -507,22 +503,21 @@ class List_initializer
507503
CATCH_AND_WRAP
508504
}
509505

510-
iterator begin()
506+
auto begin() -> decltype(std::begin(m_src))
511507
{
512508
try {
513509
return std::begin(m_src);
514510
}
515511
CATCH_AND_WRAP
516512
}
517513

518-
iterator end() const
514+
auto end() const -> decltype(std::end(m_src))
519515
{
520516
try {
521517
return std::end(m_src);
522518
}
523519
CATCH_AND_WRAP
524520
}
525-
526521
};
527522

528523

include/mysqlx/devapi/result.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,6 @@ class RowResult
586586
CATCH_AND_WRAP
587587
}
588588

589-
using iterator = RowList::iterator;
590-
591589
/**
592590
Return all remaining rows
593591

0 commit comments

Comments
 (0)