Re: Default ordering option

2019-07-27 Thread Peter J. Holzer
On 2019-07-26 09:52:52 +0200, Cyril Champier wrote: > No, the code I pasted was an existing production bug: the last_name > should have been unique, so the selected patient would always be the > same. This should have been detected in tests, but since the order was > "almost always the same", our t

Re: Default ordering option

2019-07-26 Thread Cyril Champier
Julien, Because it's production code generated by our ORM for this command: `Patient.find_by(last_name: 'champier')`. Of course this was not intended by the developer that though the last_name was unique. On Fri, Jul 26, 2019 at 10:10 AM Julien Rouhaud wrote: > On Fri, Jul 26, 2019 at 9:53 AM

Re: Default ordering option

2019-07-26 Thread Julien Rouhaud
On Fri, Jul 26, 2019 at 9:53 AM Cyril Champier wrote: > > Adrian: > >> Are you really looking for a pseudo-random name? > > > No, the code I pasted was an existing production bug: the last_name should > have been unique, so the selected patient would always be the same. > This should have been de

Re: Default ordering option

2019-07-26 Thread Cyril Champier
Adrian: Are you really looking for a pseudo-random name? No, the code I pasted was an existing production bug: the last_name should have been unique, so the selected patient would always be the same. This should have been detected in tests, but since the order was "almost always the same", our t

Re: Default ordering option

2019-07-25 Thread Adrian Klaver
On 7/25/19 12:43 AM, Cyril Champier wrote: *Adrian*: If order is not an issue in the production code why test for it in the test code? In many cases, it would not be a problem in tests if we had an unordered array comparison helper. But in other cases, it is a production issue. In ru

Re: Default ordering option

2019-07-25 Thread Cyril Champier
Peter: So I would need to create a pg extension encapsulating this hook callback? If this is the case, it seems it will be much more complicated than expected, and I wont be able to do it :( But thanks for the suggestion anyway. On Thu, Jul 25, 2019 at 12:21 PM Peter Eisentraut < peter.eisentr...@

Re: Default ordering option

2019-07-25 Thread Peter Eisentraut
On 2019-07-25 09:43, Cyril Champier wrote: > It might be an interesting exercise to implement this as a post-parsing > hook. > >   > I known nothing about that, but that sounds interesting, do you have any > documentation pointer to help me implement that? Look for post_parse_analyze_hook

Re: Default ordering option

2019-07-25 Thread Cyril Champier
*Adrian*: > > If order is not an issue in the production code why test for it in the > test code? In many cases, it would not be a problem in tests if we had an unordered array comparison helper. But in other cases, it is a production issue. In ruby ActiveRecord for exemple, you can do `Patient.f

Re: Default ordering option

2019-07-24 Thread Peter Eisentraut
On 2019-07-23 17:43, Cyril Champier wrote: > In this documentation > , it is said: > > If sorting is not chosen, the rows will be returned in an > unspecified order. The actual order in that case will depend on the > scan and join

Re: Default ordering option

2019-07-24 Thread Adrian Klaver
On 7/24/19 8:22 AM, Cyril Champier wrote: Indeed, you are right, I do my test in pure sql and via ruby ActiveRecord, and I must had been confused, the behaviour is correct in sql, it must have been a cache thing in ActiveRecord that prevented the reordering. But meanwhile, I tested on our whole

Re: Default ordering option

2019-07-24 Thread Cyril Champier
Indeed, you are right, I do my test in pure sql and via ruby ActiveRecord, and I must had been confused, the behaviour is correct in sql, it must have been a cache thing in ActiveRecord that prevented the reordering. But meanwhile, I tested on our whole CI, and it took twice the normal time with up

Re: Default ordering option

2019-07-24 Thread Adrian Klaver
On 7/24/19 1:45 AM, Cyril Champier wrote: Thanks for your answers. Unfortunately the update trick only seems to work under certain conditions. I do this to shuffle my patients table: UPDATE "patients" SET "updated_at" = NOW() WHERE "patients"."id" = (SELECT "patients"."id" FROM "patients" ORDER

Re: Default ordering option

2019-07-24 Thread Cyril Champier
Thanks for your answers. Unfortunately the update trick only seems to work under certain conditions. I do this to shuffle my patients table: UPDATE "patients" SET "updated_at" = NOW() WHERE "patients"."id" = (SELECT "patients"."id" FROM "patients" ORDER BY random() LIMIT 1) Then indeed, this quer

Re: Default ordering option

2019-07-23 Thread Ian Barwick
On 7/24/19 2:23 AM, Adrian Klaver wrote: On 7/23/19 8:43 AM, Cyril Champier wrote: Hi, In this documentation , it is said:     If sorting is not chosen, the rows will be returned in an     unspecified order. The actual order in that case

Re: Default ordering option

2019-07-23 Thread Adrian Klaver
On 7/23/19 8:43 AM, Cyril Champier wrote: Hi, In this documentation , it is said: If sorting is not chosen, the rows will be returned in an unspecified order. The actual order in that case will depend on the scan and join pla

Default ordering option

2019-07-23 Thread Cyril Champier
Hi, In this documentation , it is said: > If sorting is not chosen, the rows will be returned in an unspecified > order. The actual order in that case will depend on the scan and join plan > types and the order on disk, but it must not be re