MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / select_embedding

Function select_embedding

tests/embedding_tests.rs:105–151  ·  view source on GitHub ↗
(db: &DatabaseConnection)

Source from the content-addressed store, hash-verified

103 }
104
105 pub async fn select_embedding(db: &DatabaseConnection) -> Result<(), DbErr> {
106 use embedding::*;
107
108 #[derive(DerivePartialModel, FromQueryResult, Debug, PartialEq)]
109 #[sea_orm(entity = "Entity")]
110 struct PartialSelectResult {
111 embedding: PgVector,
112 }
113
114 let result = Entity::find_by_id(1)
115 .into_partial_model::<PartialSelectResult>()
116 .one(db)
117 .await?;
118
119 assert_eq!(
120 result,
121 Some(PartialSelectResult {
122 embedding: PgVector::from(vec![10.]),
123 })
124 );
125
126 let result = Entity::find_by_id(2)
127 .into_partial_model::<PartialSelectResult>()
128 .one(db)
129 .await?;
130
131 assert_eq!(
132 result,
133 Some(PartialSelectResult {
134 embedding: PgVector::from(vec![1., 2.]),
135 })
136 );
137
138 let result = Entity::find_by_id(3)
139 .into_partial_model::<PartialSelectResult>()
140 .one(db)
141 .await?;
142
143 assert_eq!(
144 result,
145 Some(PartialSelectResult {
146 embedding: PgVector::from(vec![10., 20., 30.]),
147 })
148 );
149
150 Ok(())
151 }
152}

Callers 1

mainFunction · 0.85

Calls 1

oneMethod · 0.45

Tested by

no test coverage detected