From dcafdea1848e4cb642431ad7b03c2480fb70f8c6 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Sat, 22 Aug 2026 05:11:39 -0600 Subject: [PATCH] test: cover updateOrCreate primary key aliases (#107) --- tests/specs/integration/BaseEntity/UpdateSpec.cfc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/specs/integration/BaseEntity/UpdateSpec.cfc b/tests/specs/integration/BaseEntity/UpdateSpec.cfc index 0ba4cda9..2cfbe18b 100644 --- a/tests/specs/integration/BaseEntity/UpdateSpec.cfc +++ b/tests/specs/integration/BaseEntity/UpdateSpec.cfc @@ -37,6 +37,19 @@ component extends="tests.resources.ModuleIntegrationSpec" { } ); describe( "updateOrCreate", function() { + it( "uses attribute aliases when finding an existing entity", function() { + var post = getInstance( "PostAlt" ).updateOrCreate( + { "id" : 1245 }, + { "body" : "Updated through an aliased primary key" } + ); + + expect( post.getId() ).toBe( 1245 ); + expect( post.getBody() ).toBe( "Updated through an aliased primary key" ); + expect( getInstance( "PostAlt" ).where( "body", "Updated through an aliased primary key" ).count() ).toBe( + 1 + ); + } ); + it( "updates an existing entity", function() { var user = getInstance( "User" ).updateOrCreate( { "username" : "elpete" },