Re: [Dbix-class] Re: SQL Query generation issue

2011-08-08 Thread Will Crawford
On 8 August 2011 10:11, Peter Rabbitson wrote: > koxon wrote: >> >> Hello all, >> >> Any help on this ? >> ... He also wrote: > Thanks > > -- > View this message in context: > http://dbix-class.35028.n2.nabble.com/SQL-Query-generation-issue-tp6656054p6662816.html > Sent from the DBIx-Class mai

Re: [Dbix-class] Re: SQL Query generation issue

2011-08-08 Thread Will Crawford
Can you resend the original message along with a larger sample of the code that's issuing the queries? I saw some similar mess a while ago that was caused by inadvertently passing a hashref instead of a value somewhere in the search parameters ... On 8 August 2011 02:20, koxon wrote: > Hello all,

Re: [Dbix-class] Re: ASE.pm uninitialized value warning

2011-08-31 Thread Will Crawford
On 31 August 2011 07:29, koxon wrote: > *Use of uninitialized value in exists at > //ms/dist/perl5/PROJ/DBIx-Class/0.08195/lib/perl5/DBIx/Class/Storage/DBI/Sybase/ASE.pm > line 266.* if (($op eq 'insert' && $bound_identity_col) || - ($op eq 'update' && exists $args->[0]{$identity_col}))

Re: [Dbix-class] Catalyst::TraitFor::Model::DBIC::Schema::Caching problem

2011-09-08 Thread Will Crawford
Use CURRENT_DATE or _TIMESTAMP instead (I hit a problem with using 'now' with Pg in DBIC due to use of prepared statements, puzzled over it for weeks before finding the solution :)). 2011/9/8 Alex Povolotsky : > Hello! > > I've tried to use Catalyst::TraitFor::Model::DBIC::Schema::Caching to > dec

Re: [Dbix-class] Catalyst::TraitFor::Model::DBIC::Schema::Caching problem

2011-09-08 Thread Will Crawford
http://archives.postgresql.org/pgsql-bugs/2011-06/msg00015.php sums it up fairly well. On 8 September 2011 12:36, Peter Rabbitson wrote: > On Thu, Sep 08, 2011 at 11:49:10AM +0100, Will Crawford wrote: >> Use CURRENT_DATE or _TIMESTAMP instead (I hit a problem with using >> '

Re: [Dbix-class] Re: ASE.pm uninitialized value warning

2011-09-13 Thread Will Crawford
On 31 August 2011 13:02, Peter Rabbitson wrote: > Will Crawford gave you the correct fix already a bit earlier. It will be > included in the next version of DBIC. In fairness, I think I replied after he'd asked :) ___ List: http://lists.

Re: [Dbix-class] Using DBIx::Class::Schema::Config with dbicdump

2011-09-30 Thread Will Crawford
On 30 September 2011 06:39, Janne Snabb wrote: > I am using dbicdump to create and update my DBIC schema from the > database schema. It creates a Schema.pm with the following line in it: > > use base 'DBIx::Class::Schema'; > > ...which I have to change to: > > use base 'DBIx::Class::Schema::Confi

Re: [Dbix-class] running stored procedures

2011-10-20 Thread Will Crawford
On 20 October 2011 13:28, Roger Day wrote: > It's DBIC (possibly, but not I thnik likely) that I think is creating the > superfluous <*>, as it is creating the wrapper around the original piece of > SQL - which I give below as well. The <*> is provided by Oracle as part of the error message that

Re: [Dbix-class] date_time field for oracle

2011-10-26 Thread Will Crawford
On 26 October 2011 12:00, Roger Day wrote: > Hi > > I think I've done all the right things for inserting a date-time into a > Oracle date field, but I keep getting this: > > DBI Exception: DBD::Oracle::st execute failed: ORA-01861: literal does not > match format string (DBD ERROR: error possibly

Re: [Dbix-class] Bind parameters in select list and group by on Pg

2011-10-28 Thread Will Crawford
On 28 October 2011 11:37, dorian taylor wrote: > Interesting, because the literal would be "interval '6 months'", which > unless I'm huffing paint would translate to "interval ?". :) Mmm, paint I think it's "interval" "6" "month(s?)" which would translate to "interval ? ?" ... but the mont

Re: [Dbix-class] Providing extra limitations to query

2012-01-10 Thread Will Crawford
$rs->search( \%implicit_params )->search( ... stuff passed into your function ...); I've occasionally done this more overtly by having a ->with_filter_X method on the result set, and called it like $foo_rs->with_melitta->search( \%user_supplied_params ) ... good examples would be where you have, s

Re: [Dbix-class] Using a scalar ref with update_or_create

2012-03-19 Thread Will Crawford
change the value to \'CURRENT_TIMESTAMP' or \'CURRENT_DATE' :) if this isn't a long-running process, 'now' (without the parentheses) will probably work. On 16 March 2012 20:32, Octavian Rasnita wrote: > Hi, > > I have tried to use: > > $self->update_or_create({ >  symbol => $symbol, >  market =>

Re: [Dbix-class] Using a scalar ref with update_or_create

2012-03-19 Thread Will Crawford
On 19 March 2012 12:33, Websuche :: Felix Ostmann wrote: > We run into the same problem and simple split the problem. Make a find, then > update or create (simple look what update_or_create do internally) > > 2012/3/19 Will Crawford >> >> change the value to

Re: [Dbix-class] delete_related issue when related resultset does a prefetch

2012-07-26 Thread Will Crawford
On 26 July 2012 00:16, Greg Hill wrote: ... > It seems to boil down to the DBIx::Class::Resultset:: _rs_update_delete > method should be ignoring stuff like prefetch and order_by when being called > by 'delete'. But maybe there's a scenario where that behavior is desirable? There are cases (invo

Re: [Dbix-class] How to create a row object that contains related objects in DBIx::Class?

2012-08-16 Thread Will Crawford
On 16 August 2012 08:42, Jan Grmela wrote: > Hi Eugene, > I'm pretty sure this should help you: > http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSet.pm#cache Not quite. What he's saying is, he wants $book->author to return the author object that was supplied when he created the book

Re: [Dbix-class] How to create a row object that contains related objects in DBIx::Class?

2012-08-16 Thread Will Crawford
On 16 August 2012 12:21, Ian Docherty wrote: ... > One technique I have seen used is as follows. > > my $author = $authors_rs->find(1); > my $book = $books_rs->create({ author => $author, title => 'title' }); > $book->author($author); > > Be warned however, in some circumstances this can lead to c

Re: [Dbix-class] DBIx::Class::Ordered changes.

2012-09-20 Thread Will Crawford
On 20 September 2012 12:06, Peter Rabbitson wrote: > This is a describing a different problem froma thread a year ago. It is what > happens when new rows are inserted *concurrently* with pos unspecified (i.e. > pushed to the end of the stack) Ah. I'd run into a similar problem with the unique key

Re: [Dbix-class] Re: Explicit class naming

2013-02-14 Thread Will Crawford
I've used moniker_map in a few places, but before I realised I could use it, I named a table cached_v_a_t_numbers to get the same effect :) Do look at the inflect_{singular,plural} attributes too, if you're tweaking the result source names you may want to tweak some of the accessor / relation name

Re: [Dbix-class] [ANNOUNCE] A much faster DBIx::Class public trial round two - v0.08241

2013-02-22 Thread Will Crawford
It would probably be more intuitive to return something like: { element => { concept => { concept_id => nnn, foldername => 'xxx' }, ... }, ... } ? I've a couple of similar queries that I wrote before I started using HRI much, though I had to use +select/+as then get_c

Re: [Dbix-class] [ANNOUNCE] A much faster DBIx::Class public trial round two - v0.08241

2013-02-22 Thread Will Crawford
On 22 February 2013 11:36, Peter Rabbitson wrote: > At first glance yes. The problem here is that you are incorrectly > assuming that given 'concept.concept_id' one can simply infer we are > talking about the 'concept' from join => { element => 'concept' }. > > However the moment *another* 'conc

Re: [Dbix-class] what is the err in this DBIx select...

2013-04-16 Thread Will Crawford
You need the first arg to search there to be [ ... ] rather than { ... }. On 15 April 2013 20:47, Rajeev Prasad wrote: > I am meaning to run... > > search records where: > if item_type='XX' _then_ item column should contain '%01par%' or > '%01pqt%' > and, > if item_type='YY' OR

Re: [Dbix-class] Returning search results in a specific order

2013-05-02 Thread Will Crawford
On 30 April 2013 19:21, Chris Newman wrote: > I have a search like this: > > my $ids = [2, 1, 3]; > > $schema->resultset (‘MyTable’)->search (id => $ids); > > > > MySQL processes rows in the order they are found in the table so I > essentially get back 1, 2, 3. $ids is really a user-specified li

Re: [Dbix-class] Help ribasushi find his lost mojo ;)

2013-07-15 Thread Will Crawford
Same here. Is there a cookie problem? On 12 July 2013 20:51, Darren Duncan wrote: > On 2013.07.12 8:44 AM, Peter Rabbitson wrote: >> >> I wrote a relatively long meditation on the merits and demerits of my >> continuous involvement with this project: >> >> >> http://blogs.perl.org/users/peter_rab

Re: [Dbix-class] Multiple connections

2014-01-16 Thread Will Crawford
Copy your lib/MyApp/Model/DB.pm (or whatever it's called), and in the second copy, add the mysql_enable_utf8 => 1 to __PACKAGE__->config( { ... } ); or add it in your myapp.conf under the new model name. On 16 January 2014 11:06, Dave Howorth wrote: > Is there a good (authoritative?) description

Re: [Dbix-class] match against ...

2014-04-03 Thread Will Crawford
On 2 April 2014 10:47, RAPPAZ Francois wrote: > I'm struggling with code as ... > my ($where, @bind)= $sqlmaker->where("ti, ex, ad", "tri", $bla); > $self->{log}->debug($where); > my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, > {where=> $where}); Couple of things

Re: [Dbix-class] match against ...

2014-04-03 Thread Will Crawford
On 3 April 2014 13:37, RAPPAZ Francois wrote: > Is it the way I'm calling using the sqlmaker object ? It occurs to me that DBIC is cheerfully calling into sqlfairy behind the scenes and turning your already-formatted SQL into its own where clause. Maybe try: ->search( \[ $sql, @binds ] ) __

Re: [Dbix-class] match against ...

2014-04-04 Thread Will Crawford
On 4 April 2014 15:27, RAPPAZ Francois wrote: > I tried ... > my $rs = $self->{schema}->resultset('Jrn')->search_rs(undef, { -and => [ > \["WHERE match(ti, ex, ad) against(? in boolean mode)", @b]], order_by => > 'tri'}); Take out the "undef, " -- you've passed the query as the second paramete

Re: [Dbix-class] Where to set database date format for InflateColumn::DateTime?

2014-04-17 Thread Will Crawford
Set the default value to be \'CURRENT_TIMESTAMP' On 17 April 2014 13:37, Adam Witney wrote: > >>> Great thanks, >>> >>> on_connect_do => "SET datestyle = 'sql, mdy'", >>> >>> did the trick >> >> mea culpa! You should use on_connect_call => 'datetime_setup' which does >> the right thing for ever

Re: [Dbix-class] custom result source calling a stored procedure

2014-06-10 Thread Will Crawford
$users->search ( [ { 'user_friends.user_id' => $id }, { 'user_friends.friend_user_id' => $id } ], { join => 'user_friends' } )->all On 10 June 2014 12:18, Mitchell Elutovich wrote: > For a customer result source, I know we can do something such as: > > $new_source->name( \< ( SELECT

Re: [Dbix-class] Search and Delete with Single Query

2014-08-28 Thread Will Crawford
$schema->resultset('User')->search({GroupId => 712})->delete; On 28 August 2014 13:01, Sheeju Alex wrote: > Hi All, > > Is there any way in DBIx to delete all rows from resultset in a single > query, it looks like delete and delete_all will delete the resultset row by > row. > > my $rs = $sch

Re: [Dbix-class] Search and Delete with Single Query

2014-08-28 Thread Will Crawford
DELETE FROM User WHERE Id = 3; > > > and so on > > So if we have 100 Users it would 201 (1 + 100 + 100) queries. > > > Best Regards, > Sheeju Alex > > > On Thu, Aug 28, 2014 at 5:38 PM, Will Crawford > wrote: >> >> $schema->resultset('User

Re: [Dbix-class] Fastest method to check for key existence?

2015-02-13 Thread Will Crawford
On 11 February 2015 at 21:58, Ekki Plicht (DF4OR) wrote: > Hi, > I need to check a list of values if they exist in a database. The > value is a unique key of that table. A stupid 'find' works of course, > but returns the whole row data, where I only need a simple binary > yes/no information if a r

Re: [Dbix-class] Is it possible to use "dumb" result classes with DBIx::Class?

2015-04-09 Thread Will Crawford
You _should_ just be able to subclass the HRI class and add those methods (and pass { result_class => 'My::HRI::Subclass' } in for the RS attributes). I haven't tested this, will do in a moment :) On 9 April 2015 at 14:58, Lasse Makholm wrote: > I'm using DBIx::Class::ResultClass::HashRefInflato

Re: [Dbix-class] Is it possible to use "dumb" result classes with DBIx::Class?

2015-04-09 Thread Will Crawford
my $self = shift; return { %$self }; } } my $users = $schema->resultset('User'); my $me = $users->find( $my_user_id, { result_class => 'My::HRI::Subclass' } ); Dwarn $me->TO_JSON; On 9 April 2015 at 16:00, Lasse Makholm wrote: > > > On Th

Re: [Dbix-class] Is it possible to use "dumb" result classes with DBIx::Class?

2015-04-09 Thread Will Crawford
Ignore me, -EINSUFFICIENTCAFFEINE. Of course you need to class the returned objects ... On 9 April 2015 at 15:57, Will Crawford wrote: > You _should_ just be able to subclass the HRI class and add those methods > (and pass { result_class => 'My::HRI::Subclass' } in for the

Re: [Dbix-class] Making DBD::Pg to return Postgres arrays as Perl arrays

2015-05-07 Thread Will Crawford
{ data_type => "integer[]", ... } works for me? On 7 May 2015 at 10:17, Adam Sjøgren wrote: > Hi. > > I have a Postgres database with some fields that are defined as arrays > in the database. > > When I insert new rows where the field has a Perl-array as the value, > DBIx::Class+DBD::Pg a

Re: [Dbix-class] RootClass DBIx::ContextualFetch

2015-09-28 Thread Will Crawford
I'd create some sort of proxy object that stores a ref to $schema and does the ->dbh_do magic behind the scenes whenever you call a method on it ... On 26 September 2015 at 18:23, Bill Moseley wrote: > > > On Sat, Sep 26, 2015 at 8:54 AM, Peter Rabbitson > wrote: > > >> Is there any problem wit

Re: [Dbix-class] Detecting connection errors

2015-10-15 Thread Will Crawford
On 15 October 2015 at 11:13, Will Crawford wrote: [stupid top-post elided] Sorry about that. ___ 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

Re: [Dbix-class] Detecting connection errors

2015-10-15 Thread Will Crawford
This is because you are using sqlite. You could be intending to call ->deploy() rather than trying to select data. Sqlite will create the file for you (complete with typo) in this case. But as you haven't created any tables in the alternately-spelt database file, you'll get an exception. On 14 Oct

Re: [Dbix-class] Result->id

2017-11-29 Thread Will Crawford
If it's a third-party product ID (which the "known from" suggests), or it's non-unique for other reasons, having it named just "id" is misleading at best :) Maybe go with something like "their_id"? On 29 November 2017 at 11:39, Vladimir Melnik wrote: > Thank you! > > That's why I can't decide sh

Re: [Dbix-class] Newbie from SQL to DBIx

2018-03-08 Thread Will Crawford
A visit to https://www.google.co.uk/search?q=dbix+select+distinct should answer your question: DBIx::Class::Manual::Cookbook (first result here) says: SELECT DISTINCT with multiple columns ... my $rs = $schema->resultset('Artist')->search( {}, { columns => [ qw/artist_id name rank