Skip to content

Conversation

elpete
Copy link
Contributor

@elpete elpete commented Aug 28, 2025

Description

It seems in mementifier the autoCastBoolean option is not respected for child items.
For example:

class Conversation {
    property name="id";
    property name="name";
    
    function latestMessage() {
        return belongsTo( "ConversationMessage", "latestMessageID" );
    }
}
class ConversationMessage {
    property name="id";
    property name="conversationID";
    property name="body" type="string" sqltype="CF_SQL_NVARCHAR";

    this.memento = { "defaultExcludes": [ "segments" ], "autoCastBooleans": false };
}

When calling getMemento() on a Conversation, it does not respect the autoCastBooleans: false in the ConversationMessage's memento settings.

This seems to be the case for a few other flags as well:

// Process the item memento
result[ thisAlias ][ thisIndex ] = thisValue[ thisIndex ].getMemento(
	includes        : nestedIncludes,
	excludes        : $buildNestedMementoList( excludes, item ),
	mappers         : $buildNestedMementoStruct( mappers, item ),
	defaults        : $buildNestedMementoStruct( defaults, item ),
	// cascade the ignore defaults down if specific nested includes are requested
	ignoreDefaults  : nestedIncludes.len() ? arguments.ignoreDefaults : false,
	// Cascade the arguments to the children
	profile         : arguments.profile,
	trustedGetters  : arguments.trustedGetters,
	iso8601Format   : arguments.iso8601Format,
	dateMask        : arguments.dateMask,
	timeMask        : arguments.timeMask,
	autoCastBooleans: arguments.autoCastBooleans
);

(From the Mementifier interceptor)

The problem here is that those flags are treated as overrides even if they are defaults. I have never set autoCastBooleans to true. It is the default value. I feel like we should treat default values as different than passed in values. Even then, passing in autoCastBooleans = true to the root level entity may not necessarily mean I want it all the way down, but I feel like it's closer, at least.

Take this section here inside Mementifier.cfc:

arguments.trustedGetters   = isNull( arguments.trustedGetters ) ? thisMemento.trustedGetters : arguments.trustedGetters;
arguments.iso8601Format    = isNull( arguments.iso8601Format ) ? thisMemento.iso8601Format : arguments.iso8601Format;
arguments.dateMask         = isNull( arguments.dateMask ) ? thisMemento.dateMask : arguments.dateMask;
arguments.timeMask         = isNull( arguments.timeMask ) ? thisMemento.timeMask : arguments.timeMask;
arguments.autoCastBooleans = isNull( arguments.autoCastBooleans ) ? thisMemento.autoCastBooleans : arguments.autoCastBooleans;

I would say we want to not param the arguments scope, but instead check if it's null and if it is smartly apply the default. That way the nested getMemento call can do the same checks.

Issues

BOX-156

Type of change

Please delete options that are not relevant.

  • Bug Fix
  • Improvement
  • New Feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link

github-actions bot commented Aug 28, 2025

lucee@6 ColdBox be Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

adobe@2023 ColdBox be Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

lucee@5 ColdBox ^7.0.0 Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

lucee@5 ColdBox be Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

lucee@6 ColdBox ^7.0.0 Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

boxlang-cfml@be ColdBox be Test Results

21 tests  +1   21 ✅ +1   2s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

adobe@2023 ColdBox ^7.0.0 Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

boxlang-cfml@1 ColdBox ^7.0.0 Test Results

21 tests  +1   21 ✅ +1   2s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

adobe@2025 ColdBox be Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Aug 28, 2025

adobe@2025 ColdBox ^7.0.0 Test Results

21 tests  +1   21 ✅ +1   1s ⏱️ ±0s
 2 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 52f4ade. ± Comparison against base commit f3b85ff.

♻️ This comment has been updated with latest results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant