Skip to content

Commit 134c9b9

Browse files
committed
fix: ci
1 parent e793ede commit 134c9b9

File tree

6 files changed

+32
-36
lines changed

6 files changed

+32
-36
lines changed

crates/pg_completions/src/context.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl TryFrom<&str> for ClauseType {
2929
panic!("{}", message);
3030
}
3131

32-
return Err(message);
32+
Err(message)
3333
}
3434
}
3535
}
@@ -215,7 +215,7 @@ mod tests {
215215

216216
let params = crate::CompletionParams {
217217
position: (position as u32).into(),
218-
text: text,
218+
text,
219219
tree: Some(&tree),
220220
schema: &pg_schema_cache::SchemaCache::new(),
221221
};
@@ -247,7 +247,7 @@ mod tests {
247247
let tree = get_tree(text.as_str());
248248
let params = crate::CompletionParams {
249249
position: (position as u32).into(),
250-
text: text,
250+
text,
251251
tree: Some(&tree),
252252
schema: &pg_schema_cache::SchemaCache::new(),
253253
};
@@ -281,7 +281,7 @@ mod tests {
281281
let tree = get_tree(text.as_str());
282282
let params = crate::CompletionParams {
283283
position: (position as u32).into(),
284-
text: text,
284+
text,
285285
tree: Some(&tree),
286286
schema: &pg_schema_cache::SchemaCache::new(),
287287
};
@@ -306,14 +306,14 @@ mod tests {
306306

307307
let params = crate::CompletionParams {
308308
position: (position as u32).into(),
309-
text: text,
309+
text,
310310
tree: Some(&tree),
311311
schema: &pg_schema_cache::SchemaCache::new(),
312312
};
313313

314314
let ctx = CompletionContext::new(&params);
315315

316-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
316+
let node = ctx.ts_node.unwrap();
317317

318318
assert_eq!(ctx.get_ts_node_content(node), Some("select"));
319319

@@ -334,14 +334,14 @@ mod tests {
334334

335335
let params = crate::CompletionParams {
336336
position: (position as u32).into(),
337-
text: text,
337+
text,
338338
tree: Some(&tree),
339339
schema: &pg_schema_cache::SchemaCache::new(),
340340
};
341341

342342
let ctx = CompletionContext::new(&params);
343343

344-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
344+
let node = ctx.ts_node.unwrap();
345345

346346
assert_eq!(ctx.get_ts_node_content(node), Some("from"));
347347
assert_eq!(
@@ -360,14 +360,14 @@ mod tests {
360360

361361
let params = crate::CompletionParams {
362362
position: (position as u32).into(),
363-
text: text,
363+
text,
364364
tree: Some(&tree),
365365
schema: &pg_schema_cache::SchemaCache::new(),
366366
};
367367

368368
let ctx = CompletionContext::new(&params);
369369

370-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
370+
let node = ctx.ts_node.unwrap();
371371

372372
assert_eq!(ctx.get_ts_node_content(node), Some(""));
373373
assert_eq!(ctx.wrapping_clause_type, None);
@@ -385,14 +385,14 @@ mod tests {
385385

386386
let params = crate::CompletionParams {
387387
position: (position as u32).into(),
388-
text: text,
388+
text,
389389
tree: Some(&tree),
390390
schema: &pg_schema_cache::SchemaCache::new(),
391391
};
392392

393393
let ctx = CompletionContext::new(&params);
394394

395-
let node = ctx.ts_node.map(|n| n.clone()).unwrap();
395+
let node = ctx.ts_node.unwrap();
396396

397397
assert_eq!(ctx.get_ts_node_content(node), Some("fro"));
398398
assert_eq!(ctx.wrapping_clause_type, Some(ClauseType::Select));

crates/pg_completions/src/test_helper.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ pub(crate) async fn get_test_deps(
3434
pub(crate) fn get_text_and_position(sql: &str) -> (usize, String) {
3535
// the cursor is to the left of the `CURSOR_POS`
3636
let position = sql
37-
.find(|c| c == CURSOR_POS)
38-
.expect("Please insert the CURSOR_POS into your query.")
39-
.checked_sub(1)
40-
.unwrap_or(0);
37+
.find(CURSOR_POS)
38+
.expect("Please insert the CURSOR_POS into your query.").saturating_sub(1);
4139

4240
let text = sql.replace(CURSOR_POS, "");
4341

crates/pg_lsp/src/db_connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl DbConnection {
4040
res = listener.recv() => {
4141
match res {
4242
Ok(not) => {
43-
if not.payload().to_string() == "reload schema" {
43+
if not.payload() == "reload schema" {
4444
let schema_cache = SchemaCache::load(&cloned_pool).await.unwrap();
4545
ide.write().await.set_schema_cache(schema_cache);
4646
};

crates/pg_lsp/src/session.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,7 @@ impl Session {
248248
tree: ide
249249
.tree_sitter
250250
.tree(&stmt)
251-
.as_ref()
252-
.and_then(|t| Some(t.as_ref())),
251+
.as_ref().map(|t| t.as_ref()),
253252
schema: &schema_cache,
254253
})
255254
.into_iter()

crates/pg_schema_cache/src/columns.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,27 @@ mod tests {
148148
user_id_col.default_expr,
149149
Some("nextval('users_id_seq'::regclass)".into())
150150
);
151-
assert_eq!(user_id_col.is_nullable, false);
152-
assert_eq!(user_id_col.is_primary_key, true);
153-
assert_eq!(user_id_col.is_unique, true);
151+
assert!(!user_id_col.is_nullable);
152+
assert!(user_id_col.is_primary_key);
153+
assert!(user_id_col.is_unique);
154154
assert_eq!(user_id_col.varchar_length, None);
155155

156156
let user_name_col = cache.find_col("name", "users", None).unwrap();
157157
assert_eq!(user_name_col.class_kind, ColumnClassKind::OrdinaryTable);
158158
assert_eq!(user_name_col.comment, None);
159159
assert_eq!(user_name_col.default_expr, None);
160-
assert_eq!(user_name_col.is_nullable, false);
161-
assert_eq!(user_name_col.is_primary_key, false);
162-
assert_eq!(user_name_col.is_unique, false);
160+
assert!(!user_name_col.is_nullable);
161+
assert!(!user_name_col.is_primary_key);
162+
assert!(!user_name_col.is_unique);
163163
assert_eq!(user_name_col.varchar_length, Some(255));
164164

165165
let user_is_veg_col = cache.find_col("is_vegetarian", "users", None).unwrap();
166166
assert_eq!(user_is_veg_col.class_kind, ColumnClassKind::OrdinaryTable);
167167
assert_eq!(user_is_veg_col.comment, None);
168168
assert_eq!(user_is_veg_col.default_expr, Some("false".into()));
169-
assert_eq!(user_is_veg_col.is_nullable, true);
170-
assert_eq!(user_is_veg_col.is_primary_key, false);
171-
assert_eq!(user_is_veg_col.is_unique, false);
169+
assert!(user_is_veg_col.is_nullable);
170+
assert!(!user_is_veg_col.is_primary_key);
171+
assert!(!user_is_veg_col.is_unique);
172172
assert_eq!(user_is_veg_col.varchar_length, None);
173173

174174
let user_middle_name_col = cache.find_col("middle_name", "users", None).unwrap();
@@ -178,9 +178,9 @@ mod tests {
178178
);
179179
assert_eq!(user_middle_name_col.comment, None);
180180
assert_eq!(user_middle_name_col.default_expr, None);
181-
assert_eq!(user_middle_name_col.is_nullable, true);
182-
assert_eq!(user_middle_name_col.is_primary_key, false);
183-
assert_eq!(user_middle_name_col.is_unique, false);
181+
assert!(user_middle_name_col.is_nullable);
182+
assert!(!user_middle_name_col.is_primary_key);
183+
assert!(!user_middle_name_col.is_unique);
184184
assert_eq!(user_middle_name_col.varchar_length, Some(255));
185185

186186
let properties_owner_id_col = cache
@@ -194,9 +194,9 @@ mod tests {
194194
properties_owner_id_col.comment,
195195
Some("users might own many houses".into())
196196
);
197-
assert_eq!(properties_owner_id_col.is_nullable, true);
198-
assert_eq!(properties_owner_id_col.is_primary_key, false);
199-
assert_eq!(properties_owner_id_col.is_unique, false);
197+
assert!(properties_owner_id_col.is_nullable);
198+
assert!(!properties_owner_id_col.is_primary_key);
199+
assert!(!properties_owner_id_col.is_unique);
200200
assert_eq!(properties_owner_id_col.varchar_length, None);
201201
}
202202
}

crates/pg_workspace_new/src/workspace/server/pg_query.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use std::sync::Arc;
22

33
use dashmap::DashMap;
4-
use pg_diagnostics::{serde::Diagnostic as SDiagnostic, Diagnostic, MessageAndDescription};
4+
use pg_diagnostics::serde::Diagnostic as SDiagnostic;
55
use pg_query_ext::diagnostics::*;
6-
use text_size::TextRange;
76

87
use super::{
98
change::ChangedStatement,

0 commit comments

Comments
 (0)