Re: [Dbix-class] DBIx how to update_or_create a table with primary index is autoincrement ? getting erroneous data

2012-09-27 Thread Ronald J Kimball
Yes, that is correct. For update_or_create() to work, it needs a way to find the original row, if it exists. Ronald On Thu, Sep 27, 2012 at 1:40 PM, Rajeev Prasad wrote: > so far, I do not, but I want one filed to be uniq, lets call it field1. so > should i set a uniq constraint on it, and the

Re: [Dbix-class] DBIx how to update_or_create a table with primary index is autoincrement ? getting erroneous data

2012-09-27 Thread Ronald J Kimball
On Thu, Sep 27, 2012 at 12:55 PM, Rajeev Prasad wrote: > 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 5

Re: [Dbix-class] Adding a case statement to a ResultSet

2012-05-04 Thread Ronald J Kimball
On Fri, May 4, 2012 at 12:12 PM, Kenneth S Mclane wrote: adds the case statement to the sql, but I get an error that "sunset_date" > is ambiguous. If I specify it as "account.sunset_date" I get > "account.sunset_date is invalid in the context it is being used in." > Try me.sunset_date. See the d

Re: [Dbix-class] not able to list any records from database

2011-09-01 Thread Ronald J Kimball
On Thu, Sep 1, 2011 at 5:52 PM, Rajeev Prasad wrote: > thx. > > but when i put search item as 'test12' I get error: > > > $ get-data-from-db.pl > Use of uninitialized value in concatenation (.) or string at ./ > get-data-from-db.pl line 23. > user is: > here is the code again, i think i have defi

Re: [Dbix-class] Duplicate me.id in WHERE clause of simple query

2011-01-24 Thread Ronald J Kimball
On Mon, Jan 24, 2011 at 8:40 AM, Winfried Neessen wrote: > sub list :Path :Args( 0 ) > { > > ## Get object and context > my ( $self, $c ) = @_; > > ## Get ResultSet > my $rs = $c->model( 'DB::Vorgaenge' ); > > ## Sort the ResultSet by ID > my $search

Re: [Dbix-class] Chained resultsets and WHERE operators

2010-11-09 Thread Ronald J Kimball
On Tue, Nov 9, 2010 at 8:36 AM, Mike Raynham wrote: > > I have created a query which determines if a given date range exists within > date ranges stored in the database: > > ### > > # SELECT * FROM my_table WHERE > # (start_date <= $start_date AND end_date >= $start_date) OR > # (start_date <= $en

Re: [Dbix-class] DBIx::Class::Schema::Loader Can't use string error

2010-10-28 Thread Ronald J Kimball
On Wed, Oct 27, 2010 at 10:26 AM, Dave Howorth wrote: > > $ ./create-schema.pl > Dumping manual schema for QD1x::Schema to directory . ... > Schema dump completed. > Failed to reload class QD1x::Schema::Result::EntryAttribute: Can't use > string ("QD1x::Schema::Result::EntryAttri") as a HASH ref w

Re: [Dbix-class] find_or_create and unique constraints

2010-10-04 Thread Ronald J Kimball
On Sat, Oct 2, 2010 at 8:16 PM, Bill Moseley wrote: > Seems like ->single (and thus find_or_create) should throw an exception if > more than one row is returned, columns passed to find_or_create must satisfy > a defined unique constraint, and if a single row is found any non-constraint > columns

Re: [Dbix-class] prefetch problem

2010-08-13 Thread Ronald J Kimball
On Fri, Aug 13, 2010 at 10:39 AM, Marc Perez wrote: > I'm doing the next query: > my $files = $catVar->model('cmsDB::Files')->search( >                       { >                               'me.cmsobj_id' => $this->cmsobj_id, >                               -or => [mime_type => 'image/jpeg',mime

Re: [Dbix-class] Enforcing read-only objects

2010-08-12 Thread Ronald J Kimball
On Wed, Aug 11, 2010 at 6:09 PM, Ian Docherty (icydee) wrote: > Ignoring for the moment the artists, cds, tracks etc. I could see it > something like the following. (top of my head, first impressions, probably > totally borked) > > In your application code. > > > my $factory = MyApp::Busines

Re: [Dbix-class] Why is this so slow?

2010-06-08 Thread Ronald J Kimball
On Tue, Jun 8, 2010 at 9:09 AM, Chris Cole wrote: > > # make SQL search both technical replicates at the same time > $dataset =~ s/t\d/t%/; > my $rs = $self->resultset('NgsMappings')->search( > { > 'me_sample' => {'like', $dataset}, > }, > { > columns => [qw/mp

Re: [Dbix-class] Automatic quoting

2010-06-08 Thread Ronald J Kimball
On Mon, Jun 7, 2010 at 6:04 PM, fREW Schmidt wrote: > On Mon, Jun 7, 2010 at 12:04 AM, Toby Corkindale < > toby.corkind...@strategicdata.com.au> wrote: > >> Only speaking on behalf of myself, but I see: >> >> 1) You shouldn't be making db tables or columns based on reserved words >> anyway, as s

[Dbix-class] update_or_create(\%hash) deletes keys from %hash when updating an inflated column

2010-04-14 Thread Ronald J Kimball
I'm passing a reference to a named hash to update_or_create(). The resultset has two inflated columns. If the row already exists in the table, then the keys for the inflated columns are deleted from the hash. Is this expected behavior? This happens with DBIC 0.08111 and 0.08121. For exampl

Re: [Dbix-class] paging question

2010-02-05 Thread Ronald J Kimball
James Marca wrote: From reading the docs, starting with http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Storage/DBI.pm#DBIx::Class_specific_connection_attributes and then linking to http://search.cpan.org/perldoc?DBI#prepare_cached, I see this for 'prepare_cached': Like "prepare

Re: [Dbix-class] Strict sequence primary key

2010-01-20 Thread Ronald J Kimball
Wes Cravens wrote: In an effort to create strictly sequential (Incrementing Integer no gaps) primary keys my method has traditionally been: BEGIN; LOCK table; SELECT MAX(id) FROM table; INSERT INTO table...; COMMIT; I'm relatively new to DBIC and have not really seen a way to do this unless I

Re: [Dbix-class] Fwd: [Catalyst] Selecting from more tables (DBIC - bug?)

2010-01-19 Thread Ronald J Kimball
Thomas L. Shinnick wrote: I'm having some of the same questions regarding +select and +as . It seems that using '+select' and '+as' does not stop other columns from being returned. I'm using DBIC 0.08115. What do you expect +select and +as to do?? +select Indicates additional columns t

Re: [Dbix-class] Duplicate entry error on create

2009-12-09 Thread Ronald J Kimball
Dermot wrote: 2009/12/9 Eden Cardim : "Dermot" == Dermot writes: Dermot> Hi, I am getting the following error when I attempt to Dermot> create a record. Dermot> DBD::mysql::st execute failed: Duplicate entry '0' for key 3 Dermot> [for Statement "INSERT INTO products ( distributio

[Dbix-class] register_source() regression in 0.08102

2009-05-07 Thread Ronald J Kimball
I'm currently using the following code in one of my schema modules, based on the message http://www.mail-archive.com/dbix-class@lists.scsys.co.uk/msg02613.html my $new_month = '200905'; my $user_session_source = __PACKAGE__->source('UserSession'); my $new_source = $user_session_source->ne

Re: [Dbix-class] Oracle xmltype

2009-05-05 Thread Ronald J Kimball
Morgon Hed wrote: You can set '+select' and '+as', and stick that in a resultset method, so the code just becomes $stream_rs->with_xml_field->... Thanks for the reply but I don't quite understand what you are saying. I can easily do the follwing: my $s1 = $schema->resultset('Stream')->search

Re: [Dbix-class] is_nullable

2009-03-18 Thread Ronald J Kimball
Dermot wrote: 2009/3/18 Ronald J Kimball : Dermot wrote: is_nullable => 0 and NOT NULL mean the same thing, don't they? I think it's one of them there double negatives :) is_nullable Set this to a true value for a columns that is allowed to contain NULL values. This is c

Re: [Dbix-class] is_nullable

2009-03-18 Thread Ronald J Kimball
Dermot wrote: Hi, I notice that when I use DBIx::Class::Schema::Loader it always creates the columns as is_nullable => 0. Is this by design or is there an option I can pass it so that my ResultSources will maintain their 'NOT NULL'. is_nullable => 0 and NOT NULL mean the same thing, don't the

Re: [Dbix-class] DBIx::Class::Resultset - DBI Exception near PATH

2009-02-18 Thread Ronald J Kimball
on...@houseofdesign.de wrote: $hashref->{'users_reference'} does nox exist. I had problems with undef variables in a hash. I generally put a "scalar" in front of my variables, this fixes the "undef value in hash"-problem e.g. ->find_or_create({ ... users_reference => scalar $hashref->{'users_

[Dbix-class] get_inflated_columns and selecting specific columns

2008-08-13 Thread Ronald J Kimball
With search(), you can specify a set of columns to return, e.g.: select => [qw/ item_id name /], However, unlike get_columns(), get_inflated_columns() doesn't limit itself to those columns. Instead, it returns values for all the columns in the table. Of course, the value will beundef for an

Re: [Dbix-class] [PATCH] Pod formatting fixes.

2008-07-21 Thread Ronald J Kimball
Florian Ragwitz wrote: diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index d0f5b1e..255b961 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -452,16 +452,16 @@ whether any options are specified in the new C. Another Important Note:

Re: [Dbix-class] DateTime independant from the database

2008-05-22 Thread Ronald J Kimball
To use DateTime for inflating your date columns, all you need to do is add InflateColumn::DateTime to the list of components. So, change: __PACKAGE__->load_components("Core"); to: __PACKAGE__->load_components("InflateColumn::DateTime", "Core"); You don't need to re-add the line of code to a

Re: [Dbix-class] SQL Function in update

2008-03-31 Thread Ronald J Kimball
time_zone=> 'UTC' )); $row->update; or $row->update(mydate => DateTime->now(time_zone=> 'UTC' )); What should GREATEST do in your case? -Alex -Original Message- From: Ronald J Kimball [mailto:[EMAIL PROTECTED] Sent: Monday, March 31, 2008 5:03 PM To: [

[Dbix-class] SQL Function in update

2008-03-31 Thread Ronald J Kimball
Yes, it's another question about using SQL functions in an update. I know I can pass a reference to a string containing literal SQL, as in: $row->update({ mydate => \ 'NOW()' }); However, in this case I need to pass arguments to the function, one of which needs to be quoted. Here's what I'm

Re: [Dbix-class] Error with escaped apostrophe and bind param

2008-03-14 Thread Ronald J Kimball
Ash Berlin wrote: Why exactly do you need to have that as part of the join condition rather than just in the WHERE clause? If you put as part of the search term then you use bind params much easier and let the *database* handle the quoting. Because I need to /exclude/ those rows. I select f

[Dbix-class] Error with escaped apostrophe and bind param

2008-03-14 Thread Ronald J Kimball
I'm getting an error with the following query, which finds all users who have not yet been sent a message from the specified user with the specified subject(s). Due to SQL::Abstract limitations, I'm providing some literal SQL for the join clause, which happens to contain an escaped apostrophe.

Re: [Dbix-class] result testing

2007-12-11 Thread Ronald J Kimball
The call to $rs->first returns undef, so you're trying to call undef->id. That's why you get the error. Is that enough of a hint? :) Try this: myErrorFunc() unless $rs->first; If id is a primary or unique key, you could do this instead: myErrorFunc() unless $c->model('AppModelDB::Clients

Re: [Dbix-class] Detecting changes after ->update(\%) ?

2007-08-08 Thread Ronald J Kimball
Paul Makepeace wrote: I had a look in various places (cookbook, faq, ::resultset) and couldn't find whether there's a way to see if any SQL would be generated due to a call to update(). my $rv = $obj->update(\%stuff); $messages->($rv->XXX ? "updated" : "unchanged"); The docs* contain an eni