Hi,

I currently have a table, which takes textarea submissions from webform into views. However, the textarea has a limit of 250 words but the data table uses varchar and 341 characters so is not showing all of the submissions.

Can I simply can the field type in phpmyadmin? I've tried changing it in the Drupal back end but it says: Cannot change field.

This is the export of the table if that helps

$data_table = new stdClass;
$data_table->disabled = FALSE; /* Edit this to true to make a default data_table disabled initially */
$data_table->api_version = 1;
$data_table->title = 'Webform views online application form';
$data_table->name = 'webform_views_online_application_form';
$data_table->table_schema = array(
  'description' => 'VIEW',
  'fields' => array(
    'sid' => array(
      'type' => 'int',
      'size' => 'normal',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
      'description' => '',
    ),
    'uid' => array(
      'type' => 'int',
      'size' => 'normal',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
      'description' => '',
    ),
    'killer_question_1_answer' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'killer_question_2_answer' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'killer_question_3_answer' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'killer_question_4_answer' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'killer_question_5_answer' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'job_reference' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'job_title' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '341',
      'not null' => FALSE,
      'description' => '',
    ),
    'submitted' => array(
      'type' => 'datetime',
      'size' => 'normal',
      'not null' => FALSE,
      'description' => '',
    ),
    'remote_addr' => array(
      'type' => 'varchar',
      'size' => 'normal',
      'length' => '128',
      'not null' => FALSE,
      'description' => '',
    ),
  ),
  'name' => 'webform_views_online_application_form',
);
$data_table->meta = array(
  'join' => array(
    'webform_submissions' => array(
      'left_field' => 'sid',
      'field' => 'sid',
      'inner_join' => '0',
    ),
    'users' => array(
      'left_field' => 'uid',
      'field' => 'uid',
      'inner_join' => '0',
    ),
  ),
);

Comments

netivajak’s picture

Looking into this with KC and determined the issue to be with the group_concat_max_len. Setting this to a higher value (e.g. 8192) than the 1024 default allows larger fields (e.g. textareas) to return the whole value.

However I note around line 340 of webform_mysql_views.module that there is a note in the function webform_mysql_views_build_query that there is a workaround in place to avoid problems with the 1024 group_concat_max_len default. This workaround appears not to be working - at least in this particular instance.

As noted in the module file, one resolutions is to use something like the following in my.cnf:

[mysqld]
group_concat_max_len = 8192

But of course that's not going to be helpful for everyone.

I've tried changing the webform_mysql_views_build_query function to set group_concat_max_len without success - any thoughts?

cafuego’s picture

Status: Active » Postponed (maintainer needs more info)

You can change the size limit on the text field using hook_form_alter() or by copying the webform textfield component to a custom one and using that instead. I'm assuming you're unable to add 341 characters on the webform?

ydahi’s picture

Any update on this?

I'm using 7.x-1.0 and running into the same issue.

The textarea in my webform is being used to hold a large list of names. However, it seems that the column is set to varchar(341) and cannot be changed.

There are two things to note:

(1) When viewing the submission (i.e. node/*/submission/*), all of the input is visible, ie. there is no cut off
(2) When using Views-3 to display the field, only a limited amount of the input is shown

Any help would be greatly appreciated.

cafuego’s picture

Status: Postponed (maintainer needs more info) » Active

Ok, your issue is definitely because of the default lower value for group_concat_max_len then.

cafuego’s picture

Version: 6.x-1.2 » 7.x-1.0
Status: Active » Needs review

The only way to fix your issue is by setting group_concat_max_len in the mysql server configuration, or by passing a setting when Drupal connects to the database.

According to #1309278: Make PDO connection options configurable the latter is now possible in Drupal 7.

So what you need to do is add some configuration to your settings.php file. Specifically, you need to add init_commands to the SQL section of the file:

$databases['default']['default']['init_commands'] = array(
  'group_concat' => 'SET group_concat_max_len=8192',
);

.. see how you go and please let us know. We can then update the docs.

aganz’s picture

#5 works like a charm, great solution for people without root access

cafuego’s picture

Status: Needs review » Reviewed & tested by the community
cafuego’s picture

Status: Reviewed & tested by the community » Closed (fixed)
wdseelig’s picture

Version: 7.x-1.0 » 6.x-1.3

This issue is not completely fixed -- at least not as of 6.x-1.3.

If you can't change group_concat_max_len [and godaddy will not let me do so] then you have no way of getting around this problem.

EXCEPT. The place in the webform_mysql_views module that retrieves the webform data is around line 352 and contains the following code:

$component = sprintf("(SELECT GROUP_CONCAT (data) FROM {webform_submitted_data} AS child WHERE child.sid = parent.sid AND cid = %d) AS `%s`, ", $row['cid'], $row['form_key']);

Simply remove the GROUP_CONCAT from this code, and you'll find that the table stores the data as a longtext instead of a varchar(341).

Bigger point: Why would be need to be doing a GROUP_CONCAT anyway? For a given (sid,cid) combination there would only be ONE data field, right??

argol_0’s picture

#9 Excellent solution thanks for the help, very useful

michaellenahan’s picture

#9 Thank you.

My specific problem was with a webform view (supplied by the webform_view module), where the data was being truncated at 341 characters, but this approach should work with other fields where the data is being truncated.

As suggested at #9, I removed the GROUP_CONCAT for the field, and now I get a mediumtext field in mysql instead of a varchar(341).

(I also wonder whether the GROUP_CONCAT is necessary at all).

    switch ($row->type) {
      //Collapse grid values in a string of key=val pairs
      case 'grid':
        $component = sprintf("(SELECT GROUP_CONCAT(no,'=',data) FROM {webform_submitted_data} AS child WHERE child.sid = parent.sid AND cid = %d) AS `%s`, ", $row->cid, $row->form_key);
        break;

      // Remove varchar(341) restriction on webform view field.
      case 'view':
        $component = sprintf("(SELECT data FROM {webform_submitted_data} AS child WHERE child.sid = parent.sid AND cid = %d) AS `%s`, ", $row->cid, $row->form_key);
        break;

      //Otherwise collapse multi-value fields into simple comma-separated lists
      default:
        $component = sprintf("(SELECT GROUP_CONCAT(data) FROM {webform_submitted_data} AS child WHERE child.sid = parent.sid AND cid = %d) AS `%s`, ", $row->cid, $row->form_key);
    }
michaellenahan’s picture

Title: Varchar vs text » varchar 341 character length restriction
StatusFileSize
new1.13 KB

Here is a patch.

xamanu’s picture

Version: 6.x-1.3 » 7.x-1.1
Status: Closed (fixed) » Needs review

As this is still an issue for the Drupal 7 version of this module I reopen this issue with update meta tags. Please review and commit to the module. Thanks.

akshita’s picture

Hi michaellenahan

Your patch did not work. I just changed the Case 'view' to case 'textarea' and that worked.

But there is another problem.

For the comment field:

The longest text appears empty but when you copy it into Notepad it is all there .

I wonder if a size limit should be put in place?

The patch changed the Comment field (textarea) from varchar(341) to mediumtext.

Thanks
Rev

quindio’s picture

About 2 years ago I ran into the problem of the 341 chars and #9
worked then but I tried today and it did not worked any more.

OK, I managed to by pass this problem by doing the following,
Since I already do a query that gets the information from the
webform_mysql_views table:

$query = "SELECT sid, uid FROM { webform_views_name_of_form } ;
while ($r = db_fetch_array($query))

To get the information from the 'data' field in the webform_submitted_data,
I use the returned sid ($r['sid']) from my first query and the cid=8
(in my case I had 14 fields in my form, and the 8th field is the one with the information I needed)

/***************/
$query2 = sprintf("SELECT data FROM { webform_submitted_data } AS child WHERE child.cid=8 and sid=%d", $r['sid']);
$q2 = db_query($query2);
$r2 = db_fetch_array($q2);
//print($r2['data']);
/****************/

This is working for me but if you guys see a problem, let me know.

Thanks,