<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Case-insensitive ordering with Django and PostgreSQL</title>
	<atom:link href="http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/</link>
	<description>Code and comments on web development, Django, Python and things (un)related.</description>
	<lastBuildDate>Wed, 16 May 2012 20:44:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: raman</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-1086</link>
		<dc:creator>raman</dc:creator>
		<pubDate>Sat, 04 Feb 2012 18:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-1086</guid>
		<description>Depending on your table size/need for efficiency, another method is to create a &#039;sort&#039; field on your table.  Example:
&lt;pre&gt;
class FoodItem(models.Model)
  	name = models.CharField(max_length=255)
  	sort_name = models.CharField(max_length=255, blank=True)
	
	def save(self):
		if self.name:
        	        self.name = self.name.strip()
			self.sort_name = self.name.lower()
                else:
			self.sort_name = &#039;&#039;
			
		super(FoodItem, self).save()
		&lt;/pre&gt;
Then the ordering would be:

l = FoodItem.objects.all().order_by(&#039;sort_name&#039;)</description>
		<content:encoded><![CDATA[<p>Depending on your table size/need for efficiency, another method is to create a &#8217;sort&#8217; field on your table.  Example:</p>
<pre>
class FoodItem(models.Model)
  	name = models.CharField(max_length=255)
  	sort_name = models.CharField(max_length=255, blank=True)

	def save(self):
		if self.name:
        	        self.name = self.name.strip()
			self.sort_name = self.name.lower()
                else:
			self.sort_name = ''

		super(FoodItem, self).save()
		</pre>
<p>Then the ordering would be:</p>
<p>l = FoodItem.objects.all().order_by(&#8217;sort_name&#8217;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MMusashi</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-1019</link>
		<dc:creator>MMusashi</dc:creator>
		<pubDate>Mon, 18 Apr 2011 07:27:41 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-1019</guid>
		<description>Thanks a lot !!
Love this solution.</description>
		<content:encoded><![CDATA[<p>Thanks a lot !!<br />
Love this solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ram</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-1011</link>
		<dc:creator>ram</dc:creator>
		<pubDate>Mon, 14 Mar 2011 07:18:21 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-1011</guid>
		<description>Great Solution, Is it works with foreignkey values?
Forexample:

Class A(models.Model):
    name = models.CharField(max_length = 50)
    .....

Class B(models.Model):
    a = models.ForeignKey(A)
    .....


Now i want to order the all &quot;b&quot; objects based on &quot;a__name&quot;. Is this is possible?
Can any one help me.</description>
		<content:encoded><![CDATA[<p>Great Solution, Is it works with foreignkey values?<br />
Forexample:</p>
<p>Class A(models.Model):<br />
    name = models.CharField(max_length = 50)<br />
    &#8230;..</p>
<p>Class B(models.Model):<br />
    a = models.ForeignKey(A)<br />
    &#8230;..</p>
<p>Now i want to order the all &#8220;b&#8221; objects based on &#8220;a__name&#8221;. Is this is possible?<br />
Can any one help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LC CLS Ron</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-905</link>
		<dc:creator>LC CLS Ron</dc:creator>
		<pubDate>Mon, 29 Nov 2010 05:15:53 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-905</guid>
		<description>Ok, you&#039;ll have to read . between . the . lines. Most &lt; (less than) and &gt; (greater than) are missing.</description>
		<content:encoded><![CDATA[<p>Ok, you&#8217;ll have to read . between . the . lines. Most &lt; (less than) and &gt; (greater than) are missing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: LC CLS Ron</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-904</link>
		<dc:creator>LC CLS Ron</dc:creator>
		<pubDate>Mon, 29 Nov 2010 05:11:28 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-904</guid>
		<description>Yes, unless just released a new version with collation support, what users are requesting to be able to control (override) this:

&#039;AAA&#039;  false in collations where sort order is like aaa AAA bbb BBB ... (dictionary sort order)
&#039;AAA&#039;  true in collations where sort order is like AAA ... ZZZ aaa ... ZZZ (binary)

It is VERY important to be able to override ANY operator to a given collation. In my experience, most databases do allow this.

for example:

&#039;AAA&#039; &lt; &#039;aaa&#039; collate SQL_Latin1_General_CP1_CS_AS
  CS = case sensitive
  AS = accent sensitive

&#039;AAA&#039; &lt; &#039;aaa&#039; collate SQL_Latin1_General_CP1_CI_AS
  CI = case insensitive
  AS = accent sensitive

or Oracle&#039;s nls_sort() for example. 

Also, these databases can be told what collation to use at various levels including per db/table/statement so on.

I find this VITALLY important. So postgreSQL, I suggest very strongly that you do work on this.
Depending on LC_XXX is okay for default, but you must be able to override as far down as to the:

=   = != operators
sort by clauses
like operations
so on...

Check out Oracle, SQL Server, MySql, so on... they all have it.

Cheers,
Ron Lentjes
LC CLS</description>
		<content:encoded><![CDATA[<p>Yes, unless just released a new version with collation support, what users are requesting to be able to control (override) this:</p>
<p>&#8216;AAA&#8217;  false in collations where sort order is like aaa AAA bbb BBB &#8230; (dictionary sort order)<br />
&#8216;AAA&#8217;  true in collations where sort order is like AAA &#8230; ZZZ aaa &#8230; ZZZ (binary)</p>
<p>It is VERY important to be able to override ANY operator to a given collation. In my experience, most databases do allow this.</p>
<p>for example:</p>
<p>&#8216;AAA&#8217; &lt; &#039;aaa&#039; collate SQL_Latin1_General_CP1_CS_AS<br />
  CS = case sensitive<br />
  AS = accent sensitive</p>
<p>&#039;AAA&#039; &lt; &#039;aaa&#039; collate SQL_Latin1_General_CP1_CI_AS<br />
  CI = case insensitive<br />
  AS = accent sensitive</p>
<p>or Oracle&#039;s nls_sort() for example. </p>
<p>Also, these databases can be told what collation to use at various levels including per db/table/statement so on.</p>
<p>I find this VITALLY important. So postgreSQL, I suggest very strongly that you do work on this.<br />
Depending on LC_XXX is okay for default, but you must be able to override as far down as to the:</p>
<p>=   = != operators<br />
sort by clauses<br />
like operations<br />
so on&#8230;</p>
<p>Check out Oracle, SQL Server, MySql, so on&#8230; they all have it.</p>
<p>Cheers,<br />
Ron Lentjes<br />
LC CLS</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave Naffziger</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-735</link>
		<dc:creator>Dave Naffziger</dc:creator>
		<pubDate>Tue, 27 Oct 2009 20:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-735</guid>
		<description>Great solution, super helpful.  Thanks for posting it.

It might be helpful also to know that Wikipedia moved the page you linked to about different SQL dialects. The new page is: 
http://en.wikibooks.org/wiki/SQL_Dialects_Reference/Functions_and_expressions/String_functions

It looks like the syntax is ok unless for some reason we want to switch to Virtuoso =)</description>
		<content:encoded><![CDATA[<p>Great solution, super helpful.  Thanks for posting it.</p>
<p>It might be helpful also to know that Wikipedia moved the page you linked to about different SQL dialects. The new page is:<br />
<a href="http://en.wikibooks.org/wiki/SQL_Dialects_Reference/Functions_and_expressions/String_functions" rel="nofollow">http://en.wikibooks.org/wiki/SQL_Dialects_Reference/Functions_and_expressions/String_functions</a></p>
<p>It looks like the syntax is ok unless for some reason we want to switch to Virtuoso =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-698</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Thu, 16 Jul 2009 08:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-698</guid>
		<description>Very nice. A great simple solution.</description>
		<content:encoded><![CDATA[<p>Very nice. A great simple solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DjangoGuy</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-581</link>
		<dc:creator>DjangoGuy</dc:creator>
		<pubDate>Thu, 13 Nov 2008 16:02:56 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-581</guid>
		<description>Thanks for the hint. It is quite useful!</description>
		<content:encoded><![CDATA[<p>Thanks for the hint. It is quite useful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sundance</title>
		<link>http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/comment-page-1/#comment-126</link>
		<dc:creator>Sundance</dc:creator>
		<pubDate>Wed, 21 Nov 2007 09:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://scottbarnham.com/blog/2007/11/20/case-insensitive-ordering-with-django-and-postgresql/#comment-126</guid>
		<description>Ayup: Postgres doesn&#039;t support &lt;a href=&quot;http://en.wikipedia.org/wiki/Collation&quot; rel=&quot;nofollow&quot;&gt;collations&lt;/a&gt;. It &lt;i&gt;claims&lt;/i&gt; to, but in truth, as far as I know, what it does is simply to use the OS-level LC_COLLATE variable (or a delegate thereof like LC_ALL) to its sorting functions and consider it a done deal. So it&#039;s impossible to have per-database, or per-table, or, heavens forbid, per-column collations, as in, you know... other RDBMS.

This is easily the biggest wart in this otherwise wonderful RDBMS and I WISH they&#039;d stop pretending they support collations. For all intents and purposes, they don&#039;t.</description>
		<content:encoded><![CDATA[<p>Ayup: Postgres doesn&#8217;t support <a href="http://en.wikipedia.org/wiki/Collation" rel="nofollow">collations</a>. It <i>claims</i> to, but in truth, as far as I know, what it does is simply to use the OS-level LC_COLLATE variable (or a delegate thereof like LC_ALL) to its sorting functions and consider it a done deal. So it&#8217;s impossible to have per-database, or per-table, or, heavens forbid, per-column collations, as in, you know&#8230; other RDBMS.</p>
<p>This is easily the biggest wart in this otherwise wonderful RDBMS and I WISH they&#8217;d stop pretending they support collations. For all intents and purposes, they don&#8217;t.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.220 seconds -->

