8000 Pager supporting QueryValues and consistency by Jasperav · Pull Request #337 · AlexPikalov/cdrs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

Pager supporting QueryValues and consistency #337

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

Jasperav
Copy link
Collaborator
@Jasperav Jasperav commented Jun 5, 2020

@AlexPikalov can you help me on the TODO comment in the test? It fails for a vec when using an in parameter, but I can not figure it out why. This solves #336.

@Jasperav Jasperav changed the title Qv only Pager supporting QueryValues Jun 5, 2020
}
}

pub fn query<Q>(&'a mut self, query: Q) -> QueryPager<'a, Q, SessionPager<'a, M, S, T>>
pub fn query<Q>(&'a mut self, query: Q, qv: Option<QueryValues>) -> QueryPager<'a, Q, SessionPager<'a, M, S, T>>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be a breaking change in the API which will require a new major version release. Can you please add a new method (query_with_values or any other descriptive name) with a proposed signature and keep query in a previous shape?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read in this comment you are thinking about a new major release: #344 (comment). Is it still needed to remain backwards compatible? I think the new parameters should always be explicitly filled.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I made a new commit which adds a consistency level parameter and updated the 'Any' consistency documentation, since the documentation was wrong

@Jasperav Jasperav changed the title Pager supporting QueryValues Pager supporting QueryValues and consistency Jul 1, 2020
fn paged_with_values_list(session: &CurrentSession) {
let q = "SELECT * FROM test_ks.my_test_table where key in (?)";
let mut pager = session.paged(2);
let mut query_pager = pager.query(q, Some(query_values!(vec![100, 101, 102, 103, 104, 105])));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please try query values without vec!, just like query_values!(100, 101, ...)
I think it may solve the error you mentioned in a TODO comment

}
}

pub fn query<Q>(&'a mut self, query: Q) -> QueryPager<'a, Q, SessionPager<'a, M, S, T>>
pub fn query<Q>(&'a mut self, query: Q, qv: Option<QueryValues>, consistency: Consistency) -> QueryPager<'a, Q, SessionPager<'a, M, S, T>>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can try to come up with some another method which would allow us to provide all values which make sense from https://github.com/AlexPikalov/cdrs/blob/master/src/query/query_params_builder.rs#L6 (perhaps every except the ones related to the paging itself)

Still I'd like to have query with as a minimalistic API

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, in the newest commit this is done

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexPikalov could you have another look? Thanks!

@Jasperav Jasperav mentioned this pull request Aug 14, 2020
@Jasperav
Copy link
Collaborator Author
Jasperav commented Sep 4, 2020

@AlexPikalov Please review so I can publish https://github.com/Jasperav/cdrs_orm

}
}

pub fn query<Q>(&'a mut self, query: Q) -> QueryPager<'a, Q, SessionPager<'a, M, S, T>>
where
Q: ToString,
{
self.query_with_pager_state(query, PagerState::new())
self.query_with_param(query,QueryParamsBuilder::new()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's not "cargo fmt"-ed.

@@ -43,6 +44,7 @@ impl<
&'a mut self,
query: Q,
state: PagerState,
qp: QueryParams,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems it's going to be a breaking change which seems to be unnecessary.
Can you please introduce a new Pager method like query_with_pager_state_params. I know it_looks_a_bit_too_long but will help to keep it back compatible

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good idea

}

fn paged_with_values_list(session: &CurrentSession) {
let q = "SELECT * FROM test_ks.my_test_table where key in ?";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed the test! :)

@krojew
Copy link
krojew commented Dec 15, 2020

FYI: This PR has been merged to https://github.com/krojew/cdrs-tokio

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

Successfully merging this pull request may close these issues.

4 participants
0