tracker issue : CF-4149665

select a category, or use search below
(searches all categories and all time range)
Title:

ORM: has<property>() doesn't take the property's where attribute into account

| View in Tracker

Status/Resolution/Reason: To Test//Investigate

Reporter/Name(from Bugbase): Mingo Hagen / Mingo Hagen (Mingo Hagen)

Created: 05/06/2016

Components: ORM Support

Versions: 2016

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: CF2016_Final /

Priority/Frequency: Major / All users will encounter

Locale/System: ALL / Platforms All

Vote Count: 0

Problem Description:

Given this property:

property name="bars" singularname="bar" fieldtype="one-to-many" fkcolumn="fooid" cfc="bar" where="deleted=0";

The hasBar() function doesn't use the where attribute

Steps to Reproduce:

See included files.

Actual Result:

hasBar() returns true

Expected Result:

hasBar() returns true

Any Workarounds:

Set lazy to false on the property or create your own has<property>() function.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4149665

Reason:	PRHaveInfo

External Customer Info:
External Company:  
External Customer Name: Mingo Hagen
External Customer Email:  
External Test Config: My Hardware and Environment details:

CF9 through CF2016

Attachments:

  1. May 06, 2016 00:00:00: 1_orm-has1.zip
  2. May 11, 2016 00:00:00: 2_orm-has1.png

Comments:

I meant to type: hasBar() returns false in the Expected Result part.
Comment by External U.
2917 | May 06, 2016 09:55:23 AM GMT
Mingo, Please share database and database driver details.
Comment by Nimit S.
2918 | May 09, 2016 03:42:07 AM GMT
@Nimit, The database is generated using ORM, I've tested using PostgreSQL 9.4 using native CF drivers (on CF9, 11 and 2016)
Comment by External U.
2919 | May 09, 2016 03:46:01 AM GMT
I have tried a repro case attached with this bug. hasBar() returns NO, if condition doesn't hold. Please try it one more time and share the screenshot with us.
Comment by Nimit S.
2920 | May 11, 2016 03:29:04 AM GMT
Hi Nimit, I've attached a screenshot showing the conflicting result (running on CF2016)
Comment by External U.
2921 | May 11, 2016 03:44:03 AM GMT
Mingo, I am unable to download the screenshot attached. Please share it at nimsharm@adobe.com
Comment by Nimit S.
2922 | May 17, 2016 11:40:28 PM GMT
I've sent you the screenshot via email.
Comment by External U.
2923 | May 18, 2016 03:12:57 AM GMT
Mingo, I am unable to repro this issue. I have attached a screenshot to this bug. Please try replicating this issue with the latest update of ColdFusion 2016
Comment by Nimit S.
2924 | September 04, 2017 09:12:20 AM GMT
Hi Nimit, I get the same result with CF2016 update 4 as with earlier versions of CF2016. Are you telling me you get "false" when you call hasBar() on the included example? Best regards, Mingo.
Comment by Mingo H.
2925 | September 05, 2017 08:07:06 AM GMT
Mingo, Yes, I get "false" when I am calling hasBar() on the included example. Please check attached bars.jpg for your reference.
Comment by Nimit S.
2926 | September 05, 2017 09:46:17 AM GMT
I have tested this using ACF2016 update 4 against a MariaDB database. I had to make a couple of tweaks to the script so it handled boolean values for MySQL vs Postgres but nothing to affect the test case. The result of running the script is: hasBar() using lazy=true YES array [empty] hasBaz() using lazy=false NO array [empty] I've enabled SQL logging to see what is happening: hasBar() using lazy=true<br /> Hibernate: select count(id) from bar where fooid =? Hibernate: select bars0_.fooid as fooid4_2_0_, bars0_.id as id1_0_0_, bars0_.id as id1_0_1_, bars0_.name as name2_0_1_, bars0_.deleted as deleted3_0_1_, bars0_.fooid as fooid4_0_1_ from bar bars0_ where ( bars0_.deleted='0' ) and bars0_.fooid=? hasBaz() using lazy=false<br /> Note that the first SQL statement run does _not_ include the deleted='0', but the 2nd does. When I add `lazy=false` to the `bars` property of bar.cfc and re-run, I get this output: hasBar() using lazy=false NO array [empty] hasBaz() using lazy=false NO array [empty] The generated SQL is: Hibernate: select foo0_.id as id1_2_0_, foo0_.name as name2_2_0_ from foo foo0_ where foo0_.id=? Hibernate: select bazs0_.fooid as fooid4_2_0_, bazs0_.id as id1_1_0_, bazs0_.id as id1_1_1_, bazs0_.name as name2_1_1_, bazs0_.deleted as deleted3_1_1_, bazs0_.fooid as fooid4_1_1_ from baz bazs0_ where ( bazs0_.deleted='0' ) and bazs0_.fooid=? Hibernate: select bars0_.fooid as fooid4_2_0_, bars0_.id as id1_0_0_, bars0_.id as id1_0_1_, bars0_.name as name2_0_1_, bars0_.deleted as deleted3_0_1_, bars0_.fooid as fooid4_0_1_ from bar bars0_ where ( bars0_.deleted='0' ) and bars0_.fooid=? Note that we have an extra SQL statement, which does reference deleted='0'.
Comment by John W.
2927 | September 05, 2017 02:18:48 PM GMT
Thanks Mingo for the information. I will try this. Can you please also update these bugs CF-4199483 and CF-4199484
Comment by Nimit S.
2928 | September 11, 2017 05:10:24 PM GMT