@@ -93,23 +93,23 @@ template <> struct string_traits<pgvector::HalfVector> {
9393 throw conversion_error (" Malformed halfvec literal" );
9494 }
9595
96- std::vector<float > values;
96+ std::vector<pgvector::HalfType > values;
9797 if (text.size () > 2 ) {
9898 std::string_view inner = text.substr (1 , text.size () - 2 );
9999 size_t start = 0 ;
100100 for (size_t i = 0 ; i < inner.size (); i++) {
101101 if (inner[i] == ' ,' ) {
102- values.push_back (string_traits<float >::from_string (inner.substr (start, i - start), c));
102+ values.push_back (static_cast <pgvector::HalfType>( string_traits<float >::from_string (inner.substr (start, i - start), c) ));
103103 start = i + 1 ;
104104 }
105105 }
106- values.push_back (string_traits<float >::from_string (inner.substr (start), c));
106+ values.push_back (static_cast <pgvector::HalfType>( string_traits<float >::from_string (inner.substr (start), c) ));
107107 }
108108 return pgvector::HalfVector (std::move (values));
109109 }
110110
111111 static std::string_view to_buf (std::span<char > buf, const pgvector::HalfVector& value, ctx c = {}) {
112- std::span<const float > values{value};
112+ std::span<const pgvector::HalfType > values{value};
113113
114114 // important! size_buffer cannot throw an exception on overflow
115115 // so perform this check before writing any data
@@ -124,7 +124,7 @@ template <> struct string_traits<pgvector::HalfVector> {
124124 if (i != 0 ) {
125125 buf[here++] = ' ,' ;
126126 }
127- here += pqxx::into_buf (buf.subspan (here), values[i], c);
127+ here += pqxx::into_buf (buf.subspan (here), static_cast < float >( values[i]) , c);
128128 }
129129
130130 buf[here++] = ' ]' ;
@@ -133,15 +133,15 @@ template <> struct string_traits<pgvector::HalfVector> {
133133 }
134134
135135 static size_t size_buffer (const pgvector::HalfVector& value) noexcept {
136- std::span<const float > values{value};
136+ std::span<const pgvector::HalfType > values{value};
137137
138138 // cannot throw an exception here on overflow
139139 // so throw in into_buf
140140
141141 size_t size = 2 ; // [ and ]
142142 for (const auto v : values) {
143143 size += 1 ; // ,
144- size += string_traits<float >::size_buffer (v );
144+ size += string_traits<float >::size_buffer (static_cast < float >(v) );
145145 }
146146 return size;
147147 }
0 commit comments