[DBIx-Class-Devel] [dbsrgits/dbix-class-schema-loader] Use hashref (not hash) for connection info options (#15)

Ian Sillitoe notifications at github.com
Mon Oct 30 14:05:15 GMT 2017


Trying to specify DBI connection options in dbicdump config.

I may have misunderstood usage, but it looks like [connect](http://search.cpan.org/~ribasushi/DBIx-Class-0.082840/lib/DBIx/Class/Storage/DBI.pm#connect_info) allows DBI connection options to be given as a hashref, eg

```
$options = { LongTrunkOk => 1 };
My::Schema->connect($dsn, $user, $pass, $options);
```

However, I think `dbicdump` is currently passing them in as a [(de-referenced) hash:](https://github.com/dbsrgits/dbix-class-schema-loader/compare/master...sillitoe:dbicdump-config-connect-with-options?expand=1#diff-7479a2c1349f0300899e26041504604eL161)

```
     make_schema_at(
         $c->{schema_class},
         $c->{loader_options} || {},
         [ $dsn, $user, $pass, %{$options} ],
     );
```

This PR changes `%{$options}` to `$options`, which allows DBI connection options to be specified in the config as:

```
<connect_info>
    dsn     dbi:Oracle:host=xxx;sid=xxx
    user    xxx
    pass    xxx
    <options>
        LongReadLen         100000000
        LongTrunkOk         1
    </options>
</connect_info>
```

Full details appended.

---

I was having difficulty passing connect options through to `dbicdump` (via `Config::Any`), e.g trying to dump the schema from an Oracle database requires the following connection options:

```
      LongReadLen         100000000
      LongTrunkOk         1
```

Based on the [DBIx::Class::Storage::DBI docs](http://search.cpan.org/~ribasushi/DBIx-Class-0.082840/lib/DBIx/Class/Storage/DBI.pm#connect_info), I thought the best way to do this in `dbic.conf` was:

```
<connect_info>
    dsn     dbi:Oracle:host=xxx;sid=xxx
    user    xxx
    pass    xxx
    LongReadLen         100000000
    LongTrunkOk         1
</connect_info>
```

However this came up with an error that seemed to suggest these options weren't being used.

```
DBIx::Class::Schema::Loader::DBI::Oracle::_view_definition(): DBI Exception: DBD::Oracle::db selectrow_array failed: ORA-24345: A Truncation or null fetch error occurred (DBD ERROR: ORA-01406 error on field 1 of 1, ora_type 8, LongReadLen too small and/or LongTruncOk not set)
```



More information about the DBIx-Class-Devel mailing list