Commit 669107f6 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

msado15: Semi-stub _Recordset get/put Filter.

parent 6254f663
......@@ -48,6 +48,7 @@ struct recordset
CursorTypeEnum cursor_type;
IRowset *row_set;
EditModeEnum editmode;
VARIANT filter;
};
struct fields
......@@ -1588,14 +1589,30 @@ static HRESULT WINAPI recordset_get_EditMode( _Recordset *iface, EditModeEnum *m
static HRESULT WINAPI recordset_get_Filter( _Recordset *iface, VARIANT *criteria )
{
FIXME( "%p, %p\n", iface, criteria );
return E_NOTIMPL;
struct recordset *recordset = impl_from_Recordset( iface );
TRACE( "%p, %p\n", iface, criteria );
if (!criteria) return MAKE_ADO_HRESULT( adErrInvalidArgument );
VariantCopy(criteria, &recordset->filter);
return S_OK;
}
static HRESULT WINAPI recordset_put_Filter( _Recordset *iface, VARIANT criteria )
{
FIXME( "%p, %s\n", iface, debugstr_variant(&criteria) );
return E_NOTIMPL;
struct recordset *recordset = impl_from_Recordset( iface );
TRACE( "%p, %s\n", recordset, debugstr_variant(&criteria) );
if (V_VT(&criteria) != VT_I2 && V_VT(&criteria) != VT_I4 && V_VT(&criteria) != VT_BSTR)
return MAKE_ADO_HRESULT( adErrInvalidArgument );
if (V_VT(&criteria) == VT_BSTR && recordset->state == adStateOpen)
{
FIXME("Validating fields not preformed\n");
}
VariantCopy(&recordset->filter, &criteria);
return S_OK;
}
static HRESULT WINAPI recordset_get_PageCount( _Recordset *iface, ADO_LONGPTR *count )
......@@ -2131,6 +2148,7 @@ HRESULT Recordset_create( void **obj )
recordset->cursor_type = adOpenForwardOnly;
recordset->row_set = NULL;
recordset->editmode = adEditNone;
VariantInit( &recordset->filter );
*obj = &recordset->Recordset_iface;
TRACE( "returning iface %p\n", *obj );
......
......@@ -59,7 +59,7 @@ static void test_Recordset(void)
CursorTypeEnum cursor;
BSTR name;
HRESULT hr;
VARIANT bookmark;
VARIANT bookmark, filter;
EditModeEnum editmode;
hr = CoCreateInstance( &CLSID_Recordset, NULL, CLSCTX_INPROC_SERVER, &IID__Recordset, (void **)&recordset );
......@@ -123,6 +123,26 @@ static void test_Recordset(void)
hr = _Recordset_put_Bookmark( recordset, bookmark );
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
VariantInit( &filter );
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == MAKE_ADO_HRESULT( adErrInvalidArgument ), "got %08lx\n", hr );
V_VT(&filter) = VT_BSTR;
V_BSTR(&filter) = SysAllocString( L"field1 = 1" );
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == S_OK, "got %08lx\n", hr );
VariantClear(&filter);
V_VT(&filter) = VT_I4;
V_I4(&filter) = 0;
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == S_OK, "got %08lx\n", hr );
V_VT(&filter) = VT_I2;
V_I2(&filter) = 0;
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == S_OK, "got %08lx\n", hr );
VariantInit( &missing );
hr = _Recordset_AddNew( recordset, missing, missing );
ok( hr == MAKE_ADO_HRESULT( adErrObjectClosed ), "got %08lx\n", hr );
......@@ -248,6 +268,23 @@ static void test_Recordset(void)
ok( fields2 == fields, "expected same object\n" );
Fields_Release( fields2 );
V_VT(&filter) = VT_BSTR;
V_BSTR(&filter) = SysAllocString( L"field1 = 1" );
hr = _Recordset_put_Filter( recordset, filter );
todo_wine ok( hr == MAKE_ADO_HRESULT( adErrItemNotFound ), "got %08lx\n", hr );
VariantClear(&filter);
V_VT(&filter) = VT_BSTR;
V_BSTR(&filter) = SysAllocString( L"field = 1" );
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == S_OK, "got %08lx\n", hr );
VariantClear(&filter);
V_VT(&filter) = VT_I4;
V_I4(&filter) = 0;
hr = _Recordset_put_Filter( recordset, filter );
ok( hr == S_OK, "got %08lx\n", hr );
count = -1;
hr = Fields_get_Count( fields2, &count );
ok( count == 1, "got %ld\n", count );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment