Sha256: a492551627e0bdadb1caa8c705d7738a8235c4aa34df537ab44a4cf56b3f5262

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

# -*- encoding : utf-8 -*-
module ActiveRecord
  
  #FIXME!!  this is a hacky place to put a hacky bit of code.
  # the following code is already in Rails 4 (see https://github.com/rails/rails/commit/c8792c7b2ea4f5fe7a5610225433ea8dd8d0f83e)
  # it allows manual rollbacks in after_save (eg store events) to reset the object correctly
  
  # really we need to get all this extension code out of config and into lib.  and hopefully we can soon get rid of this code altogether!
  module Transactions
    def with_transaction_returning_status
      status = nil
      self.class.transaction do
        add_to_transaction
        begin
          status = yield
        rescue ActiveRecord::Rollback
          @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1
          status = nil
        end

        raise ActiveRecord::Rollback unless status
      end
      status
    end
  end
  
  class SchemaDumper
    def dump(stream)
      header(stream)
      tables(stream)
      #views(stream)
      trailer(stream)
      stream
    end

    private
    def views(stream)
      views = @connection.select_all("SELECT viewname  FROM pg_views WHERE schemaname IN ('$user','public');")
      views.each do |view|
        view( view['viewname'], stream )
      end
    end

    def view(viewname, stream)
      viewinfo = @connection.select_one %{
        SELECT * from pg_views WHERE schemaname IN ('$user','public')
        and viewname='#{viewname}'
      }
      stream.puts <<ENDVIEW
  execute %{
    CREATE VIEW #{viewname} AS
    #{viewinfo['definition']}
  }

ENDVIEW
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wagn-1.12.13 config/initializers/schema_views.rb
wagn-1.12.12 config/initializers/schema_views.rb
wagn-1.12.11 config/initializers/schema_views.rb
wagn-1.12.10 config/initializers/schema_views.rb
wagn-1.12.9 config/initializers/schema_views.rb
wagn-1.12.8 config/initializers/schema_views.rb
wagn-1.12.7 config/initializers/schema_views.rb