Page 1 of 1

TDatabase broken backward compatibility

Posted: Thu Nov 03, 2022 3:04 am
by hua
When I upgrade some of my existing codes from FWH11.08 to FWH19.12, I found the following behaviour changes
1. The newer TDatabase will not change to the workarea of dbf opened using :open()
2. The newer TDatabase():save() under certain situation will do an APPEND BLANK automatically.

Apart from linking in the old version of TDatabase is there any flag to get the old behaviour?
I do not wish to have fingers pointed to me after linking in the latest FWH that I have because backward-compatibility was broken and causes either data integrity issues or run-time error occurs

TIA

Re: TDatabase broken backward compatibility

Posted: Thu Nov 03, 2022 3:57 am
by nageswaragunupudi
We do not like any user to face any inconvenience by upgrading FWH.
1st point: This was a deliberate change we made to avoid some common problems. We can explain but at some other time.
For now, we will make some changes in the database.prg to continue the old behavior

I will post the changes in my next post. Either you can make the changes yourself or we do not mind providing the revised program to you if you so wish.

2nd point; This should not happen. Can you explain a little more about this?

I consider that the latest version you have with you is FWH1912. Right?

Re: TDatabase broken backward compatibility

Posted: Thu Nov 03, 2022 4:33 am
by hua
Yes, the latest FWH I have is FWH1912.

In this particular module, I have sub-classed TDatabase and override :append() and :blank() method

Code: Select all | Expand

method append(lBlank) class TData
  local lRet := .f.
  default lBlank := .t.
  if ( ::cAlias )->( add_rec() )
     if lBlank
        ::blank()
     endif
     lRet := .t.
  endif
return lRet
//----------------------------------------------------------------------------
method blank(cField) class TData
  local xRet, x, y, n

  if !empty(cField) // user wants to blank a field only
     n := ::fieldPos(cField)
     x := ::fieldGet(n)
     y := valtype(x)
     do case
     case y == "C"
       xRet := space(len(x))
     case y == "M"
       xRet := ""
     case y == "D"
       xRet := ctod("")
     case y == "N"
       xRet := 0
     end
     ::aBuffer[n] := xRet
  else
     ::super:blank()
     if ::lBuffer
        // latest TDatabase (FWH1912) causes does append on its own at :save() if :nBufKeyNo value is 0
        ::nBufKeyNo    := ( ::cAlias )->( OrdKeyNo() )
        ::nBufRecNo    := ( ::cAlias )->( RECNO() )
     endif
  endif
return nil