From 8e5a0a05524bb597ca38b6c723aec4c261c8a831 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Fri, 20 Sep 2024 14:06:57 -0600 Subject: [PATCH] Fix to match CFML query metadata behavior --- .../modules/compat/bifs/system/GetMetaData.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetMetaData.java b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetMetaData.java index db64bb4..244f53e 100644 --- a/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetMetaData.java +++ b/src/main/java/ortus/boxlang/modules/compat/bifs/system/GetMetaData.java @@ -14,6 +14,8 @@ */ package ortus.boxlang.modules.compat.bifs.system; +import java.util.Map; + import ortus.boxlang.runtime.bifs.BIF; import ortus.boxlang.runtime.bifs.BoxBIF; import ortus.boxlang.runtime.context.IBoxContext; @@ -22,6 +24,9 @@ import ortus.boxlang.runtime.scopes.Key; import ortus.boxlang.runtime.types.Argument; import ortus.boxlang.runtime.types.Function; +import ortus.boxlang.runtime.types.Query; +import ortus.boxlang.runtime.types.Array; +import ortus.boxlang.runtime.types.Struct; @BoxBIF public class GetMetaData extends BIF { @@ -58,6 +63,18 @@ public Object _invoke( IBoxContext context, ArgumentsScope arguments ) { return boxClass.getMetaData(); } + if ( value instanceof Query query ) { + Array columnMetadata = new Array(); + for ( Map.Entry entry : columns.entrySet() ) { + columnMetadata.add( Struct.of( + Key._name, entry.getKey(), + Key.typename, entry.getValue().getType().toString(), + Key.isCaseSensitive, false + ) ); + } + return columnMetadata; + } + // All other types return the class of the value to match CF engines return value.getClass(); }