Skip to content

Commit df9719c

Browse files
authored
Made collection finding safer (#766)
1 parent 541a1d5 commit df9719c

File tree

3 files changed

+2
-23
lines changed

3 files changed

+2
-23
lines changed

pgml-sdks/rust/pgml/src/collection.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -751,27 +751,6 @@ impl Collection {
751751
Ok(results)
752752
}
753753

754-
/// Creates a new Collection from a [models::Collection] and a [`PgPool`];
755-
pub fn from_model_and_pool(collection_model: models::Collection, pool: PgPool) -> Self {
756-
let (
757-
documents_table_name,
758-
splitters_table_name,
759-
models_table_name,
760-
transforms_table_name,
761-
chunks_table_name,
762-
) = Self::generate_table_names(&collection_model.name);
763-
Self {
764-
name: collection_model.name,
765-
pool,
766-
documents_table_name,
767-
splitters_table_name,
768-
models_table_name,
769-
transforms_table_name,
770-
chunks_table_name,
771-
active: collection_model.active,
772-
}
773-
}
774-
775754
fn generate_table_names(name: &str) -> (String, String, String, String, String) {
776755
[
777756
".documents",

pgml-sdks/rust/pgml/src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl Database {
8080
.fetch_optional(self.pool.borrow())
8181
.await?;
8282
match collection {
83-
Some(c) => Ok(Collection::from_model_and_pool(c, self.pool.clone())),
83+
Some(c) => Ok(Collection::new(c.name, self.pool.clone()).await?),
8484
None => {
8585
sqlx::query("INSERT INTO pgml.collections (name) VALUES ($1)")
8686
.bind(name)

pgml-sdks/rust/pgml/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ mod tests {
101101
let connection_string = env::var("DATABASE_URL").unwrap();
102102

103103
init_logger(LevelFilter::Info).unwrap();
104-
let collection_name = "test26";
104+
let collection_name = "test27";
105105

106106
let db = Database::new(&connection_string).await.unwrap();
107107
let collection = db.create_or_get_collection(collection_name).await.unwrap();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy