Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1knelv-0007a6-7E for pgsql-general@arkaria.postgresql.org; Fri, 11 Dec 2020 09:31:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1knelN-0003Wc-Qa for pgsql-general@arkaria.postgresql.org; Fri, 11 Dec 2020 09:30:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1knelN-0003WV-1E for pgsql-general@lists.postgresql.org; Fri, 11 Dec 2020 09:30:57 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1knelB-0006Ch-Ii for pgsql-general@lists.postgresql.org; Fri, 11 Dec 2020 09:30:55 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 0912F3F8E; Fri, 11 Dec 2020 10:30:42 +0100 (CET) Date: Fri, 11 Dec 2020 10:30:42 +0100 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: Set COLLATE on a session level Message-ID: <20201211093041.GA25192@hjp.at> References: <0DDE56FB-89A8-4621-BF5E-8CE3461F4983@mikatiming.de> <9fd0eef06639e633e258461e5baad9734bcbc1ba.camel@cybertec.at> <20201120144717.GD5091@hermes.hilbert.loc> <17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="/04w6evG8XlLl3ft" Content-Disposition: inline In-Reply-To: <17384830-38E8-4F5C-92F9-338A1F1C6333@mikatiming.de> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --/04w6evG8XlLl3ft Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2020-11-30 10:11:38 +0000, Dirk Mika wrote: > > > p=E1 20. 11. 2020 v 15:28 odes=EDlatel Dirk Mika > > > napsal: > > > > Let's assume there is an app that accesses the same database from > > > > different countries. And in this app data should be displayed order= ed. And > > > > the sort order is not identical in all countries. > > > > > > > > Does the app have to send different SQL commands depending on the c= ountry? > > > > 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. [...]=20 > 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --/04w6evG8XlLl3ft Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAl/TPDcACgkQ8g5IURL+ KF0oCA//ZYS4zo6SGFHza9HcMfXgCFZxhjZad2sSnWE90p1946WeCtojcmvliUEX jWkPFREZrrYTHyPd7p3ItS35X31qDM/A05/FIHFD/1wjwR8zGDsgQDgnjRGo9fNW 6te7XbWtEwRmui5snKpUzkR03FkFuob8tM3YQq6MX0fWWJWu9xA+Il95I89+T1W9 KA9BLPWpjE1T0dVXyNmgDlTz4R0JFCP04JFzJkvgReYd3nFebB+hKiYjgYEgMTiE 2cdU1YnOLJJtMlKioBwK1E6/TxkBCXESK86cO4M4cL+aiPC4eGihdUcLIP7gSiOl sfxrp7UZTP6f3tdJaWcvBVvJolZ63Y1ZuQpOMqsXnJ/K7ngh7tGwZr4qLd5pb75R AdrRQ/Wf5HpjpCbxmlbz7gVgYwoooXiaMeawo5JufFaJxnsms5dIB28MdBADnj7j 56GA24lIwDJaJbqmZ/1bwirCVrXCnb6XmI/+5+J/vyjxH25Cz6/b6IS9aaRzQJVm dKZ4bEbGTYJaIwp+2Ys/Zrb3BL6+1v8anxG2ck3AxCDkGKSjSJGAizQrMNhNfOh7 zYWg/IAavUs0LTqPR7bUSGa+cbOjBIAMSDthRBSh8hxTaoh7mYktiRcoqP1kNCGv q7lmL1Bbly67yi04ZigDWuiSfWYyJOul3rA2f0TMpIdW4K2jfME= =Omgs -----END PGP SIGNATURE----- --/04w6evG8XlLl3ft--