From d57e33deb06b7bc8318f1b019d448a28136b2fd1 Mon Sep 17 00:00:00 2001 From: Fabrice Foray Date: Sat, 23 May 2026 17:02:49 +0200 Subject: [PATCH] [XSharp.Core.RDD] Fix Dbc.FindTable to support Alias and/or FileName #1948 --- src/Runtime/XSharp.Core/RDD/DbcSupport.prg | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Runtime/XSharp.Core/RDD/DbcSupport.prg b/src/Runtime/XSharp.Core/RDD/DbcSupport.prg index e2c796198d..f984ecd6c6 100644 --- a/src/Runtime/XSharp.Core/RDD/DbcSupport.prg +++ b/src/Runtime/XSharp.Core/RDD/DbcSupport.prg @@ -3,6 +3,7 @@ // Licensed under the Apache License, Version 2.0. // See License.txt in the project root for license information. // + USING System.Collections.Generic USING System.Diagnostics USING XSharp.RDD.Support @@ -310,7 +311,24 @@ BEGIN NAMESPACE XSharp.RDD /// PUBLIC METHOD FindTable(cTable as STRING) AS DbcTable - RETURN SELF:FindObject(SELF:_tables, cTable) + // Primary lookup by OBJECTNAME (logical alias) + IF _tables:TryGetValue(cTable, OUT VAR oTable) + oTable:GetData() + RETURN oTable + ENDIF + // Fallback: match by physical filename from the Path property. + // Handles cases where the logical name (OBJECTNAME) differs from the filename, + // e.g. "tblstorage_area" (OBJECTNAME) vs "tblstorage area.dbf" (real file). + FOREACH VAR t IN _tables:Values + VAR path := t:Path + IF ! String.IsNullOrEmpty(path) + IF String.Compare(System.IO.Path.GetFileNameWithoutExtension(path), cTable, TRUE) == 0 + t:GetData() + RETURN t + ENDIF + ENDIF + NEXT + RETURN NULL /// PUBLIC METHOD FindView(cView as STRING) AS DbcView