Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 48 additions & 16 deletions models/BaseEntity.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -2729,10 +2729,20 @@ component accessors="true" {
var meta = {};
meta[ "originalMetadata" ] = util.getInheritedMetadata( this );
meta[ "localMetadata" ] = getMetadata( this );
var hasAccessorsMetadata = false;
if ( meta.localMetadata.keyExists( "accessors" ) ) {
hasAccessorsMetadata = lCase( trim( meta.localMetadata.accessors & "" ) ) == "true";
}
// BoxLang 1.11 exposes component metadata attributes inside `annotations`.
if (
!meta[ "localMetadata" ].keyExists( "accessors" ) ||
meta[ "localMetadata" ].accessors == false
!hasAccessorsMetadata &&
meta.localMetadata.keyExists( "annotations" ) &&
isStruct( meta.localMetadata.annotations ) &&
meta.localMetadata.annotations.keyExists( "accessors" )
) {
hasAccessorsMetadata = lCase( trim( meta.localMetadata.annotations.accessors & "" ) ) == "true";
}
if ( !hasAccessorsMetadata ) {
throw(
type = "QuickAccessorsMissing",
message = 'This instance is missing `accessors="true"` in the component metadata. This is required for Quick to work properly. Please add it to your component metadata and reinit your application.'
Expand Down Expand Up @@ -2767,7 +2777,8 @@ component accessors="true" {

if ( len( meta.originalMetadata.discriminatorValue ) ) {
try {
var parentMeta = getComponentMetadata( meta.parentDefinition.meta.fullName );
var parentMeta = reference.get_Meta().originalMetadata;
param parentMeta.discriminatorColumn = "";
meta.parentDefinition[ "discriminatorValue" ] = meta.originalMetadata.discriminatorValue;
meta.parentDefinition[ "discriminatorColumn" ] = parentMeta.discriminatorColumn;
} catch ( any e ) {
Expand All @@ -2790,8 +2801,18 @@ component accessors="true" {
{}
);
} );
var functionsForRelationshipDetection = [];
if (
meta.originalMetadata.keyExists( "functions" ) &&
isArray( meta.originalMetadata.functions ) &&
!meta.originalMetadata.functions.isEmpty()
) {
functionsForRelationshipDetection = meta.originalMetadata.functions;
} else if ( meta.localMetadata.keyExists( "functions" ) && isArray( meta.localMetadata.functions ) ) {
functionsForRelationshipDetection = meta.localMetadata.functions;
}
meta[ "functionNames" ] = generateFunctionNameArray(
from = meta.originalMetadata.functions,
from = functionsForRelationshipDetection,
without = baseEntityFunctionNames
);

Expand Down Expand Up @@ -2926,18 +2947,29 @@ component accessors="true" {
* @return An attribute struct with all the keys needed.
*/
private struct function paramAttribute( required struct attr ) {
param attr.column = arguments.attr.name;
param attr.persistent = true;
param attr.nullValue = "";
param attr.convertToNull = true;
param attr.casts = "";
param attr.readOnly = false;
param attr.sqltype = "";
param attr.insert = true;
param attr.update = true;
param attr.virtual = false;
param attr.exclude = false;
param attr.isParentColumn = false;
if (
!arguments.attr.keyExists( "persistent" ) &&
arguments.attr.keyExists( "annotations" ) &&
isStruct( arguments.attr.annotations ) &&
arguments.attr.annotations.keyExists( "persistent" )
) {
arguments.attr.persistent = arguments.attr.annotations.persistent;
}
param attr.column = arguments.attr.name;
param attr.persistent = true;
param attr.nullValue = "";
param attr.convertToNull = true;
param attr.casts = "";
param attr.readOnly = false;
param attr.sqltype = "";
param attr.insert = true;
param attr.update = true;
param attr.virtual = false;
param attr.exclude = false;
param attr.isParentColumn = false;
if ( !isBoolean( attr.persistent ) ) {
attr.persistent = lCase( trim( attr.persistent & "" ) ) == "true";
}
variables._nullValues[ attr.name ] = attr.nullValue;
return arguments.attr;
}
Expand Down
21 changes: 21 additions & 0 deletions tests/specs/integration/BaseEntity/MetadataSpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ component extends="tests.resources.ModuleIntegrationSpec" {
.notToHaveKey( "discriminatorColumn" );
} );
} );

describe( "boxlang metadata compatibility", function() {
it(
title = "can read accessors metadata from annotations",
body = function() {
expect( function() {
getInstance( "User" );
} ).notToThrow();
},
skip = !server.keyExists( "boxlang" )
);

it(
title = "can read property persistent metadata from annotations",
body = function() {
var link = getInstance( "Link" );
expect( link.get_Attributes() ).notToHaveKey( "wirebox" );
},
skip = !server.keyExists( "boxlang" )
);
} );
} );
}

Expand Down
Loading