Needs review
Project:
Webform MySQL Views
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Feb 2012 at 22:31 UTC
Updated:
19 Dec 2012 at 18:34 UTC
Jump to comment: Most recent file
Comments
Comment #1
cafuego commentedAttached patch uses a small helper to generate unique column names for the view based on a webform field key, its parent (fieldset) key if set, and the component id. Additionally, it ensures this generated name is 64 characters or less, which is a hard column name length limit in MySQL.
Please test :-)
Comment #2
cafuego commentedThe patch is present in 6.x-2.x-dev, please give that a try.
Comment #3
millenniumtreeClone a webform so that two form components in different nodes have the same cid and form_key.
The CREATE VIEW will still fail.
The compound primary key on webform_component is (nid, cid), so in the LEFT JOIN pulling in form_keys, you need a bit more specificity.
- $result = db_query("SELECT c.cid, c.form_key, p.form_key AS parent_key FROM {webform_component} AS c LEFT JOIN {webform_component} AS p ON (c.pid = p.cid) WHERE c.nid = %d AND c.type != 'fieldset' ORDER BY c.weight ASC, c.cid ASC", $nid);
+ $result = db_query("SELECT c.cid, c.form_key, p.form_key AS parent_key FROM {webform_component} AS c LEFT JOIN {webform_component} AS p ON (c.pid = p.cid AND c.nid = p.nid) WHERE c.nid = %d AND c.type != 'fieldset' ORDER BY c.weight ASC, c.cid ASC", $nid);
and probably this as well on another line
- $result = db_query('SELECT c.cid, c.name, c.form_key, p.form_key AS parent_key, p.name AS parent, c.type FROM {webform_component} c LEFT JOIN {webform_component} p ON (c.pid = p.cid) WHERE c.nid = %d AND c.type = "date" ORDER BY c.weight ASC, c.cid ASC', $nid);
+ $result = db_query('SELECT c.cid, c.name, c.form_key, p.form_key AS parent_key, p.name AS parent, c.type FROM {webform_component} c LEFT JOIN {webform_component} p ON (c.pid = p.cid AND c.nid = p.nid) WHERE c.nid = %d AND c.type = "date" ORDER BY c.weight ASC, c.cid ASC', $nid);
Patch is attached - please test. The patch may have weird line numbers, and it's really just a diff -u. I hope that's acceptable.