<commit_before><cfcomponent extends="wheelsMapping.test">

	<cfinclude template="/wheelsmapping/tests/model/single_model.cfm">

	<cffunction name="test_select_distinct_addresses">
		<cfset loc.q = loc.user.findAll(select="address", distinct="true", order="address")>
		<cfset assert('loc.q.recordcount eq 4')>
		<cfset loc.e = "123 Petruzzi St.|456 Peters Dr.|789 Djurner Ave.|987 Riera Blvd.">
		<cfset loc.r = valuelist(loc.q.address, "|")>
		<cfset assert('loc.e eq loc.r')>
	</cffunction>
<!---
	TODO: uncomment once james' patch for group by is integrated
	<cffunction name="test_select_users_groupby_address">
		<cfset loc.q = loc.user.findAll(select="address", group="address", order="address", result="loc.result")>
		<cfset assert('loc.q.recordcount eq 4')>
		<cfset loc.e = "123 Petruzzi St.|456 Peters Dr.|789 Djurner Ave.|987 Riera Blvd.">
		<cfset loc.r = valuelist(loc.q.address, "|")>
		<cfset assert('loc.e eq loc.r')>
	</cffunction>
 --->
 
 	<cffunction name="test_findByKey">
		<cfset loc.q = loc.user.findByKey(1)>
		<cfset assert('loc.q.id eq 1')>
	</cffunction>
 
 	<cffunction name="test_findOne">
		<cfset loc.q = loc.user.findOne(order="id DESC")>
		<cfset assert('loc.q.id eq 5')>
	</cffunction>
 
 	<cffunction name="test_findAll">
		<cfset loc.q = loc.user.findAll()>
		<cfset assert('loc.q.recordcount eq 5')>
		<cfset loc.q = loc.user.findAll(where="lastname = 'petruzzi' OR lastname = 'peters'", order="lastname")>
		<cfset assert('loc.q.recordcount eq 2')>
		<cfset assert('valuelist(loc.q.lastname) eq "peters,petruzzi"')>
	</cffunction>
	
	<cffunction name="test_findOneByXXX">
		<cfset loc.q = loc.user.findOneByFirstname('per')>
		<cfset assert('loc.q.id eq 3')>
	</cffunction>
	
	<cffunction name="test_findAllByXXX">
		<cfset loc.q = loc.user.findAllByZipcode(value="22222", order="id")>
		<cfset assert('valuelist(loc.q.id) eq "2,5"')>
	</cffunction>
	
	<cffunction name="test_findByKey_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findByKey("0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findByKey(key="0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findByKey(key="0", returnas="objects")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isarray(loc.q) and arrayisempty(loc.q)')>
	</cffunction>
	
	<cffunction name="test_findOne_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findOne(where="id = 0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findOne(where="id = 0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findOne(where="id = 0", returnas="objects")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isarray(loc.q) and arrayisempty(loc.q)')>
	</cffunction>
	
	<cffunction name="test_findAll_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findAll(where="id = 0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isquery(loc.q) and loc.q.recordcount eq 0')>
		
		<cfset loc.q = loc.user.findAll(where="id = 0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findAll(where="id = 0", returnas="objects")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isarray(loc.q) and arrayisempty(loc.q)')>
	</cffunction>
	
	<cffunction name="test_exists_valid">
		<cfset fail()><commit_msg>Fixed test for "findOne norecords returns correct type". It now tests when you pass in returnAs="query". Removed test for passing in returnAs="objects" (only singular "object" is proper use for findOne).<commit_after><cfcomponent extends="wheelsMapping.test">

	<cfinclude template="/wheelsmapping/tests/model/single_model.cfm">

	<cffunction name="test_select_distinct_addresses">
		<cfset loc.q = loc.user.findAll(select="address", distinct="true", order="address")>
		<cfset assert('loc.q.recordcount eq 4')>
		<cfset loc.e = "123 Petruzzi St.|456 Peters Dr.|789 Djurner Ave.|987 Riera Blvd.">
		<cfset loc.r = valuelist(loc.q.address, "|")>
		<cfset assert('loc.e eq loc.r')>
	</cffunction>
<!---
	TODO: uncomment once james' patch for group by is integrated
	<cffunction name="test_select_users_groupby_address">
		<cfset loc.q = loc.user.findAll(select="address", group="address", order="address", result="loc.result")>
		<cfset assert('loc.q.recordcount eq 4')>
		<cfset loc.e = "123 Petruzzi St.|456 Peters Dr.|789 Djurner Ave.|987 Riera Blvd.">
		<cfset loc.r = valuelist(loc.q.address, "|")>
		<cfset assert('loc.e eq loc.r')>
	</cffunction>
 --->
 
 	<cffunction name="test_findByKey">
		<cfset loc.q = loc.user.findByKey(1)>
		<cfset assert('loc.q.id eq 1')>
	</cffunction>
 
 	<cffunction name="test_findOne">
		<cfset loc.q = loc.user.findOne(order="id DESC")>
		<cfset assert('loc.q.id eq 5')>
	</cffunction>
 
 	<cffunction name="test_findAll">
		<cfset loc.q = loc.user.findAll()>
		<cfset assert('loc.q.recordcount eq 5')>
		<cfset loc.q = loc.user.findAll(where="lastname = 'petruzzi' OR lastname = 'peters'", order="lastname")>
		<cfset assert('loc.q.recordcount eq 2')>
		<cfset assert('valuelist(loc.q.lastname) eq "peters,petruzzi"')>
	</cffunction>
	
	<cffunction name="test_findOneByXXX">
		<cfset loc.q = loc.user.findOneByFirstname('per')>
		<cfset assert('loc.q.id eq 3')>
	</cffunction>
	
	<cffunction name="test_findAllByXXX">
		<cfset loc.q = loc.user.findAllByZipcode(value="22222", order="id")>
		<cfset assert('valuelist(loc.q.id) eq "2,5"')>
	</cffunction>
	
	<cffunction name="test_findByKey_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findByKey("0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findByKey(key="0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findByKey(key="0", returnas="objects")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isarray(loc.q) and arrayisempty(loc.q)')>
	</cffunction>
	
	<cffunction name="test_findOne_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findOne(where="id = 0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findOne(where="id = 0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findOne(where="id = 0", returnas="query")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isquery(loc.q) and loc.q.recordcount eq 0')>
	</cffunction>
	
	<cffunction name="test_findAll_norecords_returns_correct_type">
		<cfset loc.q = loc.user.findAll(where="id = 0")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isquery(loc.q) and loc.q.recordcount eq 0')>
		
		<cfset loc.q = loc.user.findAll(where="id = 0", returnas="object")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isboolean(loc.q) and loc.q eq false')>
		
		<cfset loc.q = loc.user.findAll(where="id = 0", returnas="objects")>
		<cfset halt(false, 'loc.q')>
		<cfset assert('isarray(loc.q) and arrayisempty(loc.q)')>
	</cffunction>
	
	<cffunction name="test_exists_valid">
		<cfset fail()>
{'fraction_non_alphanumeric': 0.1869133451231125, 'fraction_numerical': 0.013467555434634744, 'mean_word_length': 4.862838915470494, 'pattern_counts': {'":': 0, '<': 153, '<?xml version=': 0, '>': 153, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '111252', 'n_tokens_mistral': 3212, 'n_tokens_neox': 2928, 'n_words': 570}