From b5c04d205573ddb5b14fc2ec750656ad11a33cd4 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 22 Aug 2026 05:54:41 -0600 Subject: [PATCH] Test explicit columns with naming collisions Closes #59 --- tests/resources/app/models/AliasedUsernameUser.cfc | 6 ++++++ tests/specs/integration/BaseEntity/AttributeSpec.cfc | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/resources/app/models/AliasedUsernameUser.cfc diff --git a/tests/resources/app/models/AliasedUsernameUser.cfc b/tests/resources/app/models/AliasedUsernameUser.cfc new file mode 100644 index 00000000..044b6e14 --- /dev/null +++ b/tests/resources/app/models/AliasedUsernameUser.cfc @@ -0,0 +1,6 @@ +component extends="quick.models.BaseEntity" accessors="true" table="users" { + + property name="id"; + property name="username" column="first_name" sqltype="cf_sql_varchar"; + +} diff --git a/tests/specs/integration/BaseEntity/AttributeSpec.cfc b/tests/specs/integration/BaseEntity/AttributeSpec.cfc index 5bf9abd3..64deef01 100644 --- a/tests/specs/integration/BaseEntity/AttributeSpec.cfc +++ b/tests/specs/integration/BaseEntity/AttributeSpec.cfc @@ -202,6 +202,14 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ); } ); + it( "uses an explicit column when the property name is also a database column", function() { + var user = getInstance( "AliasedUsernameUser" ).findOrFail( 1 ); + + expect( user.getUsername() ).toBe( "Eric" ); + expect( user.retrieveAttributesData() ).toHaveKey( "first_name" ); + expect( user.retrieveAttributesData() ).notToHaveKey( "username" ); + } ); + // https://github.com/coldbox-modules/quick/issues/127 it( "can clear an attribute", () => { var elpete = getInstance( "User" ).findOrFail( 1 );