/wheels/tests/model/crud/select.cfc
ColdFusion CFScript | 25 lines | 20 code | 5 blank | 0 comment | 0 complexity | 2ed7bff4ec6c89949bda0c62ee6be8bb MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
1<cfcomponent extends="wheelsMapping.Test">
2
3 <cffunction name="test_table_name_with_star_translates_to_all_fields">
4 <cfset loc.model = model("post") />
5 <cfset loc.r = loc.model.$createSQLFieldList(list="posts.*", include="", returnAs="query") />
6 <cfset loc.properties = loc.model.$classData().properties />
7 <cfset assert('ListLen(loc.r) eq StructCount(loc.properties)') />
8 </cffunction>
9
10 <cffunction name="test_wrong_table_alias_in_select_throws_error">
11 <cfset loc.model = model("post") />
12 <cfset raised('loc.model.$createSQLFieldList(list="comments.*", include="", returnAs="query")') />
13 </cffunction>
14
15 <cffunction name="test_association_with_expanded_aliases_enabled">
16 <cfset loc.columnList = ListSort(model("Author").$createSQLFieldList(list="", include="Posts", returnAs="query", useExpandedColumnAliases=true), "text")>
17 <cfset assert('loc.columnList eq "authors.firstname,authors.id,authors.lastname,posts.authorid AS postauthorid,posts.averagerating AS postaveragerating,posts.body AS postbody,posts.createdat AS postcreatedat,posts.deletedat AS postdeletedat,posts.id AS postid,posts.title AS posttitle,posts.updatedat AS postupdatedat,posts.views AS postviews"')>
18 </cffunction>
19
20 <cffunction name="test_association_with_expanded_aliases_disabled">
21 <cfset loc.columnList = ListSort(model("Author").$createSQLFieldList(list="", include="Posts", returnAs="query", useExpandedColumnAliases=false), "text")>
22 <cfset assert('loc.columnList eq "authors.firstname,authors.id,authors.lastname,posts.authorid,posts.averagerating,posts.body,posts.createdat,posts.deletedat,posts.id AS postid,posts.title,posts.updatedat,posts.views"')>
23 </cffunction>
24
25</cfcomponent>