Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BUG?! in CursorAdapter CursorFill/CursorRefresh methods
Message
From
05/06/2008 05:53:15
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
BUG?! in CursorAdapter CursorFill/CursorRefresh methods
Miscellaneous
Thread ID:
01321806
Message ID:
01321806
Views:
102
Hi everybody,

I just discovered this "behaviour" of the CursorAdapter class, which I think is a serious bug.

If there are uncommited changes to the attached cursor of the CursorAdapter the CursorFill/CursorRefresh methods will silently commit the changes - but only if
the BuffermodeOverride property is set to 3 (row buffering).

From VFP Help of the CursorRefresh method:
"Visual FoxPro generates an error message when the cursor contains unsaved changes."

I think this definitly needs a fix, if our application comes into the state that there are uncommited changes when CursorFill/Refresh is called I definitly don't want these changes to be silently committed - instead the error should always be risen and the decision how to deal with this situation should be left to the application developer.

Repro code:
IF !USED('test')
	CREATE TABLE test (pk I, field1 C(20))
ENDIF

ZAP IN test
FOR m.xj = 1 TO 10
	INSERT INTO test VALUES(m.xj, 'Test ' + TRANSFORM(m.xj))
ENDFOR

SELECT test
LOCATE

LOCAL pk_value
m.pk_value = test.pk

LOCAL loAdapter AS CursorAdapter
loAdapter = CREATEOBJECT('CursorAdapter')
loAdapter.DataSourceType = "NATIVE"
loAdapter.Alias = 'v_test'
loAdapter.SelectCmd = 'SELECT * FROM test WHERE pk = m.pk_value'
loAdapter.BufferModeOverride = 3 && change to 5 and the code will raise error 1545 as expected
loAdapter.SendUpdates = .T.
loAdapter.Tables = 'test'
loAdapter.KeyFieldList = 'pk'
loAdapter.UpdatableFieldList = 'pk, field1'
loAdapter.UpdateNameList = 'pk test.pk, field1 test.field1'

IF loAdapter.CursorFill()

	replace field1 WITH 'changed' IN v_test

	IF !loAdapter.CursorRefresh()
	&&IF !loAdapter.CursorFill()
		AERROR(laError)
		DISPLAY MEMORY LIKE laError
	ELSE
		? 'CursorFill/Refresh succeeded'
		SELECT test 
		LOCATE FOR pk = m.pk_value && the first CursorFill changes recno
		? 'Value in Cursor: ' + test.field1
		? 'Value in CA:     ' + v_test.field1
	ENDIF
ELSE
	AERROR(laError)
	DISPLAY MEMORY LIKE laError
ENDIF
Christian
Next
Reply
Map
View

Click here to load this message in the networking platform