Skip to content

Commit 923e0d5

Browse files
committed
refactor UUID
1 parent 96e2b3b commit 923e0d5

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎src_cpp/py_connection.cpp‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static LogicalType pyLogicalType(const py::handle& val) {
352352
auto datetime_datetime = importCache->datetime.datetime();
353353
auto time_delta = importCache->datetime.timedelta();
354354
auto datetime_date = importCache->datetime.date();
355-
auto uuid = importCache->uuid.UUID();
355+
auto uuid_uuid = importCache->uuid.UUID();
356356
auto Decimal = importCache->decimal.Decimal();
357357
if (val.is_none()) {
358358
return LogicalType::ANY();
@@ -410,7 +410,7 @@ static LogicalType pyLogicalType(const py::handle& val) {
410410
return LogicalType::DATE();
411411
} else if (py::isinstance(val, time_delta)) {
412412
return LogicalType::INTERVAL();
413-
} else if (py::isinstance(val, uuid)) {
413+
} else if (py::isinstance(val, uuid_uuid)) {
414414
return LogicalType::UUID();
415415
} else if (py::isinstance<py::dict>(val)) {
416416
py::dict dict = py::reinterpret_borrow<py::dict>(val);
@@ -673,8 +673,7 @@ Value PyConnection::transformPythonValueAs(const py::handle& val, const LogicalT
673673
}
674674
case LogicalTypeID::UUID: {
675675
auto strVal = py::str(val).cast<std::string>();
676-
auto uuidVal = UUID::fromString(strVal);
677-
uuid uuidToAppend{uuidVal};
676+
auto uuidToAppend = uuid::fromString(strVal);
678677
return Value{uuidToAppend};
679678
}
680679
case LogicalTypeID::LIST: {

‎src_cpp/py_conversion.cpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ PythonObjectType getPythonObjectType(py::handle& ele) {
1818
auto pyDateTime = importCache->datetime.datetime();
1919
auto pandasNat = importCache->pandas.NaT();
2020
auto pyDate = importCache->datetime.date();
21-
auto uuid = importCache->uuid.UUID();
21+
auto pyUuid = importCache->uuid.UUID();
2222
if (ele.is_none() || ele.is(pandasNa) || ele.is(pandasNat)) {
2323
return PythonObjectType::None;
2424
} else if (py::isinstance<py::bool_>(ele)) {
@@ -37,7 +37,7 @@ PythonObjectType getPythonObjectType(py::handle& ele) {
3737
return PythonObjectType::Bytes;
3838
} else if (py::isinstance<py::list>(ele)) {
3939
return PythonObjectType::List;
40-
} else if (py::isinstance(ele, uuid)) {
40+
} else if (py::isinstance(ele, pyUuid)) {
4141
return PythonObjectType::UUID;
4242
} else if (py::isinstance<py::dict>(ele)) {
4343
return PythonObjectType::Dict;
@@ -189,9 +189,8 @@ void transformPythonValue(common::ValueVector* outputVector, uint64_t pos, py::h
189189
} break;
190190
case PythonObjectType::UUID: {
191191
outputVector->setNull(pos, false /* isNull */);
192-
int128_t result = 0;
193-
UUID::fromString(ele.attr("hex").cast<std::string>(), result);
194-
outputVector->setValue(pos, result);
192+
uuid result = uuid::fromString(ele.attr("hex").cast<std::string>());
193+
outputVector->setValue(pos, result.value);
195194
} break;
196195
case PythonObjectType::Dict: {
197196
PyDictionary dict = PyDictionary(py::reinterpret_borrow<py::object>(ele));

‎src_cpp/py_query_result.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ py::object PyQueryResult::convertValueToPyObject(const Value& value) {
159159
}
160160
case LogicalTypeID::UUID: {
161161
lbug::common::int128_t result = value.getValue<lbug::common::int128_t>();
162-
std::string uuidString = lbug::common::UUID::toString(result);
162+
std::string uuidString = lbug::common::uuid::toString(result);
163163
auto UUID = importCache->uuid.UUID();
164164
return UUID(uuidString);
165165
}

0 commit comments

Comments
 (0)