<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/dev/caffeine &#187; oracle</title>
	<atom:link href="http://devcaffeine.com/tags/oracle/feed/" rel="self" type="application/rss+xml" />
	<link>http://devcaffeine.com</link>
	<description>anything worth taking seriously is worth making fun of</description>
	<lastBuildDate>Thu, 24 Sep 2009 20:50:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Oracle and rails 1.2.1</title>
		<link>http://devcaffeine.com/2007/02/08/rails-12-database-indexes/</link>
		<comments>http://devcaffeine.com/2007/02/08/rails-12-database-indexes/#comments</comments>
		<pubDate>Thu, 08 Feb 2007 23:09:53 +0000</pubDate>
		<dc:creator>cflipse</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[work]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://devcaffeine.com/2007/02/08/rails-12-database-indexes/</guid>
		<description><![CDATA[Grrr &#8230; So, in the course of updating to rails 1.2, it seems that the automagically generated names for database indexes were changed.  Went from &#8220;#{table}_#{columns}_index&#8221; to &#8220;index_#{table}_on_#{columns}&#8221; &#8230; an annoying little change that bumps me up against some sort of Oracle column name length ceiling.  And has the effect of probably breaking [...]]]></description>
			<content:encoded><![CDATA[<p>Grrr &#8230; So, in the course of updating to rails 1.2, it seems that the automagically generated names for database indexes were changed.  Went from &#8220;#{table}_#{columns}_index&#8221; to &#8220;index_#{table}_on_#{columns}&#8221; &#8230; an annoying little change that bumps me up against some sort of Oracle column name length ceiling.  And has the effect of probably breaking down migrations.</p>
<p>So, I&#8217;m gonna jump into the migrations and patch the existing add_index calls to specify a :name => value for all of the existing indexes, so that migrations will actually <i>work</i> and leave me with a database that matches the one in production &#8230;. </p>
<p>Figuring out why I suddenly couldn&#8217;t build my test database was not exactly the way I meant to spend the last hour &#8230;.</p>
<p><b>Update</b></p>
<p>Changeset 4768 is responsible for all this.  Apparently, to allow reverse parsing of the indexes from the index name.  Not alltogether a bad goal, but it still breaks down migrations &#8230;  (thanks to <a href=http://blog.twifkak.com/articles/2007/02/08/using-rails-migrations-add-remove_index-upgrading-to-1-2">Devin</a> for find this one)</p>
<p>And, I discovered another problem last night.  Seems that all of my text fields have a default value of &#8220;empy_clob()&#8221;  &#8230; not the function, but <i>that actual string</i>.  Sort of trashes one&#8217;s assumptions about unset fields.  Apparently (thanks Roy) this has been worked out in <a href="http://dev.rubyonrails.org/ticket/7344">ticket 7344</a> and already applied to Edge.  Some sort of thing that only applies to Oracle, because, of course, nobody tests Rails on Oracle, it&#8217;s all MySQL.  And I can&#8217;t really look into the patch attached to the ticket, because I keep getting Trac errors.  Shaping up to have been a lovely adventure &#8230;</p>
<p><b>update</b><br />
Finally got through to the site, and worked out a monkey patch to fix this.  For those of you who might be running with oracle, and can&#8217;t upgrade to Edge (gee, wonder why not) the patch is below.   This is a temporary thing, given that the ticket is closed, and will hopefully be fixed in 1.2.2 &#8230;<br />
[ruby]<br />
class ActiveRecord::ConnectionAdapters::OracleColumn<br />
  attr_writer :default<br />
end if defined? ActiveRecord::ConnectionAdapters::OracleColumn</p>
<p>class ActiveRecord::ConnectionAdapters::OracleAdapter<br />
  def quote(value, column = nil) #:nodoc:<br />
    if value &#038;&#038; column &#038;&#038; [:text, :binary].include?(column.type)<br />
      %Q{empty_#{ column.sql_type.downcase rescue &#8216;blob&#8217; }()}<br />
    else<br />
       super<br />
    end<br />
  end</p>
<p>  alias columns_orig columns<br />
  def columns(*a)<br />
    columns_orig(*a).each do |col|<br />
      col.default = nil if col.default =~ /^(null|empty_[bc]lob())$/i<br />
    end<br />
  end<br />
end if defined? ActiveRecord::ConnectionAdapters::OracleAdapter<br />
[/ruby]</p>
<p>This appears to do the trick &#8230; a dump of the test schema no longer defaults all of our text columns to &#8220;empty_clob()&#8221; and tests are again passing  &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://devcaffeine.com/2007/02/08/rails-12-database-indexes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
