Yet another post on cffeed and columnMap

I love to beat up on the cffeed tag. I mean I’m happy it was added to the language, but out of all the features in CF8, this one seemed to be the most flakey. Just look at the blog entries:

CFFEED and Date Values
Ask a Jedi: Handling RSS feeds with custom data
CFFEED Fixes in 8.0.1
Fun little feed parsing issue to watch out for - new lines!
CFFEED Tip - Structure versus Query
Metadata properties for CFFEED
Bug to watch out for with CFFEED
Columnmap Gotcha for CFFEED

Ok, so not all of those entries are complaining, but CFFEED is still my favorite tag to kick around. I ran into another problem this week with a user submitted question. He was using columnMap with CFFEED and kept getting:

There is a problem in the column mappings specified in the columnMap structure
The cffeed query does not contain any column by the name of CITY.

He was still on CF 8 with the upper case bug, but he was properly using upper case in his structure:

<cfquery name="xmlStateCities" datasource="#request.dsn.name#"> SELECT DISTINCT(city) as city ,SUM(population) AS population ,state FROM tbl_zip WHERE stateFullName = 'ALABAMA' GROUP BY city, state ORDER BY city ASC; </cfquery>

<cfset cmap = structNew()> <cfset cmap.city = “CITY”> <cfset cmap.state = “STATE”> <cfset cmap.population = “POPULATION”> <cfset cmap.siteurl = “SITEURL”> </code>

Everything looked right to me and I couldn’t figure out why CFFEED was saying the column didn’t exist in the query. Turns out it was a simple user error. If you are like me, you probably didn’t notice that in his column map structure, he used the same key name and value. Ie:

<cfset cfmap.city = “CITY“>

The error was not that that city didn’t exist in his source query. The error was that city wasn’t a valid value for the RSS query. This is a great example of how an exception message can either help you or send you down the wrong path. (And yes, I’ll file a bug report for this!) Here is the exception I would use. (Just writing this off the top of my head so pardon any misspellings/grammar issues etc.)

There is a problem in the column mappings specified in the columnMap structure
You tried to map to a column (CITY) that is not valid for RSS2.0 feeds. Please use one of (LIST HERE).

To be fair, some of the other new features of ColdFusion 8 have extremely well written exceptions. For example, if you try to read in an image and use an invalid file type, the exception message will a) tell you that it’s invalid and b) tell you to use getReadableImageFormats. That’s sweet.

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments