Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

chore(rust): simplify boolean expressions for clippy 1.96

t8y24d5faa74066d
diff --git a/crates/dbx-core/src/persistence/cloud_sync.rs b/crates/dbx-core/src/persistence/cloud_sync.rs
index fe15fff516..6140901547 100644
--- a/crates/dbx-core/src/persistence/cloud_sync.rs
+++ b/crates/dbx-core/src/persistence/cloud_sync.rs
@@ -1430,13 +1430,13 @@ pub async fn apply_sync_snapshot_with_selection(
.and_then(serde_json::Value::as_str)
== Some("none"))
});
- !forbidden_rocketmq_auth
- && !(matches!(
- secret.key.as_str(),
- "password" | NACOS_AUTH_PASSWORD_KEY | NACOS_RNACOS_CONSOLE_PASSWORD_KEY
- ) && connections
- .iter()
- .any(|config| config.id == secret.connection_id && !config.save_password))
+ let password_like_secret_unsaved = matches!(
+ secret.key.as_str(),
+ "password" | NACOS_AUTH_PASSWORD_KEY | NACOS_RNACOS_CONSOLE_PASSWORD_KEY
+ ) && connections
+ .iter()
+ .any(|config| config.id == secret.connection_id && !config.save_password);
+ !(forbidden_rocketmq_auth || password_like_secret_unsaved)
})
.map(|secret| SyncImportSecret {
connection_id: secret.connection_id.clone(),
diff --git a/crates/dbx-mcp/src/credentials.rs b/crates/dbx-mcp/src/credentials.rs
index a80229281b..cf0a1e423e 100644
--- a/crates/dbx-mcp/src/credentials.rs
+++ b/crates/dbx-mcp/src/credentials.rs
@@ -131,7 +131,7 @@ fn validate_signature_info(info: &str) -> Result<(), &'static str> {
value.replace("/* exists */", "exists").chars().filter(|c| !c.is_whitespace() && *c != '"').collect()
};
let mut designated = info.lines().filter_map(|line| line.strip_prefix("designated => "));
- if !designated.next().is_some_and(|value| normalize(value) == normalize(RELEASE_REQUIREMENT))
+ if designated.next().is_none_or(|value| normalize(value) != normalize(RELEASE_REQUIREMENT))
|| designated.next().is_some()
{
return Err("a stable Developer ID designated requirement is required");
diff --git a/crates/dbx-sql-core/src/oracle_view_rename.rs b/crates/dbx-sql-core/src/oracle_view_rename.rs
index a254848b7e..60f3cede26 100644
--- a/crates/dbx-sql-core/src/oracle_view_rename.rs
+++ b/crates/dbx-sql-core/src/oracle_view_rename.rs
@@ -367,11 +367,11 @@ fn hint_arguments(tokens: &[TokenWithSpan]) -> Option<Vec<usize>> {
let name = name.value.to_uppercase();
pos += 1;
if matches!(name.as_str(), "ALL_ROWS" | "FIRST_ROWS" | "RULE")
- && !tokens.get(pos).is_some_and(|t| t.token == Token::LParen)
+ && tokens.get(pos).is_none_or(|t| t.token != Token::LParen)
{
continue;
}
- if !tokens.get(pos).is_some_and(|t| t.token == Token::LParen) {
+ if tokens.get(pos).is_none_or(|t| t.token != Token::LParen) {
return None;
}
pos += 1;
@@ -382,7 +382,7 @@ fn hint_arguments(tokens: &[TokenWithSpan]) -> Option<Vec<usize>> {
{
pos += 1;
}
- if pos == start || !tokens.get(pos).is_some_and(|t| t.token == Token::RParen) {
+ if pos == start || tokens.get(pos).is_none_or(|t| t.token != Token::RParen) {
return None;
}
match name.as_str() {
diff --git a/crates/dbx-sql-core/src/sql.rs b/crates/dbx-sql-core/src/sql.rs
index 88fc74dfe5..6857c558ca 100644
--- a/crates/dbx-sql-core/src/sql.rs
+++ b/crates/dbx-sql-core/src/sql.rs
@@ -875,9 +875,9 @@ impl SqlStatementSplitter {
}
match ch {
- '\'' if !self.in_double_quote
- && !self.in_backtick
- && !(self.single_quote_backslash_escapes() && has_odd_trailing_backslashes(&self.buffer)) =>
+ '\'' if !(self.in_double_quote
+ || self.in_backtick
+ || self.single_quote_backslash_escapes() && has_odd_trailing_backslashes(&self.buffer)) =>
{
self.in_single_quote = !self.in_single_quote;
self.single_quote_escape_string = self.in_single_quote
@@ -886,9 +886,9 @@ impl SqlStatementSplitter {
&& ends_with_escape_string_prefix(&self.buffer)));
self.buffer.push(ch);
}
- '"' if !self.in_single_quote
- && !self.in_backtick
- && !(self.options.profile.supports_backslash_escaped_quotes
+ '"' if !(self.in_single_quote
+ || self.in_backtick
+ || self.options.profile.supports_backslash_escaped_quotes
&& has_odd_trailing_backslashes(&self.buffer)) =>
{
self.in_double_quote = !self.in_double_quote;
@@ -1541,9 +1541,9 @@ fn split_sql_statement_ranges_with_options(sql: &str, options: SqlParsingOptions
};
match ch {
- '\'' if !in_double_quote
- && !in_backtick
- && !(single_quote_backslash_escapes && has_odd_trailing_backslashes(&sql[start..i])) =>
+ '\'' if !(in_double_quote
+ || in_backtick
+ || single_quote_backslash_escapes && has_odd_trailing_backslashes(&sql[start..i])) =>
{
in_single_quote = !in_single_quote;
single_quote_escape_string = in_single_quote
@@ -1552,9 +1552,9 @@ fn split_sql_statement_ranges_with_options(sql: &str, options: SqlParsingOptions
&& ends_with_escape_string_prefix(&sql[start..i])));
i += ch.len_utf8();
}
- '"' if !in_single_quote
- && !in_backtick
- && !(options.profile.supports_backslash_escaped_quotes
+ '"' if !(in_single_quote
+ || in_backtick
+ || options.profile.supports_backslash_escaped_quotes
&& has_odd_trailing_backslashes(&sql[start..i])) =>
{
in_double_quote = !in_double_quote;
@@ -2627,9 +2627,9 @@ impl SqlScanner {
self.profile.supports_backslash_escaped_quotes
};
match ch {
- '\'' if !self.in_double_quote
- && !self.in_backtick
- && !(single_quote_backslash_escapes && self.previous == Some('\\')) =>
+ '\'' if !(self.in_double_quote
+ || self.in_backtick
+ || single_quote_backslash_escapes && self.previous == Some('\\')) =>
{
self.in_single_quote = !self.in_single_quote;
self.single_quote_escape_string = self.in_single_quote
@@ -2637,9 +2637,9 @@ impl SqlScanner {
|| (self.profile.supports_postgres_escape_strings
&& ends_with_escape_string_prefix(&sql[..idx])));
}
- '"' if !self.in_single_quote
- && !self.in_backtick
- && !(self.profile.supports_backslash_escaped_quotes && self.previous == Some('\\')) =>
+ '"' if !(self.in_single_quote
+ || self.in_backtick
+ || self.profile.supports_backslash_escaped_quotes && self.previous == Some('\\')) =>
{
self.in_double_quote = !self.in_double_quote;
}
diff --git a/crates/dbx-sql-schema/src/table_structure_sql/alter_dialect.rs b/crates/dbx-sql-schema/src/table_structure_sql/alter_dialect.rs
index 8b4128cd6d..b626272e3a 100644
--- a/crates/dbx-sql-schema/src/table_structure_sql/alter_dialect.rs
+++ b/crates/dbx-sql-schema/src/table_structure_sql/alter_dialect.rs
@@ -379,7 +379,7 @@ fn validate_sort_columns(
let version = super::create_dialect::parse_version(context.server_version.as_deref());
let primary = context.model.as_deref() == Some("primary");
if !matches!(context.model.as_deref(), Some("primary" | "duplicate" | "aggregate" | "unique"))
- || !version.is_some_and(|version| version >= if primary { (3, 0, 0) } else { (3, 3, 0) })
+ || version.is_none_or(|version| version < if primary { (3, 0, 0) } else { (3, 3, 0) })
{
warnings.push("Changing StarRocks sort keys requires confirmed table metadata and version 3.0+ for PRIMARY or 3.3+ for other models.".into());
}
diff --git a/crates/dbx-sql-schema/src/table_structure_sql/column_alter.rs b/crates/dbx-sql-schema/src/table_structure_sql/column_alter.rs
index 6d6909beb9..97d9d49940 100644
--- a/crates/dbx-sql-schema/src/table_structure_sql/column_alter.rs
+++ b/crates/dbx-sql-schema/src/table_structure_sql/column_alter.rs
@@ -221,7 +221,7 @@ fn is_column_extra_empty(extra: &ColumnExtra) -> bool {
!extra.auto_increment.unwrap_or(false)
&& !extra.on_update_current_timestamp.unwrap_or(false)
&& is_column_identity_empty(&extra.identity)
- && !extra.generated.as_ref().is_some_and(|generated| !generated.expression.trim().is_empty())
+ && extra.generated.as_ref().is_none_or(|generated| generated.expression.trim().is_empty())
&& !extra.manticore_indexed.unwrap_or(false)
&& !extra.manticore_stored.unwrap_or(false)
&& !extra.manticore_attribute.unwrap_or(false)
diff --git a/crates/dbx-sql-schema/src/table_structure_sql/oracle_foreign_keys.rs b/crates/dbx-sql-schema/src/table_structure_sql/oracle_foreign_keys.rs
index 0ebe03f3c2..bd054c72e3 100644
--- a/crates/dbx-sql-schema/src/table_structure_sql/oracle_foreign_keys.rs
+++ b/crates/dbx-sql-schema/src/table_structure_sql/oracle_foreign_keys.rs
@@ -122,7 +122,7 @@ fn validate(key: &OracleForeignKeyDefinition, oracle: bool) -> Result<(), &'stat
}
if (!key.state.deferrable && key.state.initially_deferred)
|| (key.state.validated && key.state.rely)
- || (!oracle && (key.state.deferrable || key.state.initially_deferred))
+ || (key.state.deferrable && !oracle)
{
return Err("The foreign key state is invalid or unsupported by this engine.");
}
diff --git a/crates/dbx-sql-schema/src/table_structure_sql/starrocks_layout.rs b/crates/dbx-sql-schema/src/table_structure_sql/starrocks_layout.rs
index d29eab4c9d..ded468a18a 100644
--- a/crates/dbx-sql-schema/src/table_structure_sql/starrocks_layout.rs
+++ b/crates/dbx-sql-schema/src/table_structure_sql/starrocks_layout.rs
@@ -57,7 +57,7 @@ pub(super) fn build(
if context.automatic_bucket_scaling {
warnings.push("This StarRocks table uses automatic bucket scaling (bucket_size > 0); changing distribution or bucket count through ALTER is not supported. Create a new table to change distribution.".into());
}
- if !version.is_some_and(|v| v >= (3, 2, 0)) {
+ if version.is_none_or(|v| v < (3, 2, 0)) {
warnings.push("Changing StarRocks distribution requires confirmed version 3.2 or newer.".into());
}
if !layout.partitions.is_empty() {