pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter J. Holzer <hjp-pgsql@hjp.at>
To: pgsql-general@lists.postgresql.org
Subject: Re: Set COLLATE on a session level
Date: Fri, 11 Dec 2020 10:30:42 +0100
Message-ID: <20201211093041.GA25192@hjp.at> (raw)
In-Reply-To: <17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de>
References: <0DDE56FB-89A8-4621-BF5E-8CE3461F4983@mikatiming.de>
	<9fd0eef06639e633e258461e5baad9734bcbc1ba.camel@cybertec.at>
	<F4E0491C-0312-433D-9C5F-44730A43224B@mikatiming.de>
	<CAFj8pRAk21ke-CQ5mDg8wAk2W=oc7fM6_9JvAvpbBOnJDz+kPQ@mail.gmail.com>
	<20201120144717.GD5091@hermes.hilbert.loc>
	<17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de>

On 2020-11-30 10:11:38 +0000, Dirk Mika wrote:
> > > pá 20. 11. 2020 v 15:28 odesílatel Dirk Mika <Dirk.Mika@mikatiming.de>
> > > napsal:
> > > > Let's assume there is an app that accesses the same database from
> > > > different countries. And in this app data should be displayed ordered. And
> > > > the sort order is not identical in all countries.
> > > >
> > > > Does the app have to send different SQL commands depending on the country?
> > > > Not nice.
> > > > Do the data have to be sorted in the app? Not nice either.
> > > >
> > >
> > > the query is the same - you just use a different COLLATE clause. For
> > > Postgres there is not any other way.
[...] 
> Suppose the SQL statements are generated by a database layer such as
> Hibernate. It seems to me that it is not possible to use a function
> that adds the COLLATE clause.

It seems to me that this is a defect in the ORM. Sorting by current
locale rules is important for many applications, so that is something an
ORM should support. How the ORM does it (setting a session parameter,
modifying the query, ...) may be backend-specific and not something the
programmer should worry about.

That said, I don't even know if Django (the only ORM I've used in any
depth) does that.

I also agree, that logically, the collation order should be a session
parameter. It is language-specific and therefore user-specific if you
have international users. (I acknowledge the potential performance
problems, but they are the same with an explicit collation clause).

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachments:

  signature.asc (application/pgp-signature, 832B) download

view thread (16+ messages)

Message-ID: <20201211093041.GA25192@hjp.at>
Permalink:  ../20201211093041.GA25192@hjp.at/
Also on:    postgresql.org/message-id/20201211093041.GA25192@hjp.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: hjp-pgsql@hjp.at
  Subject: Re: Set COLLATE on a session level
  In-Reply-To: <20201211093041.GA25192@hjp.at>
  References: <0DDE56FB-89A8-4621-BF5E-8CE3461F4983@mikatiming.de> <9fd0eef06639e633e258461e5baad9734bcbc1ba.camel@cybertec.at> <F4E0491C-0312-433D-9C5F-44730A43224B@mikatiming.de> <CAFj8pRAk21ke-CQ5mDg8wAk2W=oc7fM6_9JvAvpbBOnJDz+kPQ@mail.gmail.com> <20201120144717.GD5091@hermes.hilbert.loc> <17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de> <20201211093041.GA25192@hjp.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox