v2: Correct Parameters passed to VariantChangeType. V3: Added tests
Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com --- dlls/oledb32/convert.c | 8 ++++++-- dlls/oledb32/tests/convert.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/oledb32/convert.c b/dlls/oledb32/convert.c index 267de1b..22609ae 100644 --- a/dlls/oledb32/convert.c +++ b/dlls/oledb32/convert.c @@ -475,10 +475,13 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, } break; case DBTYPE_VARIANT: - if( V_VT((VARIANT*)src) == VT_DATE) + { + VariantInit(&tmp); + + if ((hr = VariantChangeType(&tmp, (VARIANT*)src, 0, VT_DATE)) == S_OK) { SYSTEMTIME st; - hr = (VariantTimeToSystemTime( V_DATE((VARIANT*)src), &st) ? S_OK : E_FAIL); + hr = (VariantTimeToSystemTime( V_DATE(&tmp), &st) ? S_OK : E_FAIL); d->year = st.wYear; d->month = st.wMonth; d->day = st.wDay; @@ -489,6 +492,7 @@ static HRESULT WINAPI convert_DataConvert(IDataConvert* iface, return E_NOTIMPL; } break; + } default: FIXME("Unimplemented conversion %04x -> DBDATE\n", src_type); return E_NOTIMPL; } break; diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c index 1d55e7f..6b0dd55 100644 --- a/dlls/oledb32/tests/convert.c +++ b/dlls/oledb32/tests/convert.c @@ -3357,6 +3357,25 @@ static void test_converttodbdate(void) ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len); ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n");
+ V_VT(&var) = VT_R8; + V_R8(&var) = 41408.086250; + dst_len = 0; + hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0); + ok(hr == S_OK, "got %08x\n", hr); + ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status); + ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len); + ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n"); + + V_VT(&var) = VT_BSTR; + V_BSTR(&var) = SysAllocString(strW); + dst_len = 0; + hr = IDataConvert_DataConvert(convert, DBTYPE_VARIANT, DBTYPE_DBDATE, sizeof(var), &dst_len, &var, &dst, 2, 0, &dst_status, 0, 0, 0); + ok(hr == S_OK, "got %08x\n", hr); + ok(dst_status == DBSTATUS_S_OK, "got %08x\n", dst_status); + ok(dst_len == sizeof(DBDATE), "got %ld\n", dst_len); + ok(!memcmp(&ts, &dst, sizeof(DBDATE) ), "bytes differ\n"); + VariantClear(&var); + dst_len = 0; bstr = SysAllocString(strW); hr = IDataConvert_DataConvert(convert, DBTYPE_BSTR, DBTYPE_DBDATE, 0, &dst_len, &bstr, &dst, 2, 0, &dst_status, 0, 0, 0);