From 8ff9e52cbefb5a3d017c3091c28b2ae048fcf4a9 Mon Sep 17 00:00:00 2001 From: Allan Chappell Date: Fri, 18 Jan 2013 11:04:17 -0600 Subject: [PATCH] [#1614234] Adding delta field to the database for cardinality > 1 --- views_natural_sort.install | 28 ++++++++++++++++++++++++++-- views_natural_sort.views.inc | 1 - 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/views_natural_sort.install b/views_natural_sort.install index 4a9ffa1..608ac97 100644 --- a/views_natural_sort.install +++ b/views_natural_sort.install @@ -34,6 +34,13 @@ function views_natural_sort_schema() { 'not null' => TRUE, 'default' => '', ), + 'delta' => array( + 'description' => t('The sequence number for this data item, used for multi-value fields'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), 'content' => array( 'description' => t('Filtered content used for sorting.'), 'type' => 'varchar', @@ -42,7 +49,7 @@ function views_natural_sort_schema() { 'default' => '', ), ), - 'primary key' => array('eid', 'entity_type', 'field'), + 'primary key' => array('eid', 'entity_type', 'field', 'delta'), ); return $schema; @@ -100,6 +107,12 @@ function views_natural_sort_update_7001() { module_load_include('inc', 'views_natural_sort', 'views_natural_sort.admin'); views_natural_sort_rebuild_index_submit(); } + +/** + * Impliments hook_update_N(). + * + * Upgrade the 7.x-1.x table structure to the 7.x-2.x table structure. + */ function views_natural_sort_update_7200() { db_drop_primary_key('views_natural_sort'); db_add_field( @@ -113,6 +126,17 @@ function views_natural_sort_update_7200() { 'default' => 'node' ) ); + db_add_field( + 'views_natural_sort', + 'delta', + array( + 'description' => t('The sequence number for this data item, used for multi-value fields'), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ) + ); db_change_field( 'views_natural_sort', 'nid', @@ -124,7 +148,7 @@ function views_natural_sort_update_7200() { 'not null' => TRUE, ), array( - 'primary key' => array('eid', 'entity_type', 'field'), + 'primary key' => array('eid', 'entity_type', 'field', 'delta'), ) ); } diff --git a/views_natural_sort.views.inc b/views_natural_sort.views.inc index 07f9230..5a7dc96 100644 --- a/views_natural_sort.views.inc +++ b/views_natural_sort.views.inc @@ -8,7 +8,6 @@ */ function views_natural_sort_views_data_alter(&$data) { - // TODO: Add a field and argument handler to support grouping. $data['node']['title']['sort']['handler'] = 'views_natural_sort_handler_sort'; } -- GitLab