No subject
Tue Nov 7 19:00:29 GMT 2017
```
<connect_info>
dsn dbi:Oracle:host=xxx;sid=xxx
user xxx
pass xxx
<options>
LongReadLen 100000000
LongTrunkOk 1
</options>
</connect_info>
```
However, this gave the error:
```
Can't use string ("LongTrunkOk") as a HASH ref while "strict refs" in use at /cath/homes2/ucbcisi/.plenv/versions/5.12.5/lib/perl5/site_perl/5.12.5/DBIx/Class/Storage/DBI.pm line 733.
```
It looks like `DBIC->connect` can accept these options as a hashref, but dbicdump is currently passing them in as a (de-referenced) hash. Applying the change in this PR seemed to make everything work for me.
Existing tests all pass. I've added a test to make sure the new config with options parses okay (fails prior to this PR). It currently throws out a warning though (I think because the test database isn't DBD::Oracle).
You can view, comment on, or merge this pull request online at:
https://github.com/dbsrgits/dbix-class-schema-loader/pull/15
-- Commit Summary --
* Use hashref (not hash) for connection info options
-- File Changes --
M script/dbicdump (2)
A t/61dbicdump_config_options.t (65)
-- Patch Links --
https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.patch
https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/dbix-class-schema-loader/pull/15
----==_mimepart_59f7319b66a84_2e413f9439534f281907b4
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Trying to specify DBI connection options in dbicdump config.</p>
<p>I may have misunderstood usage, but it looks like <a href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.082840/lib/DBIx/Class/Storage/DBI.pm#connect_info">connect</a> allows DBI connection options to be given as a hashref, eg</p>
<pre><code>$options = { LongTrunkOk => 1 };
My::Schema->connect($dsn, $user, $pass, $options);
</code></pre>
<p>However, I think <code>dbicdump</code> is currently passing them in as a <a href="https://github.com/dbsrgits/dbix-class-schema-loader/compare/master...sillitoe:dbicdump-config-connect-with-options?expand=1#diff-7479a2c1349f0300899e26041504604eL161">(de-referenced) hash:</a></p>
<pre><code> make_schema_at(
$c->{schema_class},
$c->{loader_options} || {},
[ $dsn, $user, $pass, %{$options} ],
);
</code></pre>
<p>This PR changes <code>%{$options}</code> to <code>$options</code>, which allows DBI connection options to be specified in the config as:</p>
<pre><code><connect_info>
dsn dbi:Oracle:host=xxx;sid=xxx
user xxx
pass xxx
<options>
LongReadLen 100000000
LongTrunkOk 1
</options>
</connect_info>
</code></pre>
<p>Full details appended.</p>
<hr>
<p>I was having difficulty passing connect options through to <code>dbicdump</code> (via <code>Config::Any</code>), e.g trying to dump the schema from an Oracle database requires the following connection options:</p>
<pre><code> LongReadLen 100000000
LongTrunkOk 1
</code></pre>
<p>Based on the <a href="http://search.cpan.org/%7Eribasushi/DBIx-Class-0.082840/lib/DBIx/Class/Storage/DBI.pm#connect_info">DBIx::Class::Storage::DBI docs</a>, I thought the best way to do this in <code>dbic.conf</code> was:</p>
<pre><code><connect_info>
dsn dbi:Oracle:host=xxx;sid=xxx
user xxx
pass xxx
LongReadLen 100000000
LongTrunkOk 1
</connect_info>
</code></pre>
<p>However this came up with an error that seemed to suggest these options weren't being used.</p>
<pre><code>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)
</code></pre>
<p>From the code, it looks like dbicdump allows a config key <code>options</code> within <code>connect_info</code> so I tried:</p>
<pre><code><connect_info>
dsn dbi:Oracle:host=xxx;sid=xxx
user xxx
pass xxx
<options>
LongReadLen 100000000
LongTrunkOk 1
</options>
</connect_info>
</code></pre>
<p>However, this gave the error:</p>
<pre><code>Can't use string ("LongTrunkOk") as a HASH ref while "strict refs" in use at /cath/homes2/ucbcisi/.plenv/versions/5.12.5/lib/perl5/site_perl/5.12.5/DBIx/Class/Storage/DBI.pm line 733.
</code></pre>
<p>It looks like <code>DBIC->connect</code> can accept these options as a hashref, but dbicdump is currently passing them in as a (de-referenced) hash. Applying the change in this PR seemed to make everything work for me.</p>
<p>Existing tests all pass. I've added a test to make sure the new config with options parses okay (fails prior to this PR). It currently throws out a warning though (I think because the test database isn't DBD::Oracle).</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/dbsrgits/dbix-class-schema-loader/pull/15'>https://github.com/dbsrgits/dbix-class-schema-loader/pull/15</a></p>
<h4>Commit Summary</h4>
<ul>
<li>Use hashref (not hash) for connection info options</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/dbsrgits/dbix-class-schema-loader/pull/15/files#diff-0">script/dbicdump</a>
(2)
</li>
<li>
<strong>A</strong>
<a href="https://github.com/dbsrgits/dbix-class-schema-loader/pull/15/files#diff-1">t/61dbicdump_config_options.t</a>
(65)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.patch'>https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.patch</a></li>
<li><a href='https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.diff'>https://github.com/dbsrgits/dbix-class-schema-loader/pull/15.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/dbsrgits/dbix-class-schema-loader/pull/15">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AASeAnMQgR28fH-XXYLrUUhK6bWJkDdTks5sxdebgaJpZM4QLPAk">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AASeAm2MoJmNCkZbyNb_QPQKYpg77WYVks5sxdebgaJpZM4QLPAk.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/dbsrgits/dbix-class-schema-loader/pull/15"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/dbsrgits/dbix-class-schema-loader","title":"dbsrgits/dbix-class-schema-loader","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/dbsrgits/dbix-class-schema-loader"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Use hashref (not hash) for connection info options (#15)"}],"action":{"name":"View Pull Request","url":"https://github.com/dbsrgits/dbix-class-schema-loader/pull/15"}}}</script>
----==_mimepart_59f7319b66a84_2e413f9439534f281907b4--
More information about the DBIx-Class-Devel
mailing list