Re: [Dbix-class] CDBICompat

2008-11-11 Thread Dave Howorth
Dave Howorth wrote:
 I've poked around some more and think I've found the source of the
 problem. I went back to a small example that worked and then
 experimented until it broke.

I looked at the cdbi-t tests to see how connection() is tested. AFAICT,
it isn't! So here are two tests for connection. The first one passes for
me and the second one fails.

Both pass if I replace

  use base 'DBIx::Class::CDBICompat';
with
  use base 'Class::DBI';

So can I ask that the tests be added to the test suite. I'm afraid I
don't know enough about DBIC internals to offer a patch so the test passes.

Thanks and regards,
Dave Howorth


cdbicompat-connection-test-1.t
Description: Troff document


cdbicompat-connection-test-2.t
Description: Troff document
___
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

Re: [Dbix-class] Re: Blessed objects as scalar values: what to do ?

2008-11-11 Thread BUCHMULLER Norbert
Just to summarize the decisions:

On Thu, 6 Nov 2008 17:26:51 +0100 BUCHMULLER Norbert [EMAIL PROTECTED]
wrote:

  Therefore my proposal was to say : OK, let's treat objects like
  scalars, but only if they have a method to effectively transform
  themselves into a scalar. This makes it likely that such objects can
  indeed be inserted into databases.

As discussed on IRC with mst, we should pass them intact, like current
CPAN SQLA does. I changed SQLA to reflect this.

  I don't know, maybe this view is too strong ... but on the other hand,
  do you have any real-world use cases where object references are
  passed to DBI ?
 
 Well, maybe a bit contrived, but there may be cases when the default
 date format ('2008-11-06T16:14:45') that DateTime produces on
 stringification is not suitable for the db engine,

mst told that eg. InflateColumn::DateTime does this.

  If we really want more flexibility, maybe what could be done is to add
  a new option in the SQLA contructor SQL::Abstract-new(value_classes
  = [qw/Foo::Bar, etc/]) In that scenario, object references would be
  accepted as scalar values if and only if they belong to one of the
  given classes (or descendants).
 
 I like it. (In the list we may accept strings - to use with isa()
 - and regexes - to use with ref() - , I suppose.)

There's still room for this improvement. (I just changed the behaviour
to pass objects intact and added a test case for an object that has no
stringification overload. I wanted to show you the patch first, but I
wasn't quick enough. Feel free to change it.)

norbi

___
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