[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Names for database access functions
- From: Coda Highland <chighland@...>
- Date: Wed, 17 Jun 2015 21:51:34 -0700
On Wed, Jun 17, 2015 at 9:01 PM, Geoff Leyland
<geoff_leyland@fastmail.fm> wrote:
> On 18/06/2015, at 2:19 pm, Coda Highland <chighland@gmail.com> wrote:
>>
>> I would guess the u stands for "unpacked" since that's the operation
>> that would transform a row stored in an array into multiple returns.
>
> That makes sense. Thanks.
>
>> Personally I would offer rows() as the array version and then extend
>> that with adapters, such as rows():asTable() or rows():asValues().
>
> Depending on the API you get from the database, you can build asTable and asValues without an intermediate table. In the case of asValues, this means avoiding unpack, which is a little slow, and you can return values from the database without creating any tables at all, which can help if there’s a lot of rows.
>
> But the naming convention you suggest isn’t bad. I’d be inclined to mark the array one too.
If you're going to mark one for arrays too, then instead of calling it
rows() you could call it results() or something, such that you don't
actually invoke the database API until you've selected the appropriate
output form.
/s/ Adam