Skip to content

Commit 24f1626

Browse files
committed
Implement casting for Vector to HalfVec
1 parent bab73fc commit 24f1626

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/diesel_ext/halfvec.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
use diesel::deserialize::{self, FromSql};
2+
use diesel::expression::{CastsTo, FallibleCastsTo, KnownCastSqlTypeName};
23
use diesel::pg::{Pg, PgValue};
34
use diesel::query_builder::QueryId;
45
use diesel::serialize::{self, IsNull, Output, ToSql};
56
use diesel::sql_types::SqlType;
67
use std::convert::TryFrom;
78
use std::io::Write;
89

10+
use crate::sql_types::Vector;
911
use crate::HalfVector;
1012

1113
#[derive(SqlType, QueryId)]
@@ -32,6 +34,13 @@ impl FromSql<HalfVectorType, Pg> for HalfVector {
3234
}
3335
}
3436

37+
impl KnownCastSqlTypeName<Pg> for HalfVectorType {
38+
const SQL_TYPE_NAME: &'static str = "halfvec";
39+
}
40+
41+
impl FallibleCastsTo<HalfVectorType> for Vector {}
42+
impl CastsTo<HalfVectorType> for Vector {}
43+
3544
#[cfg(test)]
3645
mod tests {
3746
use crate::{HalfVector, VectorExpressionMethods};

0 commit comments

Comments
 (0)