found this on web:
"So in summary, for tables with autoincrement primary keys ->find requires that 
you provide the primary key in the query, and ->create requires that you don't 
- this means that you cannot pass the same query hash to both methods and this 
is what ->update_or_create does."


so that means my update_or_create is never going to work on an empty table???

really? I am stuck pl help.



________________________________
 From: Rajeev Prasad <rp.ne...@yahoo.com>
To: DBIx::Class and developer list <dbix-class@lists.scsys.co.uk> 
Sent: Thursday, September 27, 2012 11:55 AM
Subject: [Dbix-class] DBIx how to update_or_create a table with primary index 
is autoincrement ? getting erroneous data
 

friends,

I have a Table to update (empty right now), and the regularly 'update' existing 
info with changes AND add any new record which come up.

source data is coming from file. one record per line.

        my @my_arr;  #has 500 uniq entries

        $schema->resultset('Mytable')->update_or_create(
        {
            field1 => $my_arr[0],
            field2 => $my_arr[1],
            field3 => $my_arr[2],
            ...
        },
        {key =>'primary'}    #field_id, auto increment value this field is NOT 
supplied in variables above.
        );


What is happening is: DBIX is first adding the 'first' record, then updating it 
with consecutive records!!! it is not creating a fresh record for any record in 
the file. so after it finishes running, I am left with one record in Table 
which is updated 500 times, and has the last record in file as the table record.

how to fix this?

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to