TCustomSQLQuery.ApplyRecUpdate have a bug
Original Reporter info from Mantis: zhouyong
-
Reporter name: 周勇
Original Reporter info from Mantis: zhouyong
- Reporter name: 周勇
Description:
'field=null' in Sql language always return false. So the function "procedure UpdateWherePart(var sql_where : string;x : integer);" have a bug when oldvalue is null. I change the code:
"if (pfInKey in Fields[x].ProviderFlags) or
((FUpdateMode = upWhereAll) and (pfInWhere in Fields[x].ProviderFlags)) or
((FUpdateMode = UpWhereChanged) and (pfInWhere in Fields[x].ProviderFlags) and (fields[x].value <> fields[x].oldvalue)) then
sql_where := sql_where + '(' + FieldNamesQuoteChar + fields[x].FieldName + FieldNamesQuoteChar + '= :' + FieldNamesQuoteChar + 'OLD_' + fields[x].FieldName + FieldNamesQuoteChar +') and '; " to
" if (pfInKey in Fields[x].ProviderFlags) or
((FUpdateMode = upWhereAll) and (pfInWhere in Fields[x].ProviderFlags)) or
((FUpdateMode = UpWhereChanged) and (pfInWhere in Fields[x].ProviderFlags) and (fields[x].value <> fields[x].oldvalue)) then
begin
if (fields[x].oldvalue=null) then // my add
sql_where := sql_where + '(' + FieldNamesQuoteChar + fields[x].FieldName + FieldNamesQuoteChar + ' is null ) and '
else
sql_where := sql_where + '(' + FieldNamesQuoteChar + fields[x].FieldName + FieldNamesQuoteChar + '= :' + FieldNamesQuoteChar + 'OLD_' + fields[x].FieldName + FieldNamesQuoteChar +') and ';
end "
Mantis conversion info:
- Mantis ID: 18162