Migration from RO9.5 to RO10 Notes

Will try to register the stones I get in the process.
Using Delphi RIO 10.3.3 RemObjects 10 (build 1469).

  1. Breaking change

Data dictionary field must now have an unique name between all the data dictionaries used n the project.
If don´t will raises an error: ‘duplicated not allowed’.

unit System.generics.collection line 7095
code

procedure TDictionary<TKey,TValue>.Add(const Key: TKey; const Value: TValue);
var
  index, hc: Integer;
begin
  if Count >= FGrowThreshold then
    Grow;

  hc := Hash(Key);
  index := GetBucketIndex(Key, hc);
  if index >= 0 then
    raise EListError.CreateRes(@SGenericDuplicateItem);

  DoAdd(hc, not index, Key, Value);
end;

Any chance to remove that restriction? I have many data dictionary fields with the same field name.

best regards

Hi,

How I can reproduce this issue?
Untitled

Will try to do a test case. Is a project working on 9.5, just try with version 10 and happens when try to access at runtime to a field present un several datadictcionary. My config is diferent. Each datamodule have schema, datadictionary and connections component. Load that from binary stream at runtime.

Ok, I test in depth,
The problem is raised when a DataDictionary have two fields with the same name. My original bug report was wroing.

That modification fix the error ignoring the second item. I ignore why schema modeler (old version) allow tio have many data dictionary fields with the same name. But if theres a reason then must find a way to allow to coexist both field name in the generics data dictionary .

procedure TSearcheableCollectionCached.RebuildList;
var
  i: integer;
begin
  {$IFDEF ROUseGenerics}
  FNameList.Clear;
  for i := 0 to Count -1 do
  begin
    // check theres not duplicated
    if not FNameList.ContainsKey(AnsiUpperCase(GetItemName(Items[i]))) then
    begin
      FNameList.Add(AnsiUpperCase(GetItemName(Items[i])),Items[i]);
    end;
  end;
  {$ELSE}
  FNameList.Sorted:=False;
  FNameList.Clear;
  FNameList.Capacity:= Self.Count;
  for i := 0 to Count -1 do
    FNameList.AddObject(GetItemName(Items[i]),Items[i]);
  FNameList.Sorted:=True;
  {$ENDIF}
  fNeedRebuild := False;
end;

Have sense have two fields with the same name in datadicionary? I have no idea. If it can happens just add my change.

Best regards

Hi,

you can’t have the same name (e.g. Field1) twice in the same data dictionary.
if it is possible, then it is a bug.
Why you can’t use template for name like %tablename%_%fieldname% ?
as a result, you will have something like table1_field1, Orders_ID, etc

Fine, will search the schema with the problem and fix.

Have no idea where to use that template. You mean in your code? In the data dictionary name at the schema editor?

If you mean in the schema , that template mis the opposite to the data dictionary use. Is suss pose to be reused on another tables, right? For that reason I change the proposed name .

Best regards.

Hi,

you can name fields as you like, but they should be unique per data dictionary.
you can name fields like

  • varchar(20) as name20
  • varchar(40) as name40
    it will allow to be unique
1 Like

Maybe can be great if the exception have more specific information to detect the problem quickly.

Best regards

Hi,

as you understand, we can’t change DASM3 because it was retired a few years ago …

Im talking about the runtime error.

Hi,

What error you would like to see here?
something like duplicated not allowed: %name% ?

In this situation? Better some like:

Datadictionary %datadictionary% have duplicated field names on field %fieldname%. Sounds logic?

we can’t raise this exception on TDataDictionary level.
I can add exception here:

function TDACustomFieldCollection.Add(const aName: string; aType: TDADataType; aSize: integer): TDACustomField;
begin
  result := Add;
  result.Name := aName;
  result.DataType := aType;
  result.Size := aSize;
end;

but this class knows nothing about TDataDictionary

TDACustomFieldCollection has duplicated field names on field %fieldname%

but it won’t help too much …