Giter Club home page Giter Club logo

dbix-class-helpers's People

Contributors

abraxxa avatar avar avatar bluefeet avatar bockscar avatar cybersiddhu avatar dboehmer avatar derobert avatar domm avatar felliott avatar frioux avatar getty avatar gregoa avatar karenetheridge avatar kbenson avatar kwakwaversal avatar manwar avatar nothingmuch avatar ntyni avatar oalders avatar rabbiveesh avatar ribasushi avatar wesq3 avatar wreis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

dbix-class-helpers's Issues

OrderByMagic thoughts

Just looking at the code again, and have two thoughts:

  1. Do we really need to join current_source_alias? What if person wants to order by a column from a join? Then it'd be an incorrect query, e.g. me.join_name.col.

  2. I didn't account for ArrayRefs for pass through. I just saw that in the example you can pass an ArrayRef to the parent order_by.

[PATCH] Fix a strictness error in a deprecated module

In Debian we are currently applying the following patch to
DBIx-Class-Helpers.
We thought you might be interested in it too.

From 3502789f7aaabf4490fb060e238d69258704ee26 Mon Sep 17 00:00:00 2001
From: Niko Tyni <[email protected]>
Date: Fri, 19 Sep 2014 12:54:58 +0300
Subject: [PATCH] Fix a strictness error in a deprecated module

The deprecation messages refer to $VERSION, which isn't
declared despite 'use strict'. This causes a compile
time error.

The patch is tracked in our Git repository at
https://anonscm.debian.org/cgit/pkg-perl/packages/libdbix-class-helpers-perl.git/plain/debian/patches/0001-Fix-a-strictness-error-in-a-deprecated-module.patch

Thanks for considering,
gregor herrmann,
Debian Perl Group

correlate `AS fieldname`

As discussed on IRC 16.52 June 9th 2016, it would be nice to allow for 'nameing a correlate field at the database level' to allow for sorting on the correlate result.

We discussed adding the following to the correlate call syntax:

 $rs->correlate('foo', { as => 'foo' });

Use of uninitialized value $DBIx::Class::Helper::ResultSet::VERSION

$ perl -MDBIx::Class::Helper::ResultSet -le 'print $DBIx::Class::Helper::ResultSet::VERSION'
Use of uninitialized value $DBIx::Class::Helper::ResultSet::VERSION in numeric ge (>=) at /Users/bill/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/DBIx/Class/Helper/ResultSet/VirtualView.pm line 18.
Use of uninitialized value $DBIx::Class::Helper::ResultSet::VERSION in numeric ge (>=) at /Users/bill/perl5/perlbrew/perls/perl-5.16.1/lib/site_perl/5.16.1/DBIx/Class/Helper/ResultSet/VirtualView.pm line 19.
2.017000

so 'use parent' acts like a BEGIN so it runs before the version is set, it seems.

Are you using dzil to add the version? Adding BEGIN fixes:

BEGIN {
$DBIx::Class::Helper::ResultSet::VERSION = '2.017000';
}

DBIx::Class::Helper::Row::OnColumnMissing returns an empty list in list context

When a DBIx::Class::Result uses this helper it changes the behavior of column accessor methods in newly created objects.

package MyApp::Schema::TestAccessor;
use warnings;
use strict;
use base qw( DBIx::Class::Core );

__PACKAGE__->load_components('Helper::Row::OnColumnMissing');
__PACKAGE__->table('test_accessor');
__PACKAGE__->add_columns(
  id => { },
  title => { },
  user_id => {},
);

sub on_column_missing {'nothing'}

1;
my $obj = $schema->resultset("TestAccessor")->create({id=>2,user_id=>1});
$obj->title; # undef
my @answers = $obj->title; # ()

But:

my $obj = $schema->resultset("TestAccessor")->find(2);
$obj->title; # undef
my @answers = $obj->title; # (undef)

Make dont_serialize in Helper::Row::ToJSON a package global?

Would be nice for https://github.com/frioux/DBIx-Class-Helpers/blob/master/lib/DBIx/Class/Helper/Row/ToJSON.pm#L12-L16 to be a package global, or expose "dont_serialize" in a sane manner to allow easily changing the default column types which shouldn't be serialised.

At $work we're using PostgreSQL, and using the text column instead of varchar (as they're synonymous). As such, all the text columns are being ignored by default.

Currently having to overload it directly which returns some of ToJSONs helpfulness to the boiler room. :( :)

use strict;
use warnings;

use base qw/DBIx::Class::Core/;

__PACKAGE__->load_components(qw/InflateColumn::DateTime Helper::Row::ToJSON/);

my $dont_serialize = {
        ntext => 1,
        blob  => 1,
};

sub _is_column_serializable {
   my ( $self, $column ) = @_;

   my $info = $self->column_info($column);

   if (!defined $info->{is_serializable}) {
      if (defined $info->{data_type} &&
          $dont_serialize->{lc $info->{data_type}}
      ) {
         $info->{is_serializable} = 0;
      } else {
         $info->{is_serializable} = 1;
      }
   }

   return $info->{is_serializable};
}

1;

Happy to help with a PR if you can let me know your preferred method to make this easier to implement.

lots of test modules are indexed

I see all these modules added to the index which probably shouldn't be:

+A::ResultSet::DateMethods1            undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+A::Role::TestConnect                  undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+A::Util                               undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+Lolbot                                undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+ParentRS                              undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+ParentSchema                          undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+ParentSchema::Result                  undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+ParentSchema::Result::Bar             undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+ParentSchema::Result::Foo             undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+RS                                    undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema                            0.001  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Bar               undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Bloaty            undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Foo               undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Foo_Bar           undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Gnarly            undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Gnarly_Station      undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::HasAccessor       undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::HasDateOps        undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::Result::Station           undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet                 undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::Bloaty         undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::Foo            undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::Gnarly         undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::HasAccessor      undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::HasDateOps      undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz
+TestSchema::ResultSet::Station        undef  F/FR/FREW/DBIx-Class-Helpers-2.023003.tar.gz

DBIx::Class::Helper::ResultSet does not include all helpers.

The POD promises to have all in one:

This is just a simple Helper helper that includes all of the ResultSet Helpers in one convenient module.

But in reality only includes these 4:

use parent qw{
   DBIx::Class::Helper::ResultSet::IgnoreWantarray
   DBIx::Class::Helper::ResultSet::Random
   DBIx::Class::Helper::ResultSet::Union
   DBIx::Class::Helper::ResultSet::VirtualView
};

Make all helpers verify that they got composed into the right type (Result, Set, Schema) of class

08:46:05 ribasushi | <ribasushi> frew: ^^ (last ~10ish lines) perhaps a C::C3::C post-apply hook check that
                   | someone tried to add a resultset helper to a result, or something....?
08:46:29      frew | right I saw that but I don't see why you think that?
08:47:13      frew | like, he posted a thing where he did something stupid, and it has a stacktrace that is a
                   | little confusing but it's hard when someone does something crazy like use an RS component in
                   | a result
08:47:26 ribasushi | because when people end up doing this, the failure ( site / exception text ) is completely
                   | impenetrable unless you know what to look for
08:47:32      frew | ooohhh
08:47:41 ribasushi | mainly because add_columns clashes (both in resultsource proxy and in your helper )
08:47:42      frew | you are recommending a possible additional helper base to check
08:47:44      frew | I hear you
08:48:03 ribasushi | so the very next thing after load_components is CXSA barfing because it is called on a class
08:48:10      frew | right I see
08:48:14 ribasushi | yes!
08:48:14 ribasushi | :)
08:48:33      frew | I'll add it to the list

clarify onerow's doc some

21:41:38 aran | looking good.  althought I wouldn’t call it more correct than first.  first treats the result*set* like a set, so from  
              | an guts standpoint its as correct as it gets
21:43:00 aran | I’d also personally note that this should, for the sake of portability, just always be used when you want just the first
              | row available and no more no matter what, whether or not it improves anything.  Give it a best-practices bent.
21:44:01 frew | yeah I should document that; how often do people $rs->first and then $rs->next through the rest of the list? (I guess
              | almost neveR)
21:44:14 aran | aye

one_row can be made much more efficient

02:05:20 ribasushi | one_row can be made much more efficient, if you aren't worried about calling things that can go away at a later date
02:06:09 ribasushi | calling single is vastly cheaper than next (there is no intermediate DBIx::Class::Storage::Cursor instantiation)
02:06:46 ribasushi | you would need to call ->_resolved_attrs, and then look whether collapse is set and call one or the other
02:07:18 ribasushi | this will also bypass ::Cursor::Cached if one is using it so keeping things calling ->next may be ok
02:07:42 ribasushi | just laying out musings, nothing catastrophically wrong with what you have now

Simply loading AutoRemoveColumns seems to interfere with DBICs group_by inferrence

~dbic_repo$ perl -Ilib -It/lib -MDBICTest -MDevel::Dwarn -e '
  Dwarn [ DBICTest->init_schema
                   ->resultset("Artist")
                    ->search({}, { group_by => "name" })
                     ->count_rs
                      ->as_query ]
'

vs

~dbic_repo$ perl -Ilib -It/lib -MDBICTest -MDevel::Dwarn -e '
  require DBICTest::BaseResultSet;
  DBICTest::BaseResultSet->load_components("Helper::ResultSet::AutoRemoveColumns");
  Dwarn [ DBICTest->init_schema
                   ->resultset("Artist")
                    ->search({}, { group_by => "name" })
                     ->count_rs
                      ->as_query ]
'

P.S. This is the problem with http://lists.scsys.co.uk/pipermail/dbix-class/2017-October/012682.html, user has already been informed about this issue.

t/ResultSet/DateMethods1/oracle.t failure

Oracle InstantClient 12.1.0.2.0 on Linux 64bit, DBIx::Class::Helpers version 2.032000:

[ahartmai@ahartmai-nb:~/perl5/perlbrew/perls/22$ (master)]$ cpanm --look DBIx::Class::Helpers
[ahartmai@ahartmai-nb:~/.cpanm/work/1448628618.8509/DBIx-Class-Helpers-2.032000$ ]$ export DBIC_TRACE=1
[ahartmai@ahartmai-nb:~/.cpanm/work/1448628618.8509/DBIx-Class-Helpers-2.032000$ ]$ perl -MCarp::Always t/ResultSet/DateMethods1/oracle.t
    # Subtest: Oracle
        # Subtest: basic
alter session 
  SET nls_date_format = 'YYYY-MM-DD HH24:MI:SS'
alter session 
  SET nls_timestamp_format = 'YYYY-MM-DD HH24:MI:SS.FF'
alter session 
  SET nls_timestamp_tz_format = 'YYYY-MM-DD HH24:MI:SS.FF TZHTZM'

DROP TABLE "Gnarly" CASCADE CONSTRAINTS

CREATE TABLE "Gnarly"( "id" number, NOT NULL, "name" varchar2( 4000 ) NOT NULL, "literature" clob, "your_mom" blob, PRIMARY KEY( "id" ) )

DROP TABLE "HasDateOps" CASCADE CONSTRAINTS

CREATE TABLE "HasDateOps"( "id" number, NOT NULL, "a_date" date NOT NULL, "b_date" date, PRIMARY KEY( "id" ) )
        ok 1 - utc_now
        ok 2 - no floating dates
        ok 3 - datetime correctly UTC and stringified
DELETE FROM "HasDateOps"
INSERT INTO "HasDateOps"( "a_date", "id" ) 
  VALUES( sys_extract_utc( SYSTIMESTAMP ), '1' )
SELECT "me"."id", "me"."a_date", "me"."b_date" 
  FROM "HasDateOps" "me"
        ok 4 - UTC works! (and clock is correct)
        1..4
    ok 1 - basic
        # Subtest: comparisons
DELETE FROM "HasDateOps"
BEGIN WORK
INSERT INTO "HasDateOps"( "a_date", "id" ) 
  VALUES( ?, ? ) : '__BULK_INSERT__'
COMMIT
            # Subtest: datetime object
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 1 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 2 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 3 - manual prefix
            1..3
        ok 1 - datetime object
            # Subtest: datetime literal
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 1 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 2 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < '2012-12-13 00:00:00'
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= '2012-12-13 00:00:00'
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= '2012-12-13 00:00:00'
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > '2012-12-13 00:00:00'
                ok 4 - after
                1..4
            ok 3 - manual prefix
            1..3
        ok 2 - datetime literal
            # Subtest: subquery
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 4 - after
                1..4
            ok 1 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 4 - after
                1..4
            ok 2 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > ( 
    SELECT "me"."a_date" 
      FROM "HasDateOps" "me" 
    WHERE "id" = '2'
   )
                ok 4 - after
                1..4
            ok 3 - manual prefix
            1..3
        ok 3 - subquery
            # Subtest: both columns
DELETE FROM "HasDateOps"
BEGIN WORK
INSERT INTO "HasDateOps"( "a_date", "b_date", "id" ) 
  VALUES( ?, ?, ? ) : '__BULK_INSERT__'
COMMIT
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 1 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 2 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 3 - manual prefix
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < "b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= "b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= "b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > "b_date"
                ok 4 - after
                1..4
            ok 4 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "b_date"
                ok 4 - after
                1..4
            ok 5 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "b_date"
                ok 4 - after
                1..4
            ok 6 - manual prefix
                # Subtest: no prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 7 - no prefix
                # Subtest: auto prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 8 - auto prefix
                # Subtest: manual prefix
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" < "me"."b_date"
                ok 1 - before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" <= "me"."b_date"
                ok 2 - on_or_before
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" >= "me"."b_date"
                ok 3 - on_or_after
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."a_date" > "me"."b_date"
                ok 4 - after
                1..4
            ok 9 - manual prefix
            1..9
        ok 4 - both columns
            # Subtest: literal SQL
SELECT "me"."id" 
  FROM "HasDateOps" "me" 
WHERE "me"."b_date" < sys_extract_utc( SYSTIMESTAMP )
            ok 1 - literal SQL compared (and db clock correct)
            1..1
        ok 5 - literal SQL
        1..5
    ok 2 - comparisons
        # Subtest: add
DELETE FROM "HasDateOps"
BEGIN WORK
INSERT INTO "HasDateOps"( "a_date", "id" ) 
  VALUES( ?, ? ) : '__BULK_INSERT__'
COMMIT
SELECT( TO_TIMESTAMP( "a_date" ) + NUMTODSINTERVAL( '1', 'DAY' ) ) 
  FROM "HasDateOps" "me" 
WHERE "id" = '1'
        ok 1 - live day
        ok 2 - suspected day
        ok 3 - unit: day
SELECT( TO_TIMESTAMP( "a_date" ) + NUMTODSINTERVAL( '2', 'HOUR' ) ) 
  FROM "HasDateOps" "me" 
WHERE "id" = '1'
        ok 4 - live hour
        ok 5 - suspected hour
        ok 6 - unit: hour
SELECT( TO_TIMESTAMP( "a_date" ) + NUMTODSINTERVAL( '3', 'MINUTE' ) ) 
  FROM "HasDateOps" "me" 
WHERE "id" = '1'
        ok 7 - live minute
        ok 8 - suspected minute
        ok 9 - unit: minute
SELECT( TO_TIMESTAMP( "a_date" ) + NUMTODSINTERVAL( '5', 'SECOND' ) ) 
  FROM "HasDateOps" "me" 
WHERE "id" = '1'
        ok 10 - live second
        ok 11 - suspected second
        ok 12 - unit: second
        ok 13 - vanilla add
DELETE FROM "HasDateOps"
INSERT INTO "HasDateOps"( "a_date", "id" ) 
  VALUES( '2013-12-11 10:09:08', '1' )
            # Subtest: column
SELECT "foo" 
  FROM ( 
    SELECT ( TO_TIMESTAMP( TO_TIMESTAMP( TO_TIMESTAMP( "me"."a_date" ) + NUMTODSINTERVAL( '2', 'MINUTE' ) ) + NUMTODSINTERVAL( '4', 'SECOND' ) ) + NUMTODSINTERVAL( '1', 'HOUR' ) ) AS "foo" 
      FROM "HasDateOps" "me"
   ) "me" 
WHERE ROWNUM <= '1'
            # Child (column) exited without calling finalize()
        not ok 14 - column
        #   Failed test 'column'
        #   at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Carp/Always.pm line 28.
        # Child (add) exited without calling finalize()
    not ok 3 - add
    #   Failed test 'add'
    #   at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Carp/Always.pm line 28.
Invalid date format: 2013-12-11 11:11:12.000000000 at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/DateTime/Format/Oracle.pm line 140.
    DateTime::Format::Oracle::parse_datetime("DateTime::Format::Oracle", "2013-12-11 11:11:12.000000000") called at t/lib/A/ResultSet/DateMethods1.pm line 130
    A::ResultSet::DateMethods1::parse_datetime(A::ResultSet::DateMethods1=HASH(0x2992c68), "2013-12-11 11:11:12.000000000") called at t/lib/A/ResultSet/DateMethods1.pm line 343
    A::ResultSet::DateMethods1::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "column", CODE(0x3a04138)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("column", CODE(0x3a04138)) called at t/lib/A/ResultSet/DateMethods1.pm line 351
    A::ResultSet::DateMethods1::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 118
    Test::Roo::Class::each_test(A::ResultSet::DateMethods1=HASH(0x2992c68), CODE(0x19051d8)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 38
    Test::Roo::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 39
    Test::Roo::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at (eval 85) line 16
    A::ResultSet::DateMethods1::_do_tests(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 87
    Test::Roo::Class::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 89
    Test::Roo::Class::run_tests("A::ResultSet::DateMethods1", "Oracle") called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/DateTime/Format/Oracle.pm line 140.
    DateTime::Format::Oracle::parse_datetime("DateTime::Format::Oracle", "2013-12-11 11:11:12.000000000") called at t/lib/A/ResultSet/DateMethods1.pm line 130
    A::ResultSet::DateMethods1::parse_datetime(A::ResultSet::DateMethods1=HASH(0x2992c68), "2013-12-11 11:11:12.000000000") called at t/lib/A/ResultSet/DateMethods1.pm line 343
    A::ResultSet::DateMethods1::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "column", CODE(0x3a04138)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("column", CODE(0x3a04138)) called at t/lib/A/ResultSet/DateMethods1.pm line 351
    A::ResultSet::DateMethods1::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 118
    Test::Roo::Class::each_test(A::ResultSet::DateMethods1=HASH(0x2992c68), CODE(0x19051d8)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 38
    Test::Roo::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 39
    Test::Roo::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at (eval 85) line 16
    A::ResultSet::DateMethods1::_do_tests(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 87
    Test::Roo::Class::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 89
    Test::Roo::Class::run_tests("A::ResultSet::DateMethods1", "Oracle") called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 279.
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "column", CODE(0x3a04138)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("column", CODE(0x3a04138)) called at t/lib/A/ResultSet/DateMethods1.pm line 351
    A::ResultSet::DateMethods1::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 118
    Test::Roo::Class::each_test(A::ResultSet::DateMethods1=HASH(0x2992c68), CODE(0x19051d8)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 38
    Test::Roo::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 39
    Test::Roo::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at (eval 85) line 16
    A::ResultSet::DateMethods1::_do_tests(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 87
    Test::Roo::Class::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 89
    Test::Roo::Class::run_tests("A::ResultSet::DateMethods1", "Oracle") called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 279.
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("add", CODE(0x2993388)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo.pm line 39
    Test::Roo::__ANON__(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at (eval 85) line 16
    A::ResultSet::DateMethods1::_do_tests(A::ResultSet::DateMethods1=HASH(0x2992c68)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 87
    Test::Roo::Class::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 261
    Test::Builder::__ANON__() called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    eval {...} called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 266
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 89
    Test::Roo::Class::run_tests("A::ResultSet::DateMethods1", "Oracle") called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/Builder.pm line 279.
    Test::Builder::subtest(Test::Builder=HASH(0xdee7a8), "Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/5.22.0/Test/More.pm line 771
    Test::More::subtest("Oracle", CODE(0x13331e0)) called at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Test/Roo/Class.pm line 89
    Test::Roo::Class::run_tests("A::ResultSet::DateMethods1", "Oracle") called at t/ResultSet/DateMethods1/oracle.t line 18
    # Child (Oracle) exited without calling finalize()
not ok 1 - Oracle
#   Failed test 'Oracle'
#   at /home/ahartmai/perl5/perlbrew/perls/22/lib/site_perl/5.22.0/Carp/Always.pm line 28.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 1.

Hella Fast JSON Encoder

15:52:26 ribasushi | so - first of all JSON _en_coding is rather well contained, best seen here: https://metacpan.org/source/SRI/Mojolicious-7.0/lib/Mojo/JSON.pm#L209-260
15:53:26      frew | ok
15:53:51 ribasushi | then if you teach DBIC to recognize a specifc HRI-like class on the lowest possible level like so:
                   | https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082840/lib/DBIx/Class/ResultSet.pm#L1382-1390
15:53:59      frew | ooooooooh
15:54:18 ribasushi | you can then assemble a parser like so: https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082840/lib/DBIx/Class/ResultSet.pm#L1432-1439
15:54:26 ribasushi | and DBIC will use it properly
15:55:17 ribasushi | https://metacpan.org/source/RIBASUSHI/DBIx-Class-0.082840/lib/DBIx/Class/ResultSource/RowParser/Util.pm
15:55:27 ribasushi | search for hri_style in this file
15:55:37 ribasushi | it will make it clear how to implement json_style as well
15:55:46 ribasushi | once all of this is assembled/compiled
15:55:53      frew | cool
15:55:56 ribasushi | you have completely functioncall-free JSON assembly
15:56:02      frew | right
15:56:06 ribasushi | just like you have the infres/hri one
15:56:28 ribasushi | which while still in perl space, is going to be a simple loop, and I am pretty sure will beat any transfer to C space

AutoRemoveColumns should not override an explicit columns attribute

I tried this. Note that Pool::Passholder's holder_photo is a bytea, so is auto-removed:

my $row = $c->model('Pool::Passholder')->find($passholder_no, { key => 'primary', columns => [ 'holder_photo' ] })

And was rather surprised when it selected all the columns except holder_photo. It turns out it completely ignored the columns attribute.

This appears to be a bug in how RemoveColumns is implemented. A trivial fix is:

Index: libdbix-class-helpers-perl-2.019004/lib/DBIx/Class/Helper/ResultSet/RemoveColumns.pm
===================================================================
--- libdbix-class-helpers-perl-2.019004.orig/lib/DBIx/Class/Helper/ResultSet/RemoveColumns.pm   2014-02-14 08:53:27.0000
+++ libdbix-class-helpers-perl-2.019004/lib/DBIx/Class/Helper/ResultSet/RemoveColumns.pm        2014-04-05 13:36:38.2834
@@ -13,7 +13,7 @@

    my $attrs  = $self->{attrs}; # not copying on purpose...

-   if ( $attrs->{remove_columns} ) {
+   if ( !$attrs->{columns} && $attrs->{remove_columns} ) {
       my %rc = map { $_ => 1 } @{$attrs->{remove_columns}};
       $attrs->{columns} = [
          grep { !$rc{$_} } $self->result_source->columns

not_null shortcut

What do you think about having a not_null shortcut?

Example from my own use:

=head2 not_null($column)

Ensure that given C<$column> is not null.

=cut

sub not_null {
    my ($self, $column) = @_;

    return $self->search_rs({ $self->me($column) => { '!=' => undef } });
}

Problem installing on debian Stretch

Hi there,

Currently there is a problem installing DBIx-Class-Helpers in Debian Stretch and possibly on most modern perl version. There is a dependency down the tree that won't install. DBIx-Class-Helpers depends on DBIx-Class-Candy which in turn depends on String-CamelCase. String-CamelCase has this issue open which seems to be the effect of some new feature for hardening perl against CVE-2016-1238. As explained here there is a workaround export PERL_USE_UNSAFE_INC=1 but I'm guessing this will hit users more and more as they upgrade. This is not an issue of DBIx-Class-Helpers itself, but I wanted to report it here just in case since it does render the package uninstallable from CPAN on recent perl versions.

Thanks for your time.

Create a ::ResultClass::Tee

@Relequestual needed something like this and I think it would be both generally useful and a great example on how to make custom ResultClasses

@frew | package MyApp::Schema::ResultClass::Tee; sub new { return [ ::HRI->new(@_), ::Foo->new(@_) ] }
@frew | the hard part is that you'll want to store the name of ::Foo (say, MyApp::Schema::Result::User) in an attr, so you'll have to make
      | an instantiation method other than new

A tad cleaner ProxyResultMethod

While reading #39 I was looking at this and it occurred to me it can be improved a bit: only resort to internals grubbing in order to "touch" the slot into existence. Afterwards use set_column as usual to reinvoke the dirty/cache-invalidate/etc machinery.

SetOperations UNION needs extra brackets (PostgreSQL)?

Hello,
I am using SetOperations union() method. I found that when the two queries to be combined in the union have ORDER BY or LIMIT clauses within them, PostgreSQL complains of a syntax error. This is because the two queries should be contained within round brackets "()" before adding the UNION.

However within SetOperations.pm there is the following which seems intended to strip these brackets:

What I did as a patch, which works well in PostgreSQL, is to comment out this line and also add round brackets explicitly to each query (much like line 80, in fact):
$sql = q<(> . $sql . q<)>;

Can you let me know whether you want this behaviour or not? I will not be offended if you close the ticket! However at the moment I have monkeypatched SetOperations locally to allow the UNION queries to have ORDER BY and LIMIT.

Thanks,
Oliver.

Pg DateMethods1 dt_SQL_add with parameter

Basically the following does not work because the parameters type is unknown:

 $self->dt_SQL_add($enddate, 'day', 1)

easy fix is to inject date ? into the sql. Might be able to coerce DBD::Pg for prettier SQL. Might not be worth the effort.

Fix ResultsExist

Looks like when I "fixed" ResultsExist I broke it :(

Here's some info:

11:24:33     Perlkonig | https://metacpan.org/source/FREW/DBIx-Class-Helpers-2.031000/lib/DBIx/Class/Helper/ResultSet/Shortcut/ResultsExist.pm <- heh, and
                       | there's ->first again :-)
11:25:30    @ribasushi | frew: ^^ that's indeed odd
11:25:47         @frew | not totally sure I wrote that
11:25:54         @frew | the Shortcuts were mostly contributed
11:26:01    @ribasushi | frew: I'd go for rows => 1 + next, so it implicitly exhausts
11:26:19    @ribasushi | ( in addition to the EXISTS )
11:26:20         @frew | but fwiw, there was a LONG time where I heard a lot of conflicting information about first, next, and single
11:27:23     Perlkonig | wait, what SQL does that even generate? "SELECT EXISTS (SELECT ...);"?
11:27:39     Perlkonig | no, that's way off
11:29:08     Perlkonig | "SELECT * FROM table WHERE EXISTS (SELECT ...);"?
11:29:23         @frew | something along those lins
11:29:29         @frew | you could run it and see :)
11:29:32     Perlkonig | so that would return either no rows, or all rows
11:29:35         @frew | no
11:29:50         @frew | the query would, but we don't fetch it all
11:30:21         @frew | Perlkonig: https://metacpan.org/pod/DBIx::Class::Helper::ResultSet::Shortcut#results_exist
11:30:24         @frew | the doc might help?
11:31:41     Perlkonig | oh, I thought it was undocumented
11:31:52     Perlkonig | I saw it in https://metacpan.org/release/DBIx-Class-Helpers but it had no POD
11:32:03         @frew | yeah it's sorta internal to ::Shortcut
11:32:12     Perlkonig | I did run it
11:32:14     Perlkonig | I was right
11:32:21         @frew | I figured ::Shortcut wouldb e easier if everything were documnted in one place
11:32:24     Perlkonig | it also runs out of memory because it fetches all rows
11:32:25         @frew | Perlkonig: do you use postgres?
11:32:43     Perlkonig | in general, yes, but this app also needs to access a mysql db
11:32:44         @frew | sounds like you are a pg user expecting all dbd's to be as silly as yours :)
11:32:51    @ribasushi | errrrr
11:32:52             * | ribasushi looks closer at the thing
11:33:03    @ribasushi | frew: this is actually entirely incorrect (putting it in where)
11:33:05     Perlkonig | so yeah, ResultsExist is completely broken
11:33:32             * | frew looks at test
11:33:36    @ribasushi | you want to SELECT EXISTS (....) FROM <something, doesn't matter what)
11:33:53    @ribasushi | which will always return 1 row, with a boolean in the 1st col
11:34:11     Perlkonig | or just do the { rows => 1 } thing again
11:34:20     Perlkonig | hmm, but that would still have to transfer all columns
11:34:49         @frew | patches welcome?
11:34:53         @frew | I haven't actually used this helper

11:34:53    @ribasushi | frew: sorry I didn't catch that back when you wrote it, I should have seen that :/
11:35:02         @frew | ribasushi: again: I didn't write it :)
11:35:06         @frew | it was contributed
11:35:09    @ribasushi | hm... was it oalders maybe?
11:35:12         @frew | yessir
11:35:12             * | ribasushi fuzzy
11:35:22         @frew | https://github.com/frioux/DBIx-Class-Helpers/blame/master/lib/DBIx/Class/Helper/ResultSet/Shortcut/ResultsExist.pm
11:35:32    @ribasushi | oalders: ^^ read past ~15 lines
11:35:37       oalders | ok
11:35:43     Perlkonig | - Add ::Shortcut::ResultsExist RS helper (Olaf Alders)
11:35:44         @frew | anyway I'm totally interested in fixing it, I just won't take the blame :)
11:35:46     Perlkonig | oh, too late
11:36:07       oalders | ribasushi: that's a copy/paste of some code you gave me
11:36:08         @frew | hm
11:36:11       oalders | but it seems to work for me
11:36:16         @frew | did I break it somehow? https://github.com/frioux/DBIx-Class-Helpers/commit/fd4024322fb7601352f2caf1ab6c5873f6ea6263
11:36:29         @frew | oalders: they are claiming that while it may work, it pulls in the whole table
11:36:36    @ribasushi | oalders: it works, it's just very inefficient
11:36:43       oalders | yeah, that's not at all what we wanted
11:36:44         @frew | I'm theorizing that it works for everyting but pg
11:36:48     Perlkonig | it works if your table is small enough to fit into memory
11:36:49         @frew | but I don't really know
11:37:28       oalders | i'm using it on Pg. obviously didn't realize there's an issue
11:37:38    @ribasushi | frew: yeah - the original https://github.com/frioux/DBIx-Class-Helpers/commit/fd402432 has the select => ...
11:37:46         @frew | iirc that actually failed tests
11:37:52         @frew | or I'dve left it alone
11:38:01     Perlkonig | I'm running out of memory on a mysql table with 6917243 rows :-)
11:38:10    @ribasushi | right - but the fix changed the concept entirely ;)
11:38:12         @frew | Perlkonig: at the client or the server?
11:38:40       oalders | https://github.com/frioux/DBIx-Class-Helpers/pull/25
11:38:51     Perlkonig | frew: client
11:38:54         @frew | huh
11:39:07     Perlkonig | perl gets oom-killed or runs into ulimits
11:39:11         @frew | sure sure
11:39:58         @frew | ribasushi: so yeah, with his original you get a SQL syntax error
11:40:02    @ribasushi | Perlkonig: problem has been identified, if frew and oalders doesn't have time to fixxxor it - perhaps you can lend a hand? :)
11:40:02         @frew | maybe a bug in core dbic?
11:40:12         @frew | DBIx::Class::Storage::DBI::_prepare_sth(): DBI Exception: DBD::SQLite::db prepare_cached failed: near "(": syntax error [for Statement
                       | "SELECT EXISTS( (SELECT "me"."id", "me"."bar_id" FROM "Foo" "me" WHERE ( "id" > ? )) ) FROM "Foo" "me""] at
                       | t/ResultSet/Shortcut/ResultsExist.t line 16
11:40:41     Perlkonig | that doesn't look right to me either
11:40:43    @ribasushi | frew: sqlite is choking on (( ))
11:40:48     Perlkonig | you don't want to select from Foo
11:40:55         @frew | oalders: fwiw, I could change it back to what you had and only test against pg
11:41:10         @frew | I have that capability in the helpers, and there are some helpers that don't support some engines
11:41:38    @ribasushi | Perlkonig: one needs to select from "somewhere" on most engines
11:41:50             * | frew could regex out the () but that seems perilous
11:41:57         @frew | ribasushi: thoughts re the parens?
11:42:19     Perlkonig | ribasushi: yeah, but then you need some kind of restriction (like rows => 1!), or you'll get as many results as there are rows in the
                       | table
11:42:47    @ribasushi | Perlkonig: yes that's a fair point too
11:43:01     Perlkonig | this is like  (map { exists $foo{key} } keys %foo)
11:43:02     Perlkonig | sort of
11:43:20    @ribasushi | frew: I'd say most expedient is 'EXISTS ' . ${$asq}->[0]
11:44:13         @frew | bummer
11:44:21     Perlkonig | ... in that case, why even bother with exists?
11:44:30     Perlkonig | select 1 from Foo limit 1  
11:44:49         @frew | Perlkonig: well the whole thing is if your db engine needs some other way of checking existence
11:45:00         @frew | I mean, for some people I think doing a limit at all can be pricy?
11:45:05         @frew | it varies from engine to engine
11:45:10    @ribasushi | Perlkonig: because something needs to apply all the $rs conditions
11:45:11         @frew | ribasushi might know better
11:45:33     Perlkonig | ah, true
11:46:04    @ribasushi | Perlkonig: basically the original thinking is to have a proper subquery and hint the optimizer "I just want to know if there's
                       | anything" for portaility
11:46:27    @ribasushi | instead of descending into the nightmares that are limits, and various codepaths depending on the $rs attributes
11:46:40    @ribasushi | nevertheless - given the amount of fail, it may be warranted
11:47:00    @ribasushi | s/warranted/necessary/
11:47:09     Perlkonig | I don't see how you can do this portably without a generic 1-row relation to select from
11:47:10         @frew | s/necesarry/wantarray/
11:47:29    @ribasushi | Perlkonig: in the current form - it won't work this is true  
11:47:56    @ribasushi | Perlkonig: but there may be a portable-ish FROM <> spec or somesuch
11:48:05    @ribasushi | someone needs to do the research basically
11:48:27             * | ribasushi is braincycle-booked for the next week or so, thus someone else stepping up would be awesome
11:50:34     Perlkonig | what do I need to do if I want to write my own dbic component? 
11:50:49         @frew | subclass something, maybe less
11:51:14     Perlkonig | ... huh?
11:51:22         @frew | Perlkonig: like, a component is just a perl package
11:51:44         @frew | you set your base class so that C3 knows what to do (likely DBIx::Class::Core or DBIx::Class::ResultSet)
11:51:53         @frew | and then load the component with load_components
11:52:33             * | frew adds DBICH issue re ResultsExist

wrong return precedence [cpan #87311]

https://rt.cpan.org/Public/Bug/Display.html?id=87311
returns binds stronger than and, so the expressions after and are ignored.
See https://rt.perl.org/rt3/Public/Bug/Display.html?id=59802

diff -bu ./t/row/numifyget.t~ ./t/row/numifyget.t
--- ./t/row/numifyget.t~    2013-07-02 20:40:24.000000000 -0500
+++ ./t/row/numifyget.t 2013-07-25 10:01:23.852572001 -0500
@@ -19,9 +19,9 @@
    my $value = shift;
    my $b_obj = B::svref_2object(\$value);
    my $flags = $b_obj->FLAGS;
-   return ( $flags & B::SVf_IOK or $flags & B::SVp_IOK
+   return (( $flags & B::SVf_IOK or $flags & B::SVp_IOK
           or $flags & B::SVf_NOK or $flags & B::SVp_NOK
-        ) and !($flags & B::SVf_POK )
+           ) and !($flags & B::SVf_POK ))
 }

ToJSON misconvert integer to string

When convert Row data to json using ToJSON, the column with integer type will be converted to string. Of course, I could make the value to integer via $a + 0. Is there anyway auto do that, make sure the integer column to integer.
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.