Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterate-like interface but for select with columns #815

Open
allspark opened this issue Oct 21, 2021 · 1 comment
Open

iterate-like interface but for select with columns #815

allspark opened this issue Oct 21, 2021 · 1 comment
Labels

Comments

@allspark
Copy link

allspark commented Oct 21, 2021

Hi,

from the join example

auto rows = storage2.select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate),
                            left_join<Visit>(on(c(&Doctor::id) == &Visit::doctorId)));  
for(auto &row : rows) {
    cout << std::get<0>(row) << '\t' << std::get<1>(row) << '\t' << std::get<2>(row) << '\t' << std::get<3>(row) << endl;
}
cout << endl;

rows is a std::vector<std::tuple<Columns...>>. it would be nice if the same query would be possible with iterate to get a view over std::tuple<Columns...> instead.

@fnc12 fnc12 added the feature label Oct 22, 2021
@fnc12
Copy link
Owner

fnc12 commented Oct 22, 2021

Hi. It is a very nice feature. I have been thinking about it several days ago. I think that API will look like that:

auto statement = storage.prepare(select(columns(&Doctor::id, &Doctor::name, &Visit::patientName, &Visit::vdate),
                            left_join<Visit>(on(c(&Doctor::id) == &Visit::doctorId))));
for(auto &row: storage.iterate(statement)) {  // decltype(row) is the std::tuple<...>
  //..
}

and one can use any type of statement. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants