Skip to content

Commit

Permalink
Remove the default limit in Query::new
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Sep 24, 2023
1 parent 329da23 commit 461af38
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions examples/actix-app/config/config.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,6 @@ span = { "http.method" = "string", "http.target" = "string", "http.status_code"
app-name = "data-cube"

[openapi]
show-docs = true
rapidoc-route = "/rapidoc"
custom-html = "local/docs/rapidoc.html"
5 changes: 5 additions & 0 deletions examples/axum-app/config/config.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ name = "admin"
host = "127.0.0.1"
port = 6082

[server]
page-dir = "public"

[database]
namespace = "dc"
max-rows = 10000
Expand Down Expand Up @@ -83,4 +86,6 @@ span = { "http.method" = "string", "http.target" = "string", "http.status_code"
app-name = "data-cube"

[openapi]
show-docs = true
rapidoc-route = "/rapidoc"
custom-html = "local/docs/rapidoc.html"
3 changes: 3 additions & 0 deletions examples/axum-app/config/config.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ name = "admin"
host = "127.0.0.1"
port = 6082

[server]
page-dir = "public"

[database]
type = "mysql"
namespace = "dc"
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/database/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ pub(super) trait QueryExt<DB> {
/// Formats the query pagination to generate SQL `LIMIT` expression.
fn format_pagination(&self) -> String {
let limit = self.query_limit();
if limit == usize::MAX {
if limit == 0 || limit == usize::MAX {
return String::new();
}

Expand Down
6 changes: 3 additions & 3 deletions zino-core/src/database/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ pub trait Schema: 'static + Send + Sync + ModelHooks {
Ok(rows_affected)
}

/// Finds models selected by the query in the table,
/// Finds a list of models selected by the query in the table,
/// and decodes it as `Vec<T>`.
async fn find<T: DecodeRow<DatabaseRow, Error = Error>>(
query: &Query,
Expand Down Expand Up @@ -655,7 +655,7 @@ pub trait Schema: 'static + Send + Sync + ModelHooks {
Ok(data)
}

/// Finds models selected by the query in the table,
/// Finds a list of models selected by the query in the table,
/// and parses it as `Vec<T>`.
async fn find_as<T: DeserializeOwned>(query: &Query) -> Result<Vec<T>, Error> {
let mut data = Self::find::<Map>(query).await?;
Expand Down Expand Up @@ -920,7 +920,7 @@ pub trait Schema: 'static + Send + Sync + ModelHooks {
Ok(())
}

/// Performs a left outer join to another table to filter rows in the "joined" table,
/// Performs a left outer join to another table to filter rows in the joined table,
/// and decodes it as `Vec<T>`.
async fn lookup<M: Schema, T: DecodeRow<DatabaseRow, Error = Error>>(
query: &Query,
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/model/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl Query {
filters: filters.into().into_map_opt().unwrap_or_default(),
sort_order: Vec::new(),
offset: 0,
limit: 10,
limit: 0,
}
}

Expand Down

0 comments on commit 461af38

Please sign in to comment.