I have a search like this:
my $ids = [2, 1, 3];
$schema->resultset ('MyTable')->search (id => $ids);
MySQL processes rows in the order they are found in the table so I essentially
get back 1, 2, 3. $ids is really a user-specified list so I'd like to return
the results in the same order they ori
order them by the the length of the name of the number descending, and then
alphabetically by the cardinal name of the number ascending:
1,2,3
one, two, three
two, one three
2,1,3
len.
On Tue, Apr 30, 2013 at 2:21 PM, Chris Newman <
chris.new...@overturenetworks.com> wrote:
> I have a search
On Tue, Apr 30, 2013 at 06:21:54PM +, Chris Newman wrote:
>
> However, I cannot for the life of me figure out how to do the same thing
> using DBIx::Class. My test code looks like this:
> $schema->resultset ('MyTable')->search (id => $ids, {
> order_by => \'FIND_IN_SET (id, '2, 1, 3')
> });
reply.
-Original Message-
From: Peter Rabbitson [mailto:rabbit+d...@rabbit.us]
Sent: Tuesday, April 30, 2013 3:09 PM
To: DBIx::Class user and developer list
Subject: Re: [Dbix-class] Returning search results in a specific order
On Tue, Apr 30, 2013 at 06:21:54PM +, Chris Newman
On Tue, Apr 30, 2013 at 08:36:50PM +, Chris Newman wrote:
> From: Peter Rabbitson [mailto:rabbit+d...@rabbit.us]
> Sent: Tuesday, April 30, 2013 3:09 PM
>>
>> The thing above isn't valid perl, left alone valid search() syntax.
>>
>> Please show *actual* code run and *actual* SQL produced.
>
>
W
e generate a special ORDER BY for such a scenario (that should work for
most RDBMs):
ORDER BY
id = 2 ASC,
id = 1 ASC,
id = 3 ASC
2013/5/1 Peter Rabbitson
> On Tue, Apr 30, 2013 at 08:36:50PM +, Chris Newman wrote:
>
> > From: Peter Rabbitson [mailto:rabbit+d...@rabbit.us]
> > Sent:
On 30 April 2013 19:21, Chris Newman wrote:
> I have a search like this:
>
> my $ids = [2, 1, 3];
>
> $schema->resultset (‘MyTable’)->search (id => $ids);
>
>
>
> MySQL processes rows in the order they are found in the table so I
> essentially get back 1, 2, 3. $ids is really a user-specified li