coldbox-modules / cborm

The ColdBox ORM enhancements for ColdFusion ORM & Hibernate. Make ORM not suck!
https://coldbox-orm.ortusbooks.com/
8 stars 17 forks source link

Bug Fix countWhere method #54

Closed BalbinoOrtus closed 2 years ago

BalbinoOrtus commented 2 years ago

@michaelborn @lmajano we need to tweak the countWhere( ) function so the if ( structCount( arguments ) > 1 ) { statement wraps around the entire parameter handling, including the 1 = 1 addition

michaelborn commented 2 years ago

For more context, this resolves a SQL syntax error when only the entityName parameter is provided.

By only running .countWhere( entityName = "User" ), you get SQL like this:

SELECT count(id) FROM User 1 = 1

Which is obviously not valid SQL. :sob:

lmajano commented 2 years ago

@BalbinoOrtus before I merge this, I need a test case. @michaelborn can you assist!

michaelborn commented 2 years ago

I added a test case to @BalbinoOrtus 's PR.

https://github.com/BalbinoOrtus/cborm/pull/1

As soon as he merges that, it will appear in this PR here.

BalbinoOrtus commented 2 years ago

@lmajano @michaelborn merged the test case