mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 06:49:16 +02:00
* More complete indexdef treatment
git-svn-id: trunk@11543 -
This commit is contained in:
parent
4aa1b45da2
commit
5a2da31729
@ -141,6 +141,10 @@ Type
|
|||||||
Public
|
Public
|
||||||
Constructor Create(ATableName : String);
|
Constructor Create(ATableName : String);
|
||||||
Function AddDDIndexDef(AName : String) : TDDIndexDef;
|
Function AddDDIndexDef(AName : String) : TDDIndexDef;
|
||||||
|
function AddIndex (AName: String) : TDDIndexDef;
|
||||||
|
function IndexByName(AIndexName: String): TDDIndexDef;
|
||||||
|
function FindIndex(AIndexName: String): TDDIndexDef;
|
||||||
|
function IndexOfIndex(AIndexName: String): Integer;
|
||||||
Property TableName : String Read FTableName Write SetTableName;
|
Property TableName : String Read FTableName Write SetTableName;
|
||||||
Property Indexes[Index : Integer] : TDDIndexDef Read GetIndex Write SetIndex; default;
|
Property Indexes[Index : Integer] : TDDIndexDef Read GetIndex Write SetIndex; default;
|
||||||
end;
|
end;
|
||||||
@ -477,6 +481,7 @@ Const
|
|||||||
|
|
||||||
Resourcestring
|
Resourcestring
|
||||||
SErrFieldNotFound = '"%s": Field "%s" not found.';
|
SErrFieldNotFound = '"%s": Field "%s" not found.';
|
||||||
|
SErrIndexNotFound = '"%s": Index "%s" not found.';
|
||||||
SErrTableNotFound = 'Table "%s" not found.';
|
SErrTableNotFound = 'Table "%s" not found.';
|
||||||
SErrDuplicateTableName = 'Duplicate table name: "%s"';
|
SErrDuplicateTableName = 'Duplicate table name: "%s"';
|
||||||
SErrDuplicateFieldName = '"%s": Duplicate field name: "%s"';
|
SErrDuplicateFieldName = '"%s": Duplicate field name: "%s"';
|
||||||
@ -997,6 +1002,7 @@ procedure TDDTableDef.SetTableName(const AValue: String);
|
|||||||
begin
|
begin
|
||||||
FTableName:=AValue;
|
FTableName:=AValue;
|
||||||
FFieldDefs.TableName:=AValue;
|
FFieldDefs.TableName:=AValue;
|
||||||
|
FIndexDefs.TableName:=AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDDTableDef.GetPrimaryKeyName: String;
|
function TDDTableDef.GetPrimaryKeyName: String;
|
||||||
@ -2199,11 +2205,41 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TDDIndexDefs.AddDDIndexDef(AName: String): TDDIndexDef;
|
function TDDIndexDefs.AddDDIndexDef(AName: String): TDDIndexDef;
|
||||||
|
begin
|
||||||
|
result := AddIndex (AName);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDDIndexDefs.AddIndex(AName: String): TDDIndexDef;
|
||||||
begin
|
begin
|
||||||
Result:=Add as TDDIndexDef;
|
Result:=Add as TDDIndexDef;
|
||||||
Result.IndexName:=AName;
|
Result.IndexName:=AName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDDIndexDefs.IndexOfIndex(AIndexName: String): Integer;
|
||||||
|
begin
|
||||||
|
Result:=Count-1;
|
||||||
|
While (Result>=0) and (CompareText(GetIndex(Result).IndexName,AIndexName)<>0) do
|
||||||
|
Dec(Result)
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDDIndexDefs.FindIndex(AIndexName: String): TDDIndexDef;
|
||||||
|
Var
|
||||||
|
I : integer;
|
||||||
|
begin
|
||||||
|
I:=IndexOfIndex(AIndexName);
|
||||||
|
If (I=-1) then
|
||||||
|
Result:=Nil
|
||||||
|
else
|
||||||
|
Result:=GetIndex(I);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDDIndexDefs.IndexByName(AIndexName: String): TDDIndexDef;
|
||||||
|
begin
|
||||||
|
Result:=FindIndex(AIndexName);
|
||||||
|
If Result=Nil then
|
||||||
|
Raise EDatadict.CreateFmt(SErrIndexNotFound,[TableName,AIndexName]);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
Loading…
Reference in New Issue
Block a user