On Oct 2, 2009, at 4:55 AM, Avi Miller wrote:
>
>
> Signed-off-by: Avi Miller <[email protected]>
> ---
> lib/puppet/rails.rb | 4 ++++
> lib/puppet/rails/database/schema.rb | 9 +++++++--
> lib/puppet/rails/param_value.rb | 4 ++--
> lib/puppet/rails/resource_tag.rb | 4 ++--
> 4 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/lib/puppet/rails.rb b/lib/puppet/rails.rb
> index fc8eacd..ec2d618 100644
> --- a/lib/puppet/rails.rb
> +++ b/lib/puppet/rails.rb
> @@ -51,6 +51,10 @@ module Puppet::Rails
>
> socket = Puppet[:dbsocket]
> args[:socket] = socket unless socket.empty?
> + when "oracle_enhanced":
> + args[:database] = Puppet[:dbname] unless Puppet[:dbname].empty?
> + args[:username] = Puppet[:dbuser] unless Puppet[:dbuser].empty?
> + args[:password] = Puppet[:dbpassword] unless
> Puppet[:dbpassword].empty?
> else
> raise ArgumentError, "Invalid db adapter %s" % adapter
> end
> diff --git a/lib/puppet/rails/database/schema.rb b/lib/puppet/rails/
> database/schema.rb
> index d8fcbb4..929ebba 100644
> --- a/lib/puppet/rails/database/schema.rb
> +++ b/lib/puppet/rails/database/schema.rb
> @@ -21,9 +21,10 @@ class Puppet::Rails::Schema
>
> # Thanks, mysql! MySQL requires a length on indexes
> in text fields.
> # So, we provide them for mysql and handle
> everything else specially.
> + # Oracle doesn't index on CLOB fields, so we skip it
> if Puppet[:dbadapter] == "mysql"
> execute "CREATE INDEX typentitle ON resources
> (restype,title(50));"
> - else
> + elseif Puppet[:dbadapter] != "oracle_enhanced"
> add_index :resources, [:title, :restype]
> end
>
> @@ -49,7 +50,11 @@ class Puppet::Rails::Schema
> t.column :updated_at, :datetime
> t.column :created_at, :datetime
> end
> - add_index :puppet_tags, :id, :integer => true
> +
> + # Oracle automatically creates a primary key index
> + if Puppet[:dbadapter] != "oracle_enhanced"
> + add_index :puppet_tags, :id, :integer => true
> + end
>
> create_table :hosts do |t|
> t.column :name, :string, :null => false
> diff --git a/lib/puppet/rails/param_value.rb b/lib/puppet/rails/
> param_value.rb
> index 21415ef..b298924 100644
> --- a/lib/puppet/rails/param_value.rb
> +++ b/lib/puppet/rails/param_value.rb
> @@ -48,7 +48,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base
>
> # returns an array of hash containing all the parameters of a
> given resource
> def self.find_all_params_from_resource(db_resource)
> - params = db_resource.connection.select_all("SELECT v.id,
> v.value, v.line, v.resource_id, v.param_name_id, n.name FROM
> param_values as v INNER JOIN param_names as n ON
> v.param_name_id=n.id WHERE v.resource_id=%s" % db_resource.id)
> + params = db_resource.connection.select_all("SELECT v.id,
> v.value, v.line, v.resource_id, v.param_name_id, n.name FROM
> param_values v INNER JOIN param_names n ON v.param_name_id=n.id
> WHERE v.resource_id=%s" % db_resource.id)
Are these changes tot he SQL fully compatible with the other DBs we
run on?
If so, then +1.
>
> params.each do |val|
> val['value'] = unserialize_value(val['value'])
> val['line'] = val['line'] ? Integer(val['line']) : nil
> @@ -59,7 +59,7 @@ class Puppet::Rails::ParamValue < ActiveRecord::Base
>
> # returns an array of hash containing all the parameters of a
> given host
> def self.find_all_params_from_host(db_host)
> - params = db_host.connection.select_all("SELECT v.id,
> v.value, v.line, v.resource_id, v.param_name_id, n.name FROM
> param_values as v INNER JOIN resources r ON v.resource_id=r.id INNER
> JOIN param_names as n ON v.param_name_id=n.id WHERE r.host_id=%s" %
> db_host.id)
> + params = db_host.connection.select_all("SELECT v.id,
> v.value, v.line, v.resource_id, v.param_name_id, n.name FROM
> param_values v INNER JOIN resources r ON v.resource_id=r.id INNER
> JOIN param_names n ON v.param_name_id=n.id WHERE r.host_id=%s" %
> db_host.id)
> params.each do |val|
> val['value'] = unserialize_value(val['value'])
> val['line'] = val['line'] ? Integer(val['line']) : nil
> diff --git a/lib/puppet/rails/resource_tag.rb b/lib/puppet/rails/
> resource_tag.rb
> index 8aeec0e..8d088fd 100644
> --- a/lib/puppet/rails/resource_tag.rb
> +++ b/lib/puppet/rails/resource_tag.rb
> @@ -8,7 +8,7 @@ class Puppet::Rails::ResourceTag < ActiveRecord::Base
>
> # returns an array of hash containing tags of resource
> def self.find_all_tags_from_resource(db_resource)
> - tags = db_resource.connection.select_all("SELECT t.id,
> t.resource_id, p.name FROM resource_tags as t INNER JOIN puppet_tags
> as p ON t.puppet_tag_id=p.id WHERE t.resource_id=%s" % db_resource.id)
> + tags = db_resource.connection.select_all("SELECT t.id,
> t.resource_id, p.name FROM resource_tags t INNER JOIN puppet_tags p
> ON t.puppet_tag_id=p.id WHERE t.resource_id=%s" % db_resource.id)
> tags.each do |val|
> val['resource_id'] = Integer(val['resource_id'])
> end
> @@ -17,7 +17,7 @@ class Puppet::Rails::ResourceTag <
> ActiveRecord::Base
>
> # returns an array of hash containing tags of a host
> def self.find_all_tags_from_host(db_host)
> - tags = db_host.connection.select_all("SELECT t.id,
> t.resource_id, p.name FROM resource_tags as t INNER JOIN resources r
> ON t.resource_id=r.id INNER JOIN puppet_tags as p ON
> t.puppet_tag_id=p.id WHERE r.host_id=%s" % db_host.id)
> + tags = db_host.connection.select_all("SELECT t.id,
> t.resource_id, p.name FROM resource_tags t INNER JOIN resources r ON
> t.resource_id=r.id INNER JOIN puppet_tags p ON t.puppet_tag_id=p.id
> WHERE r.host_id=%s" % db_host.id)
> tags.each do |val|
> val['resource_id'] = Integer(val['resource_id'])
> end
> --
> 1.5.5.6
>
>
> >
--
I never did give anybody hell. I just told the truth, and they thought
it was hell. -- Harry S Truman
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---