This is a continuation of the issue for a previous version: https://drupal.org/node/2008470

As in that case, longer text fields are not handled well:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'content' at row 1: INSERT INTO {views_natural_sort} .. etc...

As in that case, a similar solution proposed works, to avoid using a varchar field.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wyrdwright’s picture

generalredneck’s picture

Good call.

My other patch in #2008470: incompatibility actually has an extra bit from another patch I did for another user. My bad. Thanks for the do-over.

ElusiveMind’s picture

Why are we truncating the title? What if we wish to display the Natural View instead of the node title? This would be problematic. Here is a patch that increases the size of the content field to a text field of normal size.

This patch is based off the current 1.4 stable branch

generalredneck’s picture

Test is a data type?

Probably meant text.

Here's the deal with sorting text vs using a varchar.

http://nicj.net/mysql-text-vs-varchar-performance/

This is one thing I won't change. Besides showing the natural sorted transformed string is not possible at the moment as there is no field handler... lastly it's transformed to mimic natural sorting and particularly in the case of numbers.... uglier than sin.

ElusiveMind’s picture

Here is a patch for the 2.0 branch

ElusiveMind’s picture

I'm not certain by what you mean not showing the transformed string. I am able to show the Node Title: Natural as per the view options. Is this somehow calculated differently? Maybe I'm misunderstanding something.

ElusiveMind’s picture

I'm not certain by what you mean not showing the transformed string. I am able to show the Node Title: Natural as per the view options. Is this somehow calculated differently? Maybe I'm misunderstanding something.

generalredneck’s picture

FileSize
48.65 KB

In the 1.4 branch you can show it as you can see via views_natural_sort.views.inc30.

The 2.0 branch doesn't allow you to do that as only a sort handler is included. Also the Natural Sorted strings are indeed calculated and look like the following to achieve natural sorting title is the node title and content is the natural sorted version. Notice the words The, An, A and others are removed, and that numbers are encoded such that they will sort 1,2,10 instead of 1,10,2:

generalredneck’s picture

@wyrdwright Sorry it took so long to get this in but I took your fix and committed it. I modified it with some of my own comments and also back ported it to the 1.x branch.

You can see what I've done via
http://drupalcode.org/project/views_natural_sort.git/commit/dc247e9586e4...
and
http://drupalcode.org/project/views_natural_sort.git/commit/5b9ffc3af76c...

generalredneck’s picture

Issue summary: View changes
Status: Active » Closed (fixed)