Merge 'storage-interbase' into 'trunk'
Rafael Kitover [Sun, 7 Mar 2010 10:55:06 +0000 (10:55 +0000)]
r23004@hlagh (orig r8530):  moritz | 2010-02-04 07:41:29 -0500
create branch for Storage::DBI::InterBase

r23005@hlagh (orig r8531):  moritz | 2010-02-04 07:44:02 -0500
primitive, non-working and very specific Storage::DBI::InterBase
r23006@hlagh (orig r8532):  moritz | 2010-02-04 08:00:05 -0500
[Storage::DBI::InterBase] remove cruft copied from MSSQL
r23008@hlagh (orig r8534):  moritz | 2010-02-04 08:34:22 -0500
[Storage::DBI::InterBase] remove more cruft
r23014@hlagh (orig r8540):  caelum | 2010-02-04 10:08:27 -0500
test file for firebird, not passing yet
r23015@hlagh (orig r8541):  caelum | 2010-02-04 11:24:51 -0500
Firebird: fix test cleanup, add ODBC wrapper
r23016@hlagh (orig r8542):  caelum | 2010-02-04 13:18:48 -0500
limit and better autoinc for Firebird
r23018@hlagh (orig r8544):  caelum | 2010-02-04 14:19:51 -0500
override quoting columns for RETURNING in Firebird ODBC (where it doesn't work) and generate a RETURNING clause only when necessary
r23022@hlagh (orig r8548):  caelum | 2010-02-05 03:55:43 -0500
fix up my Row code for non-pk autoincs, add pretty crappy DT inflation for Firebird
r23023@hlagh (orig r8549):  caelum | 2010-02-05 04:26:03 -0500
rename a couple of variables
r23024@hlagh (orig r8550):  caelum | 2010-02-05 04:46:31 -0500
check for both NULL and null, rename _fb_auto_incs to _auto_incs
r23025@hlagh (orig r8551):  caelum | 2010-02-05 05:07:14 -0500
support autoinc PKs without is_auto_increment set
r23047@hlagh (orig r8570):  caelum | 2010-02-06 07:35:31 -0500
move Firebird ODBC override for RETURNING to a SQLAHacks class
r23048@hlagh (orig r8571):  caelum | 2010-02-06 08:06:44 -0500
Firebird: add POD, fix BLOB tests
r23085@hlagh (orig r8588):  caelum | 2010-02-08 08:26:41 -0500
better DT inflation for Firebird and _ping
r23087@hlagh (orig r8590):  moritz | 2010-02-08 08:32:26 -0500
test ->update({...}) for firebird
r23088@hlagh (orig r8591):  caelum | 2010-02-08 08:33:09 -0500
test update
r23089@hlagh (orig r8592):  moritz | 2010-02-08 08:43:50 -0500
use quoting in firebird tests
r23115@hlagh (orig r8597):  caelum | 2010-02-10 07:05:21 -0500
default to sql dialect 3 unless overridden
r23116@hlagh (orig r8598):  caelum | 2010-02-10 07:42:17 -0500
turn on ib_softcommit, savepoint tests now pass for DBD::InterBase
r23123@hlagh (orig r8605):  caelum | 2010-02-10 17:38:24 -0500
fix savepoints for Firebird ODBC
r23170@hlagh (orig r8652):  caelum | 2010-02-11 07:27:19 -0500
support the DATE data type for Firebird
r23186@hlagh (orig r8668):  caelum | 2010-02-12 14:43:20 -0500
special bind_param_array move to make DBD::InterBase happy (RT#54561)
r23213@hlagh (orig r8695):  caelum | 2010-02-13 15:15:46 -0500
fix fail in t/72pg.t related to new autoinc retrieval code in ::Row
r23214@hlagh (orig r8696):  caelum | 2010-02-13 15:18:27 -0500
fix multiple cursor test
r23246@hlagh (orig r8728):  caelum | 2010-02-16 09:47:43 -0500
POD fix
r23358@hlagh (orig r8758):  caelum | 2010-02-19 06:25:27 -0500
s/primary_columns/_pri_cols/ for Firebird
r23420@hlagh (orig r8800):  rkitover | 2010-02-22 19:33:13 -0500
don't use ib_softcommit by default
r23496@hlagh (orig r8841):  rkitover | 2010-03-01 04:22:19 -0500
update POD
r23545@hlagh (orig r8855):  rkitover | 2010-03-03 12:59:41 -0500
destroy cached statements in $storage->disconnect too
r23582@hlagh (orig r8892):  rkitover | 2010-03-05 18:06:33 -0500
auto_nextval support for Firebird
r23598@hlagh (orig r8908):  rkitover | 2010-03-06 11:48:41 -0500
remove that code for non-pk autoincs from Row, move to ::DBI::InterBase
r23599@hlagh (orig r8909):  rkitover | 2010-03-06 12:00:15 -0500
remove BindType2 test class
r23601@hlagh (orig r8911):  rkitover | 2010-03-06 12:12:55 -0500
cache autoinc sequence in column_info
r23609@hlagh (orig r8919):  rkitover | 2010-03-06 18:05:24 -0500
remove connect_info from maint/gen-schema.pl
r23610@hlagh (orig r8920):  rkitover | 2010-03-06 18:15:13 -0500
don't die on insert in firebird with no pk
r23612@hlagh (orig r8922):  ribasushi | 2010-03-06 19:18:46 -0500
What I really meant
r23619@hlagh (orig r8929):  rkitover | 2010-03-07 05:46:04 -0500
fix RETURNING for empty INSERT

1  2 
Changes
lib/DBIx/Class/Row.pm
t/lib/sqlite.sql

diff --combined Changes
+++ b/Changes
@@@ -1,12 -1,11 +1,13 @@@
  Revision history for DBIx::Class
  
+         - Support for Firebird RDBMS with DBD::InterBase and ODBC
          - DBIx::Class::InflateColumn::File entered deprecated state
          - DBIx::Class::Optional::Dependencies left experimental state
          - Add req_group_list to Opt::Deps (RT#55211)
          - Cascading delete/update are now wrapped in a transaction
            for atomicity
 +        - Fix multiple deficiencies when using MultiCreate with
 +          data-encoder components (e.g. ::EncodedColumn)
          - Fix regression where SQL files with comments were not
            handled properly by ::Schema::Versioned.
          - Fix regression on not properly throwing when $obj->relationship
diff --combined lib/DBIx/Class/Row.pm
@@@ -105,40 -105,26 +105,40 @@@ with NULL as the default, and save your
  
  sub __new_related_find_or_new_helper {
    my ($self, $relname, $data) = @_;
 -  if ($self->__their_pk_needs_us($relname, $data)) {
 +
 +  # create a mock-object so all new/set_column component overrides will run:
 +  my $rel_rs = $self->result_source
 +                    ->related_source($relname)
 +                    ->resultset;
 +  my $new_rel_obj = $rel_rs->new_result($data);
 +  my $proc_data = { $new_rel_obj->get_columns };
 +
 +  if ($self->__their_pk_needs_us($relname)) {
      MULTICREATE_DEBUG and warn "MC $self constructing $relname via new_result";
 -    return $self->result_source
 -                ->related_source($relname)
 -                ->resultset
 -                ->new_result($data);
 +    return $new_rel_obj;
 +  }
 +  elsif ($self->result_source->_pk_depends_on($relname, $proc_data )) {
 +    if (! keys %$proc_data) {
 +      # there is nothing to search for - blind create
 +      MULTICREATE_DEBUG and warn "MC $self constructing default-insert $relname";
 +    }
 +    else {
 +      MULTICREATE_DEBUG and warn "MC $self constructing $relname via find_or_new";
 +      # this is not *really* find or new, as we don't want to double-new the
 +      # data (thus potentially double encoding or whatever)
 +      my $exists = $rel_rs->find ($proc_data);
 +      return $exists if $exists;
 +    }
 +    return $new_rel_obj;
    }
 -  if ($self->result_source->_pk_depends_on($relname, $data)) {
 -    MULTICREATE_DEBUG and warn "MC $self constructing $relname via find_or_new";
 -    return $self->result_source
 -                ->related_source($relname)
 -                ->resultset
 -                ->find_or_new($data);
 +  else {
 +    my $us = $self->source_name;
 +    $self->throw_exception ("'$us' neither depends nor is depended on by '$relname', something is wrong...");
    }
  }
  
  sub __their_pk_needs_us { # this should maybe be in resultsource.
 -  my ($self, $relname, $data) = @_;
 +  my ($self, $relname) = @_;
    my $source = $self->result_source;
    my $reverse = $source->reverse_relationship_info($relname);
    my $rel_source = $source->related_source($relname);
@@@ -315,20 -301,12 +315,20 @@@ sub insert 
        MULTICREATE_DEBUG and warn "MC $self pre-reconstructing $relname $rel_obj\n";
  
        my $them = { %{$rel_obj->{_relationship_data} || {} }, $rel_obj->get_inflated_columns };
 -      my $re = $self->result_source
 -                    ->related_source($relname)
 -                    ->resultset
 -                    ->find_or_create($them);
 +      my $existing;
 +
 +      # if there are no keys - nothing to search for
 +      if (keys %$them and $existing = $self->result_source
 +                                           ->related_source($relname)
 +                                           ->resultset
 +                                           ->find($them)
 +      ) {
 +        %{$rel_obj} = %{$existing};
 +      }
 +      else {
 +        $rel_obj->insert;
 +      }
  
 -      %{$rel_obj} = %{$re};
        $self->{_rel_in_storage}{$relname} = 1;
      }
  
      $self->store_column($auto_pri[$_] => $ids[$_]) for 0 .. $#ids;
    }
  
    $self->{_dirty_columns} = {};
    $self->{related_resultsets} = {};
  
        foreach my $obj (@cands) {
          $obj->set_from_related($_, $self) for keys %$reverse;
          my $them = { %{$obj->{_relationship_data} || {} }, $obj->get_inflated_columns };
 -        if ($self->__their_pk_needs_us($relname, $them)) {
 +        if ($self->__their_pk_needs_us($relname)) {
            if (exists $self->{_ignore_at_insert}{$relname}) {
              MULTICREATE_DEBUG and warn "MC $self skipping post-insert on $relname";
            } else {
diff --combined t/lib/sqlite.sql
@@@ -1,6 -1,6 +1,6 @@@
  -- 
  -- Created by SQL::Translator::Producer::SQLite
- -- Created on Sun Mar  7 11:14:14 2010
+ -- Created on Sat Mar  6 18:04:27 2010
  -- 
  ;
  
@@@ -35,6 -35,18 +35,6 @@@ CREATE TABLE collection 
  );
  
  --
 --- Table: employee
 ---
 -CREATE TABLE employee (
 -  employee_id INTEGER PRIMARY KEY NOT NULL,
 -  position integer NOT NULL,
 -  group_id integer,
 -  group_id_2 integer,
 -  group_id_3 integer,
 -  name varchar(100)
 -);
 -
 ---
  -- Table: encoded
  --
  CREATE TABLE encoded (
@@@ -47,7 -59,7 +47,7 @@@
  --
  CREATE TABLE event (
    id INTEGER PRIMARY KEY NOT NULL,
-   starts_at datetime NOT NULL,
+   starts_at date NOT NULL,
    created_on timestamp NOT NULL,
    varchar_date varchar(20),
    varchar_datetime varchar(20),
@@@ -241,21 -253,6 +241,21 @@@ CREATE TABLE books 
  CREATE INDEX books_idx_owner ON books (owner);
  
  --
 +-- Table: employee
 +--
 +CREATE TABLE employee (
 +  employee_id INTEGER PRIMARY KEY NOT NULL,
 +  position integer NOT NULL,
 +  group_id integer,
 +  group_id_2 integer,
 +  group_id_3 integer,
 +  name varchar(100),
 +  encoded integer
 +);
 +
 +CREATE INDEX employee_idx_encoded ON employee (encoded);
 +
 +--
  -- Table: forceforeign
  --
  CREATE TABLE forceforeign (
@@@ -448,4 -445,4 +448,4 @@@ CREATE INDEX fourkeys_to_twokeys_idx_t_
  -- View: year2000cds
  --
  CREATE VIEW year2000cds AS
--    SELECT cdid, artist, title, year, genreid, single_track FROM cd WHERE year = "2000"
++    SELECT cdid, artist, title, year, genreid, single_track FROM cd WHERE year = "2000"