Skip to content

Commit

Permalink
parse size
Browse files Browse the repository at this point in the history
  • Loading branch information
28Smiles committed Apr 21, 2024
1 parent 6d101f1 commit 99513fb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/postgres/writer/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ impl ColumnInfo {
Type::DateRange => ColumnType::Custom(Alias::new("daterange").into_iden()),
Type::PgLsn => ColumnType::Custom(Alias::new("pg_lsn").into_iden()),
Type::Unknown(s) => {
match s.as_str() {
#[cfg(feature = "postgres-vector")]
"vector" => ColumnType::Vector,
_ => ColumnType::Custom(Alias::new(s).into_iden()),
#[cfg(feature = "postgres-vector")]
if s.starts_with("vector") {
let s = &s[6..];
return if s.starts_with("(") && s.ends_with(")") {
let s = &s[1..s.len() - 1];
let size = s.parse::<u32>().expect("Invalid vector size");
ColumnType::Vector(Some(size))
} else {
ColumnType::Vector(None)
}
}

ColumnType::Custom(Alias::new(s).into_iden())
},
Type::Enum(enum_def) => {
let name = Alias::new(&enum_def.typename).into_iden();
Expand Down

0 comments on commit 99513fb

Please sign in to comment.