Skip to content

Commit 7c51883

Browse files
committed
Switched to pqxx::from_string
1 parent 157b633 commit 7c51883

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/pgvector/pqxx.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ template<> struct string_traits<pgvector::Vector> {
3737
size_t start = 0;
3838
for (size_t i = 0; i < inner.size(); i++) {
3939
if (inner[i] == ',') {
40-
values.push_back(string_traits<float>::from_string(inner.substr(start, i - start), c));
40+
values.push_back(pqxx::from_string<float>(inner.substr(start, i - start), c));
4141
start = i + 1;
4242
}
4343
}
44-
values.push_back(string_traits<float>::from_string(inner.substr(start), c));
44+
values.push_back(pqxx::from_string<float>(inner.substr(start), c));
4545
}
4646
return pgvector::Vector{std::move(values)};
4747
}
@@ -105,11 +105,11 @@ template<> struct string_traits<pgvector::HalfVector> {
105105
size_t start = 0;
106106
for (size_t i = 0; i < inner.size(); i++) {
107107
if (inner[i] == ',') {
108-
values.push_back(static_cast<pgvector::Half>(string_traits<float>::from_string(inner.substr(start, i - start), c)));
108+
values.push_back(static_cast<pgvector::Half>(pqxx::from_string<float>(inner.substr(start, i - start), c)));
109109
start = i + 1;
110110
}
111111
}
112-
values.push_back(static_cast<pgvector::Half>(string_traits<float>::from_string(inner.substr(start), c)));
112+
values.push_back(static_cast<pgvector::Half>(pqxx::from_string<float>(inner.substr(start), c)));
113113
}
114114
return pgvector::HalfVector{std::move(values)};
115115
}
@@ -172,7 +172,7 @@ template<> struct string_traits<pgvector::SparseVector> {
172172
throw conversion_error("Malformed sparsevec literal");
173173
}
174174

175-
int dimensions = string_traits<int>::from_string(text.substr(n + 2), c);
175+
int dimensions = pqxx::from_string<int>(text.substr(n + 2), c);
176176
if (dimensions < 0) {
177177
throw conversion_error("Dimensions cannot be negative");
178178
}
@@ -187,8 +187,8 @@ template<> struct string_traits<pgvector::SparseVector> {
187187
throw conversion_error("Malformed sparsevec literal");
188188
}
189189

190-
int index = string_traits<int>::from_string(substr.substr(0, ne), c);
191-
float value = string_traits<float>::from_string(substr.substr(ne + 1), c);
190+
int index = pqxx::from_string<int>(substr.substr(0, ne), c);
191+
float value = pqxx::from_string<float>(substr.substr(ne + 1), c);
192192

193193
if (index < 1) {
194194
throw conversion_error("Index out of bounds");

0 commit comments

Comments
 (0)