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 1jeIhm-0006cy-ED for pgsql-general@arkaria.postgresql.org; Thu, 28 May 2020 13:36:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jeIhl-0003O6-Ay for pgsql-general@arkaria.postgresql.org; Thu, 28 May 2020 13:36:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jeIhk-0003Ny-Uu for pgsql-general@lists.postgresql.org; Thu, 28 May 2020 13:36:17 +0000 Received: from post.visena.com ([46.226.10.50]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.92) (envelope-from ) id 1jeIhg-00023e-OR for pgsql-general@lists.postgresql.org; Thu, 28 May 2020 13:36:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=visena.com; s=20141101.wh; h=Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:Cc:To:From:Date; bh=YlbX7tgtVjkmj+cxmwCUwpuga6zIUQ8dhwCnxJ/qu2M=; b=eg/wrCAfNJzRjx6j4R3d3IdYKfr3LIb8ii/bciVMTCo3icPpBtcSf8BfPMZbX5QTz3qVasNCJYMoyC9YTXziO0Xg+jr0O6euzIz+nVw22ZjyQk9zdpanCDiPDBsq5b4+XYLAIjq6xK8G5LBTaDLV9Znshv4oYvksK8O65QTeuec=; Received: from [10.0.1.10] (helo=tc7-visena.wh.internal.visena.com) by post.visena.com with esmtp (Exim 4.82) (envelope-from ) id 1jeIha-0000Mk-8X; Thu, 28 May 2020 15:36:06 +0200 Received: from localhost ([127.0.0.1] helo=tc7-visena.wh.internal.visena.com) by tc7-visena.wh.internal.visena.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jeIha-0003Qx-6q; Thu, 28 May 2020 15:36:06 +0200 Date: Thu, 28 May 2020 15:36:06 +0200 (CEST) From: Andreas Joseph Krogh To: Tom Lane Cc: Geoff Winkless , "pgsql-generallists.postgresql.org" Message-ID: In-Reply-To: <6288.1590672402@sss.pgh.pa.us> References: <6288.1590672402@sss.pgh.pa.us> Subject: Re: Order by lower(column-alias) doesn't work... MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_245_1475016813.1590672966146" X-Mailer: Visena Mail 2.2.306-SNAPSHOT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_245_1475016813.1590672966146 Content-Type: multipart/related; boundary="----=_Part_246_1033598980.1590672966146" ------=_Part_246_1033598980.1590672966146 Content-Type: multipart/alternative; boundary="----=_Part_247_2011489602.1590672966157" ------=_Part_247_2011489602.1590672966157 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable P=C3=A5 torsdag 28. mai 2020 kl. 15:26:42, skrev Tom Lane >:=20 Andreas Joseph Krogh writes: > Is there a way to define "sorting-rules" on custom-types so that I can h= ave > ORDER BY and PG will pick my custom=20 odering? You'd have to write your own type, which would be a lotta work :-(. A possible partial answer is to define the composite type as firstname citext, lastname citext, other-fields-here and then the regular composite-type comparison rule would give you approximately what you said you wanted ... but only approximately. regards, tom lane=20 Hm, ok. I think the most non-intrusive way for me is to craft a sub-select= =20 producing the "varchar-string-flattened" so I can order by that alias.=20 -- Andreas Joseph Krogh ------=_Part_247_2011489602.1590672966157 Content-Type: text/html;charset=UTF-8 Content-Transfer-Encoding: quoted-printable
P=C3=A5 torsdag 28. mai 2020 kl. 15:26:42, skrev Tom Lane <tgl@sss.pgh.pa.us>:
And= reas Joseph Krogh <andreas@visena.com> writes:
> Is there a way to define "sorting-rules" on custom-types so = that I can have
> ORDER BY <my_array_of_custom_types_alias> and PG will pick my cu= stom odering?

You'd have to write your own type, which would be a lotta work :-(.

A possible partial answer is to define the composite type as

firstname citext, lastname citext, other-fields-here

and then the regular composite-type comparison rule would give you
approximately what you said you wanted ... but only approximately.

regards, tom lane
=C2=A0
=C2=A0
Hm, ok. I think the most non-intrusive way for me is to craft a sub-se= lect producing the "varchar-string-flattened" so I can order by t= hat alias.
=C2=A0
">
--
Andreas Joseph Krogh
------=_Part_247_2011489602.1590672966157-- ------=_Part_246_1033598980.1590672966146-- ------=_Part_245_1475016813.1590672966146--