Skip to content

Commit

Permalink
Release 0.13.1
Browse files Browse the repository at this point in the history
  • Loading branch information
photino committed Sep 20, 2023
1 parent 70bda82 commit c667ab7
Show file tree
Hide file tree
Showing 22 changed files with 124 additions and 102 deletions.
8 changes: 4 additions & 4 deletions examples/actix-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.12.0"
version = "0.12.1"
features = ["actix", "export-pdf"]

[dependencies.zino-core]
path = "../../zino-core"
version = "0.13.0"
version = "0.13.1"
features = [
"connector",
"connector-arrow",
Expand All @@ -33,8 +33,8 @@ features = [

[dependencies.zino-derive]
path = "../../zino-derive"
version = "0.10.0"
version = "0.10.1"

[dependencies.zino-model]
path = "../../zino-model"
version = "0.10.0"
version = "0.10.1"
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 @@ -15,10 +15,12 @@ host = "127.0.0.1"
port = 6080

[[standby]]
name = "portal"
host = "127.0.0.1"
port = 6081

[[standby]]
name = "admin"
host = "127.0.0.1"
port = 6082

Expand Down
2 changes: 2 additions & 0 deletions examples/actix-app/config/config.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ host = "127.0.0.1"
port = 6080

[[standby]]
name = "portal"
host = "127.0.0.1"
port = 6081

[[standby]]
name = "admin"
host = "127.0.0.1"
port = 6082

Expand Down
4 changes: 1 addition & 3 deletions examples/actix-app/src/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ pub fn routes() -> Vec<RouterConfigure> {
}

pub fn debug_routes() -> Vec<RouterConfigure> {
vec![
stats_router as RouterConfigure,
]
vec![stats_router as RouterConfigure]
}

fn auth_router(cfg: &mut ServiceConfig) {
Expand Down
8 changes: 4 additions & 4 deletions examples/axum-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.12.0"
version = "0.12.1"
features = ["axum", "export-pdf"]

[dependencies.zino-core]
path = "../../zino-core"
version = "0.13.0"
version = "0.13.1"
features = [
"connector",
"connector-arrow",
Expand All @@ -33,8 +33,8 @@ features = [

[dependencies.zino-derive]
path = "../../zino-derive"
version = "0.10.0"
version = "0.10.1"

[dependencies.zino-model]
path = "../../zino-model"
version = "0.10.0"
version = "0.10.1"
2 changes: 2 additions & 0 deletions examples/axum-app/config/config.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ host = "127.0.0.1"
port = 6080

[[standby]]
name = "portal"
host = "127.0.0.1"
port = 6081

[[standby]]
name = "admin"
host = "127.0.0.1"
port = 6082

Expand Down
2 changes: 2 additions & 0 deletions examples/axum-app/config/config.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ host = "127.0.0.1"
port = 6080

[[standby]]
name = "portal"
host = "127.0.0.1"
port = 6081

[[standby]]
name = "admin"
host = "127.0.0.1"
port = 6082

Expand Down
6 changes: 3 additions & 3 deletions examples/dioxus-desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ features = ["derive"]

[dependencies.zino]
path = "../../zino"
version = "0.12.0"
version = "0.12.1"
features = ["dioxus"]

[dependencies.zino-core]
path = "../../zino-core"
version = "0.13.0"
version = "0.13.1"
features = ["orm-sqlite"]

[dependencies.zino-model]
path = "../../zino-model"
version = "0.10.0"
version = "0.10.1"
1 change: 1 addition & 0 deletions examples/dioxus-desktop/src/service/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions zino-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zino-core"
description = "Core types and traits for zino."
version = "0.13.0"
version = "0.13.1"
rust-version = "1.72"
edition = "2021"
license = "MIT"
Expand Down Expand Up @@ -157,7 +157,7 @@ version = "0.11.1"
optional = true

[dependencies.minijinja]
version = "1.0.7"
version = "1.0.8"
optional = true
features = ["debug", "loader"]

Expand Down
12 changes: 3 additions & 9 deletions zino-core/src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pub trait Application {
/// Registers default routes.
fn register(self, routes: Self::Routes) -> Self;

/// Registers routes with a custom server name.
fn register_with(self, server_name: &'static str, routes: Self::Routes) -> Self;

/// Runs the application.
fn run(self, async_jobs: Vec<(&'static str, AsyncCronJob)>);

Expand Down Expand Up @@ -90,15 +93,6 @@ pub trait Application {
self.register_with("debug", routes)
}

/// Registers routes with a custom server type.
#[inline]
fn register_with(self, _server_type: &'static str, _routes: Self::Routes) -> Self
where
Self: Sized,
{
self
}

/// Gets the system’s information.
#[inline]
fn sysinfo() -> Map {
Expand Down
30 changes: 16 additions & 14 deletions zino-core/src/database/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,20 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
format!(r#"({field} = '') IS NOT FALSE"#)
} else if value == "notnull" {
format!(r#"({field} = '') IS FALSE"#)
} else if self.index_type() == Some("text") {
if value.contains(',') {
value
.split(',')
.map(|s| {
let value = Query::escape_string(s);
format!(r#"{field} RLIKE {value}"#)
})
.collect::<Vec<_>>()
.join(" OR ")
} else {
let value = Query::escape_string(format!("{value}"));
format!(r#"{field} RLIKE {value}"#)
}
} else if value.contains(',') {
let value = value
.split(',')
Expand All @@ -265,20 +279,8 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
.join(",");
format!(r#"{field} IN ({value})"#)
} else {
let index = value.find(|ch| !"!~*".contains(ch)).unwrap_or(0);
if index > 0 {
let (operator, value) = value.split_at(index);
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
} else {
let operator = if self.index_type() == Some("text") {
"RLIKE"
} else {
"="
};
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
}
let value = Query::escape_string(value);
format!(r#"{field} = {value}"#)
}
} else {
let value = self.encode_value(Some(value));
Expand Down
21 changes: 15 additions & 6 deletions zino-core/src/database/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,20 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
format!(r#"({field} = '') IS NOT FALSE"#)
} else if value == "notnull" {
format!(r#"({field} = '') IS FALSE"#)
} else if self.index_type() == Some("text") {
if value.contains(',') {
value
.split(',')
.map(|s| {
let value = Query::escape_string(s);
format!(r#"{field} ~* {value}"#)
})
.collect::<Vec<_>>()
.join(" OR ")
} else {
let value = Query::escape_string(value);
format!(r#"{field} ~* {value}"#)
}
} else if value.contains(',') {
let value = value
.split(',')
Expand All @@ -284,13 +298,8 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
} else {
let operator = if self.index_type() == Some("text") {
"~*"
} else {
"="
};
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
format!(r#"{field} = {value}"#)
}
}
} else {
Expand Down
30 changes: 16 additions & 14 deletions zino-core/src/database/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
format!(r#"({field} = '') IS NOT FALSE"#)
} else if value == "notnull" {
format!(r#"({field} = '') IS FALSE"#)
} else if self.index_type() == Some("text") {
if value.contains(',') {
value
.split(',')
.map(|s| {
let value = Query::escape_string(format!("%{s}%"));
format!(r#"{field} LIKE {value}"#)
})
.collect::<Vec<_>>()
.join(" OR ")
} else {
let value = Query::escape_string(format!("%{value}%"));
format!(r#"{field} LIKE {value}"#)
}
} else if value.contains(',') {
let value = value
.split(',')
Expand All @@ -249,20 +263,8 @@ impl<'c> EncodeColumn<DatabaseDriver> for Column<'c> {
.join(",");
format!(r#"{field} IN ({value})"#)
} else {
let index = value.find(|ch| !"!~*".contains(ch)).unwrap_or(0);
if index > 0 {
let (operator, value) = value.split_at(index);
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
} else {
let operator = if self.index_type() == Some("text") {
"RLIKE"
} else {
"="
};
let value = Query::escape_string(value);
format!(r#"{field} {operator} {value}"#)
}
let value = Query::escape_string(value);
format!(r#"{field} = {value}"#)
}
} else {
let value = self.encode_value(Some(value));
Expand Down
2 changes: 1 addition & 1 deletion zino-core/src/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl<S: ResponseCode> Response<S> {
pub fn get_header(&self, name: &str) -> Option<&str> {
self.headers
.iter()
.find_map(|(key, value)| (key == &name).then_some(value.as_str()))
.find_map(|(key, value)| (key == name).then_some(value.as_str()))
}

/// Returns the status code as `u16`.
Expand Down
32 changes: 18 additions & 14 deletions zino-core/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<T> State<T> {
let config = self.config();
let mut listeners = Vec::new();

// Optional debug server
// Debug server
if let Some(debug_server) = config.get_table("debug") {
let debug_host = debug_server
.get_str("host")
Expand All @@ -113,26 +113,25 @@ impl<T> State<T> {
}

// Main server
let (main_host, main_port) = if let Some(main_server) = config.get_table("main") {
let host = main_server
if let Some(main_server) = config.get_table("main") {
let main_host = main_server
.get_str("host")
.and_then(|s| s.parse::<IpAddr>().ok())
.unwrap_or(Ipv4Addr::UNSPECIFIED.into());
let port = main_server.get_u16("port").unwrap_or(6080);
(host, port)
} else {
(Ipv4Addr::UNSPECIFIED.into(), 6080)
};
listeners.push(("main".into(), (main_host, main_port).into()));
.expect("the `main.host` field should be a str");
let main_port = main_server
.get_u16("port")
.expect("the `main.port` field should be an integer");
listeners.push(("main".into(), (main_host, main_port).into()));
}

// Optional standbys
// Standbys
if config.contains_key("standby") {
let standbys = config
.get_array("standby")
.expect("the `standby` field should be an array of tables");
for standby in standbys.iter().filter_map(|v| v.as_table()) {
let server_type = standby
.get_str("type")
let server_name = standby
.get_str("name")
.map(|s| s.to_owned().into())
.unwrap_or("standby".into());
let standby_host = standby
Expand All @@ -142,10 +141,15 @@ impl<T> State<T> {
let standby_port = standby
.get_u16("port")
.expect("the `standby.port` field should be an integer");
listeners.push((server_type, (standby_host, standby_port).into()));
listeners.push((server_name, (standby_host, standby_port).into()));
}
}

// Ensure that there is at least one listener
if listeners.is_empty() {
listeners.push(("main".into(), (Ipv4Addr::LOCALHOST, 6080).into()));
}

listeners
}
}
Expand Down
6 changes: 3 additions & 3 deletions zino-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zino-derive"
description = "Derived traits for zino."
version = "0.10.0"
version = "0.10.1"
rust-version = "1.72"
edition = "2021"
license = "MIT"
Expand All @@ -17,9 +17,9 @@ proc-macro = true
convert_case = "0.6.0"
proc-macro2 = "1.0.66"
quote = "1.0.33"
syn = "2.0.35"
syn = "2.0.37"

[dependencies.zino-core]
path = "../zino-core"
version = "0.13.0"
version = "0.13.1"
features = ["orm"]
Loading

0 comments on commit c667ab7

Please sign in to comment.