/wheels/tests/model/crud/select.cfc

http://cfwheels.googlecode.com/ · ColdFusion CFScript · 25 lines · 20 code · 5 blank · 0 comment · 0 complexity · 2ed7bff4ec6c89949bda0c62ee6be8bb MD5 · raw file

  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_table_name_with_star_translates_to_all_fields">
  3. <cfset loc.model = model("post") />
  4. <cfset loc.r = loc.model.$createSQLFieldList(list="posts.*", include="", returnAs="query") />
  5. <cfset loc.properties = loc.model.$classData().properties />
  6. <cfset assert('ListLen(loc.r) eq StructCount(loc.properties)') />
  7. </cffunction>
  8. <cffunction name="test_wrong_table_alias_in_select_throws_error">
  9. <cfset loc.model = model("post") />
  10. <cfset raised('loc.model.$createSQLFieldList(list="comments.*", include="", returnAs="query")') />
  11. </cffunction>
  12. <cffunction name="test_association_with_expanded_aliases_enabled">
  13. <cfset loc.columnList = ListSort(model("Author").$createSQLFieldList(list="", include="Posts", returnAs="query", useExpandedColumnAliases=true), "text")>
  14. <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"')>
  15. </cffunction>
  16. <cffunction name="test_association_with_expanded_aliases_disabled">
  17. <cfset loc.columnList = ListSort(model("Author").$createSQLFieldList(list="", include="Posts", returnAs="query", useExpandedColumnAliases=false), "text")>
  18. <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"')>
  19. </cffunction>
  20. </cfcomponent>