Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 102754
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: KBENSON [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.082801



Subject: populate silently drops data if first hashref contains less items than subsequent hashrefs
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-5616-1426286610-1420.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1194
Download (untitled) / with headers
text/plain 1.1k
When DBIx::Class::ResultSet::populate is calles with an arrayref of hashrefs, it generates a column list from the keys of the first hashref. If the subsequent hashrefs for insertion include hash keys that were not included in the first hashref, but are valid fields, they are silently ignored. E.g. Table foo has fields field_1, field_, field_3. my @populate_items = ( { field_1=>10, field_3=>30 }, { field_1=>10, field_2=>20, field_3=>30 } ); Schema->resultset('Foo')->populate( \@populate_items ); DBIC_TRACE=1 shows the query generated will be equivalent to: INSERT INTO `foo` ( `field_1`, `field_3` ) VALUES ( ?, ? ): '__BULK_INSERT__' This has to do with how populate determines the columns in the void context case. This one bit me pretty hard, I have a populate that happens once a day has a small percentage of it's items missing some views. IF the first item happened to be one missing a field, subsequent items for that populate were all missing that field. I understand if in the name of keeping this a fast path this behavior needs to stay, but the warning about how context matters should definitely be updated to reflect this case. Thanks!
MIME-Version: 1.0
X-Spam-Status: No, score=-4.935 tagged_above=-99.9 required=10 tests=[AWL=0.965, BAYES_00=-1.9, FROM_OUR_RT=-4] autolearn=ham
In-Reply-To: <rt-4.0.18-5616-1426286610-1681.102754-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-102754 [...] rt.cpan.org> <rt-4.0.18-5616-1426286610-1681.102754-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <5503F4F5.3000609 [...] cpan.org>
content-type: text/plain; charset="utf-8"; format="flowed"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -4.935
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 30CCA2405CF for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Sat, 14 Mar 2015 04:44:53 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UZ96cK7J6bB5 for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Sat, 14 Mar 2015 04:44:51 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id C56552401D5 for <bug-DBIx-Class [...] rt.cpan.org>; Sat, 14 Mar 2015 04:44:50 -0400 (EDT)
Received: (qmail 14592 invoked by alias); 14 Mar 2015 08:44:49 -0000
Received: from mujunyku.leporine.io (HELO mujunyku.leporine.io) (113.212.96.195) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sat, 14 Mar 2015 01:44:47 -0700
Received: from [10.0.13.10] (unknown [10.0.13.10]) by mujunyku.leporine.io (Postfix) with ESMTP id A100212A0FD for <bug-DBIx-Class [...] rt.cpan.org>; Sat, 14 Mar 2015 08:44:39 +0000 (UTC)
Delivered-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0
Subject: Re: [rt.cpan.org #102754] populate silently drops data if first hashref contains less items than subsequent hashrefs
Return-Path: <ribasushi [...] cpan.org>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbix-class
Date: Sat, 14 Mar 2015 09:44:37 +0100
X-Spam-Level:
To: bug-DBIx-Class [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Peter Rabbitson <ribasushi [...] cpan.org>
RT-Message-ID: <rt-4.0.18-24677-1426322694-1493.102754-0-0 [...] rt.cpan.org>
Content-Length: 691
Download (untitled) / with headers
text/plain 691b
On 03/13/2015 11:43 PM, Kevan Benson via RT wrote: Show quoted text
> > When DBIx::Class::ResultSet::populate is calles with an arrayref of hashrefs, it generates a column list from the keys of the first hashref. If the subsequent hashrefs for insertion include hash keys that were not included in the first hashref, but are valid fields, they are silently ignored.
This has been fixed about a year ago https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082810/Changes#L61. The commit message explains why it took so long: https://github.com/dbsrgits/dbix-class/commit/d0cefd99 Please let me know if the fix in 0.082810 is indeed solving your problem, as it is possible something *still* got missed.
MIME-Version: 1.0
X-Spam-Status: No, score=-4.698 tagged_above=-99.9 required=10 tests=[AWL=2.000, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-24677-1426322694-748.102754-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-102754 [...] rt.cpan.org> <rt-4.0.18-5616-1426286610-1681.102754-4-0 [...] rt.cpan.org> <5503F4F5.3000609 [...] cpan.org> <rt-4.0.18-24677-1426322694-748.102754-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.140.233.71 with SMTP id e68mr19051099qhc.56.1426356621116; Sat, 14 Mar 2015 11:10:21 -0700 (PDT)
Message-ID: <CADKE7o4G9c9y1CqD1QmDUv+8MzxCbp7PMgygvQWfX-fKV3k9_A [...] mail.gmail.com>
Content-Type: multipart/alternative; boundary="001a113551aab989da05114387b1"
X-Spam-Score: -4.698
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 9626B240374 for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Sat, 14 Mar 2015 14:10:40 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6KDnuYq7ha1j for <cpan-bug+DBIx-Class [...] hipster.bestpractical.com>; Sat, 14 Mar 2015 14:10:37 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 5A53E24020F for <bug-DBIx-Class [...] rt.cpan.org>; Sat, 14 Mar 2015 14:10:36 -0400 (EDT)
Received: (qmail 5774 invoked by alias); 14 Mar 2015 18:10:35 -0000
Received: from mail-qg0-f51.google.com (HELO mail-qg0-f51.google.com) (209.85.192.51) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sat, 14 Mar 2015 11:10:24 -0700
Received: by qgfa8 with SMTP id a8so11050453qgf.0 for <bug-DBIx-Class [...] rt.cpan.org>; Sat, 14 Mar 2015 11:10:21 -0700 (PDT)
Received: by 10.140.20.143 with HTTP; Sat, 14 Mar 2015 11:10:21 -0700 (PDT)
Delivered-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #102754] populate silently drops data if first hashref contains less items than subsequent hashrefs
Return-Path: <kentrak [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=b3sEuAFs5L5N2VTg04SW+zCxIOldh7tbCOerP9gBV7o=; b=iq43A+NEi0s5GAA4ZmSOnJyPBhewdnp7Q1p/aWMQcevXPZfZg0FO2IrSfaTXVSH4u2 hyIE7b+v3VXMnlikSrHQfBZNZUQm0/YO8uUpbCgf+uunMrrnChuCzw7d8AL/RvCfcGBW /kaSatxkhyDxR/x7cp/0iD00IsP16juWm+UcNSNG6NDOWa7wZo9l4kn2P0JdkrId6VnP 2JOLF4y52RJmsIRqiVkjWlYgIus+ryqlhTb3hwU/SWdwiI9AEdaGwEXMpLjzuR/ujYoD D9wNXGlNqC4MvF+MaWXMOjMUJai9dttOmf61Ad3c2l8HNfDlvCki/PNymnP5O7sWRAy+ Hw+A==
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+DBIx-Class [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbix-class
Date: Sat, 14 Mar 2015 11:10:21 -0700
X-Spam-Level:
To: bug-DBIx-Class [...] rt.cpan.org
From: Kevan Benson <kentrak [...] gmail.com>
RT-Message-ID: <rt-4.0.18-2479-1426356642-1846.102754-0-0 [...] rt.cpan.org>
Content-Length: 0
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 1205
Download (untitled) / with headers
text/plain 1.1k
I could have sword I updated recently, but apparently I'm on 0.08270. In any case, I should have checked the most recent code for the bug, and I forgot that step. Thanks for the quick response, I'll confirm it's functioning on my side and if not reply back, but you should be able to close this in the meantime. Thanks again! On Sat, Mar 14, 2015 at 1:44 AM, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=102754 > > > On 03/13/2015 11:43 PM, Kevan Benson via RT wrote:
> > > > When DBIx::Class::ResultSet::populate is calles with an arrayref of
> hashrefs, it generates a column list from the keys of the first hashref. > If the subsequent hashrefs for insertion include hash keys that were not > included in the first hashref, but are valid fields, they are silently > ignored. > > This has been fixed about a year ago > https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082810/Changes#L61. > The commit message explains why it took so long: > https://github.com/dbsrgits/dbix-class/commit/d0cefd99 > > Please let me know if the fix in 0.082810 is indeed solving your > problem, as it is possible something *still* got missed. > > >
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-RT-Original-Encoding: utf-8
Content-Length: 1999
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-5616-1426286610-1420.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-5616-1426286610-1420.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-4229-1426764803-269.102754-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 61


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.