Skip Menu |
 

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

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

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

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



Subject: _insert_bulk not looking at all column values
Download (untitled) / with headers
text/plain 1.1k
No paste! from "ghenry" at 217.168.150.38 data_type: 'integer' and is_nullable: 1 format options below DBIx::Class::Storage::DBI::_insert_bulk(): Incorrect value (expecting SCALAR-ref \'NULL') for column 'id_ratecard' in populate slice: { a2b_custom1 => "NULL", a2b_custom2 => "NULL", buycost => "0.00550", calledstation => "441225900800", card_id => 1, destination => 441225, dnid => "441225900800", id => 11, id_card_package_offer => \"NULL", id_did => \"NULL", id_ratecard => 16054, id_tariffgroup => 1, id_tariffplan => 1, id_trunk => 2, nasipaddress => "", real_sessiontime => 66, sessionbill => "0.015", sessionid => "SIP/0ad43660", sessiontime => 66, sipiax => 0, src => "4654654646", starttime => "2019-08-20 13:20:15", stoptime => "2019-08-20 13:21:21", terminatecauseid => 1, uniqueid => "1250770812.24", } at t/lib/Helpers.pm line 46 Spec: =head2 id_ratecard data_type: 'integer' is_nullable: 1 id_ratecard is NULL on some other records in this data. Doesn't look at them all: https://metacpan.org/release/DBIx-Class/source/lib/DBIx/Class/Storage/DBI.pm#L2177 Thanks.
Download (untitled) / with headers
text/plain 1.5k
On Mon Nov 04 10:14:39 2019, GHENRY wrote: Show quoted text
> > No paste! > from "ghenry" at 217.168.150.38 > data_type: 'integer' and is_nullable: 1 > > format options below > > DBIx::Class::Storage::DBI::_insert_bulk(): Incorrect value (expecting > SCALAR-ref \'NULL') for column 'id_ratecard' in populate slice: > { > a2b_custom1 => "NULL", > a2b_custom2 => "NULL", > buycost => "0.00550", > calledstation => "441225900800", > card_id => 1, > destination => 441225, > dnid => "441225900800", > id => 11, > id_card_package_offer => \"NULL", > id_did => \"NULL", > id_ratecard => 16054, > id_tariffgroup => 1, > id_tariffplan => 1, > id_trunk => 2, > nasipaddress => "", > real_sessiontime => 66, > sessionbill => "0.015", > sessionid => "SIP/0ad43660", > sessiontime => 66, > sipiax => 0, > src => "4654654646", > starttime => "2019-08-20 13:20:15", > stoptime => "2019-08-20 13:21:21", > terminatecauseid => 1, > uniqueid => "1250770812.24", > } at t/lib/Helpers.pm line 46 > > Spec: > > =head2 id_ratecard > > data_type: 'integer' > is_nullable: 1 > > > > id_ratecard is NULL on some other records in this data. > > Doesn't look at them all: > > https://metacpan.org/release/DBIx- > Class/source/lib/DBIx/Class/Storage/DBI.pm#L2177 > > Thanks.
To clarify after poking: The insert_bulk code looks like it assumes every value for a particular column will always be the same type as the first item given for that column in the input $data. If we pass it a mixture of foreign_key values and NULLs (no FK value), then it can't cope.
Download (untitled) / with headers
text/plain 1.1k
On Mon Nov 04 16:14:39 2019, GHENRY wrote: Show quoted text
> > > id_ratecard is NULL on some other records in this data. >
You are supplying literal snippets for some rows but not for others. This varies the amount of bind variables, which can not be done in a single bulk insert call ( it changes the SQL statement ). You need to simply pass the regular NULLs in the form of undef, as you normally would elsewhere. Please close this ticket if the below example answers your question fully. I will keep it open for a bit, but there's really nothing I can "fix" on my side. ~.../dbic_checkout$ perl -It/lib -Ilib -MDBICTest -MData::Dumper -e ' my $rs = DBICTest->init_schema( no_populate => 1 )->resultset("Artist"); $rs->populate([ { name => undef, rank => 1 }, { name => "hazname", rank => 2 }, ]); die Dumper [ $rs->all_hri ]; ' $VAR1 = [ [ { 'artistid' => 1, 'charfield' => undef, 'name' => undef, 'rank' => 1 }, { 'artistid' => 2, 'charfield' => undef, 'name' => 'hazname', 'rank' => 2 } ] ];
Looks good. Will switch to undef. Thanks.


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.