I am getting the following error on node, Views: page.
It occurred after making changes to Ubercart class and attribute settings. I have not amended the database or template files at all.

user warning: Unknown column 'node_data_field_image_cache.delta' in 'field list' query: SELECT node.nid AS nid, node.type AS node_type, node_data_field_image_cache.field_image_cache_fid AS node_data_field_image_cache_field_image_cache_fid, node_data_field_image_cache.field_image_cache_list AS node_data_field_image_cache_field_image_cache_list, node_data_field_image_cache.field_image_cache_data AS node_data_field_image_cache_field_image_cache_data, node_data_field_image_cache.nid AS node_data_field_image_cache_nid, node_data_field_image_cache.delta AS node_data_field_image_cache_delta, node.title AS node_title FROM node node LEFT JOIN content_field_image_cache node_data_field_image_cache ON node.vid = node_data_field_image_cache.vid WHERE (node.status <> 0) AND (node.type IN ('product','product_kit')) LIMIT 3, 30 in /home/mysite/drupal/sites/all/modules/views/includes/view.inc on line 731.

Multiple rows of this error on Ubercart catalog views:
user warning: Unknown column 'delta' in 'order clause' query: SELECT * FROM content_field_image_cache WHERE vid = 103 ORDER BY delta in /home/mtsite/drupal/sites/all/modules/cck/content.module on line 979.

#62 383330-keep-imagefield-settings.patch1.39 KBlongwave
PASSED: [[SimpleTest]]: [MySQL] 2,117 pass(es). View
#25 383330_global_field_settings.patch927 bytesIsland Usurper
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 383330_global_field_settings_0.patch. See the log in the details link for more information. View
#22 383330_global_field_settings.patch1.19 KBIsland Usurper
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 383330_global_field_settings.patch. See the log in the details link for more information. View
Members fund testing for the Drupal project. Drupal Association Learn more


La M’s picture

Title: 6.x-2.0-beta8 » Unknown column 'node_data_field_image_cache.delta'
NikLP’s picture

Did you run update.php, or even check that this version of the module would alter your database?

La M’s picture

Yes I ran an update. I didn't check about the database because it was a recommended install as part of ubercart, image.cache.

ismaiel’s picture

same problem

suersan’s picture

same here too,
even for additional image field does not fix the problem,
I delete the imagecache module along with the database part, then installed again, still same problem. Need help...
there are some suggestions over here, it did not work for me , maybe you are a lucky one.

InternetDevels’s picture


InternetDevels’s picture

I opened database and found that the table have not column 'delta', so I added it to table and resolved the problem.

drewish’s picture

Project: ImageCache » Ubercart
Version: 6.x-2.0-beta8 » 6.x-2.x-dev

this is totally not an imagecache issue. imagecache doesn't provide fields.

Island Usurper’s picture

Status: Active » Postponed (maintainer needs more info)

What version of Ubercart are you on? There have been some problems lately with Imagefield changing it's field settings so that Ubercart 2.x-beta5 doesn't provide the right values when it creates the default image field.

asak’s picture

I'm getting this error after trying to upload an image to a product:

user warning: Unknown column 'delta' in 'order clause' query: SELECT * FROM content_field_image_cache WHERE vid = 3 ORDER BY delta in /home/..../public_html/gold/sites/all/modules/cck/content.module on line 987

Ubercart 6.x-2.0-beta6
Imagefield 6.x-3.0-rc1
Filefield 6.x-3.0-rc1
Imagecache 6.x-2.0-beta8

asak’s picture

And this one:

# user warning: Unknown column 'delta' in 'field list' query: INSERT INTO content_field_image_cache (vid, nid, delta, field_image_cache_fid, field_image_cache_list, field_image_cache_data) VALUES (3, 3, 0, 13, 1, 'a:2:{s:3:\"alt\";s:21:\"חנות\";s:5:\"title\";s:21:\"חנות\";}') in /home/.../public_html/gold/sites/all/modules/cck/content.module on line 1207.

Island Usurper’s picture

Assigned: La M » Unassigned
Priority: Critical » Normal

Under the Manage fields page, do the settings for field_image_cache say you can have multiple values? It looks like CCK expects it to, though the database table wasn't created that way for some reason.

NikLP’s picture

Some of that sounds like someone has jumped versions or not run their update.php properly...

asak’s picture

Thank you guys... i outta be spanked ;)

Island Usurper’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Does that mean nothing needs to be done here? If there's a solution, post it and mark this as "fixed".

BenK’s picture

Status: Closed (won't fix) » Needs review

I had the same problem. I solved it by changing the global settings "number of values" for the imagefield to "1", saving the node, and then changing it back to "Unlimited." I'm not sure why that works, but the issue hasn't surfaced again since. Since these are global values, you only need to do it on one instance of imagefield (field_image_cache).

Hope this helps.... before I solved this, it wasn't letting me save any images to a product node.


Island Usurper’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dan3h’s picture

I also had the same problem. The solution posted in comment #16 worked like a charm for me. Thanks, BenK!

John Carbone’s picture

Huh... ran into a very similar message when working with noderef: "user warning: Unknown column 'delta' in 'order clause' query: SELECT * FROM content_field" ... yada yada... totally unrelated to UC, but comment 16 fixed it for me too. Thanks! Just to clarify for anyone else that might find this, I think he meant to say to change the settings on the content type and save it, not the node. : )

ericduran’s picture

Version: 6.x-2.x-dev » 6.x-2.0-rc7
Status: Closed (fixed) » Active

Sorry for setting this issue back to active. But the problem is in the way Ubercart set up new classes.

So here's my set-up
-Ubercart 6.x-2.0-rc7
-Drupal 6.14
-....(All Latest modules)

Here's how you can duplicate the error.
1. Go into the default product content type - and modified the image field and set the Number of Values to be 1.
2. Create product nodes with images on then.
3. Create a new product class in ubercart.
4. Now the nodes you created should loose their images.

That should be all that's require to duplicate the error.

So here's what I go so far
When the new product class is created the uc_product_class_form_submit function is call which calls the uc_product_add_default_image_field function.

In the uc_product_add_default_image_field function a new instance of an image_field is attached. You can see the code below.

    $instances = content_field_instance_read(array('field_name' => $field_name, 'type_name' => $type));

    if (count($instances) < 1) {
      // Only add the field if it doesn't exist. Don't overwrite any changes.

The checking is just there to avoid overwritten the settings when updating a class.

The real problem is when the field array is being created

  $field = array(
    'label' => $label,
    'type' => 'filefield',
    'widget_type' => 'imagefield_widget',
    'weight' => -2,
    'file_extensions' => 'gif jpg png',
    'custom_alt' => 1,
    'custom_title' => 1,
    'description' => '',
    'required' => 0,
    'multiple' => '1',
    'list_field' => '0',
    'list_default' => 1,
    'description_field' => '0',

As you can see above the global settings such as required, multiple, list_field, list_default, and description field are set in the new instance array. Which in turns are applied when then content_field_instance_create function is call with the $field parameter.

So what happens is that every time a new class is created the global settings are reapply and the field table gets re-setup. Which cause you to loose that data. Which sucks. :-(

So there's the problem.

A quick-fix is just commenting the global settings. I know this works once you have the "product" node set up. But I don't know what the consequence will be if it's a clean install and the uc_product_enable function is call.

Island Usurper’s picture

Status: Active » Needs review
1.19 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 383330_global_field_settings.patch. See the log in the details link for more information. View

It seems there's quite a lot in that field definition that we don't need. Here's a patch to take it out. I haven't tested the case where it creates a brand new image field, but I'll get to that next.

Island Usurper’s picture

Status: Needs review » Needs work

Dang. It looks like it wants to list the files through CCK when the field is added afresh. That's not good for the initial field settings, but I can imagine some reasons why someone would change that for their product images.

ericduran’s picture

You can just put an if for the 1st time the field is getting creating and add the list_field then just leave it out after. I'll submit a patch tomorrow.

Island Usurper’s picture

Status: Needs work » Needs review
927 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 383330_global_field_settings_0.patch. See the log in the details link for more information. View

Actually, since display_settings are per-instance settings, I can leave them in the $field. Give this patch a test install. I've been using drush to disable/enable the modules quickly. Make sure you actually remove the field first, if you do that.

Bilmar’s picture


josi123’s picture

Version: 6.x-2.0-rc7 » 6.x-2.2

Some problem. #16 fixed. The bug is there in latest version of ubercart. Also image field is created with no label and 'files' as default path.

jrefano’s picture

same issue, #16 fixes for me as well

weblance’s picture

thanks ben. #16 did not work for me at first but when I stood on one leg and barked like a cat it worked like charm.

p4trizio’s picture

Hi Jeff, I was very skeptic about #16 but I gave it a try and it amazingly worked.
Believe in it!!! :D
PS. I'm using the latest versions (Drupal 6.15, Ubercart 2.2, cck 2.6, imagecache 2.0-beta10)

weblance’s picture

No it worked for me too. I just think it is funny and reminds me of when the Fonz hits the jukebox or in the 60's when hitting the TV got the picture to stop fluttering. Just making light of the fix. It is actually an amazing find. I don't know how people figure that stuff out. Didn't mean to sound cynical.

p4trizio’s picture

Actually I found it funny too, anyway Ben was a genius ;-)

dbeall’s picture

#16,, works for me, I would never have tried that, thanks

noslokire’s picture

Boo to this bug, #16 worked for me as well!

freelock’s picture

I suspect this is really a CCK issue, related to sharing a field across multiple content types. A few weeks ago we tracked down this bug: #671708: Repeating date should be a different date type by stepping through the debugger, and basically found that CCK would alter the underlying table in the database whenever you saved the field definition on a content type. So whichever content type you looked at last could actually delete data in the same field, in other content types!

I'm not sure this is the problem here, but I really suspect it's the same bug. In our case, we started getting this error (and images disappeared) when we enabled the Product Kit module. Suddenly the field_image_cache was no longer unlimited in all content types it appeared in, and the image queries broke with this error. That would explain why changing the number of instances (twice) would repair it -- though you would lose any additional images.

Can anybody confirm?

markagray’s picture

I'd like to try #16 but I'm not certain that I am doing it correctly. We have lost all of the images that we had attached to our products and our product kits. I tried this

1. Go to Home → Administer Site → Content management → Product
2. Pull down "Image Attach Settings"
3. Changed "Maximum Number of Images" from Unlimited to 1.
4. Save content type.
5. Repeat steps 1 through 4, changing 1 to Unlimited.
6. Repeat steps 1 through 5 for two product classes we created.
7. Repeat steps 1 through 6 for Product Kits.

These changes had no effect so I tried:

8. Go to Home → Administer Site → Site building → ImageCache
9. Flushed all listed image caches.

This had no effect so I tried:

10. Go to Home → Administer Site → Site configuration → Performance
11. Clicked on "Clear cached data".

This had no effect.

Were steps 1 through 5 the correct steps for the #16 fix?

markagray’s picture

Update to #36.

1. Go to Home → Administer Site → Content management → Product
2. Clicked on the Configure link for field_image_cache.
3. Performed the workaround described in #16.

It worked!

Thanks BenK!

TR’s picture

So is anyone going to try out the patch in #25 and report on it? The "workaround" in #16 isn't a fix to Ubercart, doesn't get this issue any closer to being resolved, and doesn't keep other people from encountering the same problem.

If you are one of the people experiencing this problem, the community needs to test the patch and let us know whether that fixes things. Only when the patch has been show to work without causing other problems will it be committed to Ubercart.

victoria_b’s picture

#16 worked for me too. What a life saver!

Nice work Ben.


markagray’s picture


I'll try the patch. To test it, what would I do before and after applying the patch? For example, would I remove the images from the products, apply the patch, then add the images back to the products?

robby.smith’s picture


AlexisWilke’s picture

Title: Unknown column 'node_data_field_image_cache.delta' » Product Kit is missing the Image field! (Unknown column 'node_data_field_image_cache.delta')
Version: 6.x-2.2 » 6.x-2.x-dev
Issue tags: +product_kit, +invalid sql

This is a problem with the fact that at this time the Product Kit does not have an image fieldset like the standard product has.

Somehow, I have not seen those errors in my logs or on screen but it is a problem for me since I show a list of software for sale and all the bundles do not include the field.

I did not read all the comments, but patches in #22 and #25 have nothing to do with improving the software. It just removes the SQL error. We'd need to add the field to the product kit table and the code in the node edit page so we can have an image. 8-)

Maybe I'll do that later, although right now I have a few other problems to work on...

dmurray’s picture

I had the same issue as documented here, #16 fixed the errors but did result in all the images being lost :(

scotself’s picture

Definitely causing some folks some issues...glad for #16's work-around though!! Whewww!

cha0s’s picture

The workaround from a year ago helped me as well! Sometimes I just can't keep up with this fast-moving open source stuff...

csc4’s picture

I've just hit this problem with a clean install - and part of the issue seemed to be that the Product image had files as the directory which was throwing an error so I had to change that as well as performing the changes in #16

colorado’s picture

Thank you for posting this fix! This worked for me as well.

dejavu007’s picture

Issue tags: +Ubercart

Post #16 Hack fixed it...... Thanks

perusio’s picture

Hmm. For me the solution was much simpler than the one outlined in #16 and #36. I created additional product classes and somehow the field became multivalued instead of a single value field. I went into the "master" product content type and set it to single value. Voilá: problem solved!

shotokai’s picture

I had the same problem, and I did run update.php (over and over). The issue however was update.php related.
The version update on the uc_product module was not being picked up correctly, so I had to set it manually. That fixed the issue for me.

Jimmel’s picture

#49 works fine for me with the ubercart creating classes problem.

leovw’s picture

Hi Just wanted to say thanks and let people know that applying the patch in #22 let me create new classes without losing my images!

rgs’s picture

BenK rocks. Will have to try the patch.

isimo’s picture

I had this problem and none of the fixes worked. I wanted to stipulate 1 image rather than multiple. I realised i had a relationship on the image fid on the 'views - > relationships' which i don't suppose is needed on a single image value. I deleted this and it has started to work.

TR’s picture

Status: Needs review » Active
Issue tags: -Ubercart, -product_kit, -invalid sql
TR’s picture

Untagging and changing status.

extensive’s picture

Make image_cache amount from 1 to unlimited the error has gone for me!

TR’s picture

Component: Code » Product kits

Moving to "Product kit" component.

longwave’s picture

Agreeing with freelock in #35 - I suspect this is an obscure bug in CCK that only occurs when sharing fields between content types, and when those fields are created programmatically rather than in the UI. I have seen similar issues in Features and there are a couple of bug reports in Date about the same thing. Tracking down the offending piece of code seems very difficult, though.

longwave’s picture

From #1830752: Creating New Product Class Makes Images in Existing Products Vanish, if ImageField is not set to Unlimited

How to reproduce: Create at least one product class in Ubercart. Change the content type to allow exactly one image per product rather than the default "unlimited". Add a few products, each with an image attached. Create a new product class. All the images in existing products will no longer show up because of a broken SQL statement. The root cause is that inserting a new product class will overwrite the existing field definition and thus create the invalid SQL for any previously inserted products.

The function uc_product_add_default_image_field() should instead test whether the field already exists and if it does, honor the current settings. If it does not exist, it can follow the current strategy and insert a new field with reasonable defaults.

adijeff’s picture

A year later, #49 worked for me. Thanks perusio.

longwave’s picture

Status: Active » Needs review
1.39 KB
PASSED: [[SimpleTest]]: [MySQL] 2,117 pass(es). View

Finally, thanks to the steps listed in #60, I think I have a patch that solves this. This ensures that if a field instance already exists, we copy the settings from the existing field, rather than always trying to reset it to "unlimited".

longwave’s picture

Status: Needs review » Fixed

Committed. After applying the patch in #62, the steps in #60 no longer produce an error, and the newly added product class has an image field set to 1 image rather than unlimited.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Jenechka’s picture

Thank you Eric!