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

feat: add support for multiple inequalities #86

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions crates/emulator-database/src/database/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,37 +354,13 @@ impl Query {
}));
}

// Validate order_by versus inequality field
match filter.get_inequality_fields().unique().at_most_one() {
Err(mut fields) => {
return Err(GenericDatabaseError::invalid_argument(format!(
"Cannot have inequality filters on multiple properties: [{}]",
fields.join(", ")
)));
}
Ok(Some(inequality_field)) => {
if let Some(first_order_by) = self.order_by.first() {
if first_order_by.field != *inequality_field {
return Err(GenericDatabaseError::invalid_argument(format!(
"inequality filter property and first sort order must be the \
same: {inequality_field} and {}",
first_order_by.field
)));
}
}
}
Ok(None) => (),
}
filter
.field_filters()
.filter(|f| f.op.is_array_contains())
.at_most_one()
.map_err(|_| {
// TODO: Error message from cloud read: "A maximum of 1 'ARRAY_CONTAINS' filter
// is allowed per disjunction." Should change message after
// we add support for disjunctions.
GenericDatabaseError::invalid_argument(
"Only a single array-contains clause is allowed in a query",
"A maximum of 1 'ARRAY_CONTAINS' filter is allowed per disjunction.",
)
})?;
}
Expand Down
14 changes: 9 additions & 5 deletions crates/hybrid-axum-tonic/src/nest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ pub trait NestTonic: Sized {
Request<hyper::Body>,
Error = Infallible,
Response = hyper::Response<tonic::body::BoxBody>,
Future: Send + 'static + Unpin,
>
+ Clone
+ Send
+ 'static
+ NamedService,
S::Future: Send + 'static + Unpin;
+ NamedService;
}

impl NestTonic for Router {
Expand All @@ -29,12 +29,12 @@ impl NestTonic for Router {
Request<hyper::Body>,
Error = Infallible,
Response = hyper::Response<tonic::body::BoxBody>,
Future: Send + 'static + Unpin,
>
+ Clone
+ Send
+ 'static
+ NamedService,
S::Future: Send + 'static + Unpin,
{
// Nest it at /S::NAME, and wrap the service in an AxumTonicService
self.route(
Expand All @@ -56,8 +56,12 @@ struct AxumTonicService<S> {

impl<B, S> Service<Request<B>> for AxumTonicService<S>
where
S: Service<Request<B>, Error = Infallible, Response = hyper::Response<tonic::body::BoxBody>>,
S::Future: Unpin,
S: Service<
Request<B>,
Error = Infallible,
Response = hyper::Response<tonic::body::BoxBody>,
Future: Unpin,
>,
{
type Response = axum::response::Response;
type Error = Infallible;
Expand Down
2 changes: 1 addition & 1 deletion crates/hybrid-axum-tonic/tests/common/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use crate::common::proto::{test1_server::*, test2_server::*, *};

pub struct Test1Service {
pub state: Mutex<u32>,
pub str: String,
}

#[async_trait]
impl Test1 for Test1Service {
async fn test1(
Expand Down
1 change: 0 additions & 1 deletion crates/hybrid-axum-tonic/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async fn test_hybrid() {
let grpc_router1 = Router::new()
.nest_tonic(Test1Server::new(Test1Service {
state: Mutex::new(10),
str: String::new(),
}))
.layer(from_fn(do_nothing));

Expand Down
Loading