polymorphic_as_table 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
 - data/README +13 -0
 - data/Rakefile +23 -0
 - data/install.rb +1 -0
 - data/lib/polymorphic_as_table.rb +67 -0
 - data/lib/polymorphic_as_table/association_proxy.rb +19 -0
 - data/lib/polymorphic_as_table/belongs_to_association.rb +11 -0
 - data/lib/polymorphic_as_table/has_many_association.rb +26 -0
 - data/lib/polymorphic_as_table/has_one_association.rb +30 -0
 - data/lib/polymorphic_as_table/through_association_scope.rb +64 -0
 - data/lib/polymorphic_as_table/through_reflection.rb +11 -0
 - data/polymorphic_as_table.gemspec +25 -0
 - data/rails/init.rb +5 -0
 - data/test/database.yml +18 -0
 - data/test/polymorphic_as_table_plugin.sqlit3.db +0 -0
 - data/test/polymorphic_as_table_test.log +447 -0
 - data/test/polymorphic_as_table_test.rb +35 -0
 - data/test/schema.rb +12 -0
 - data/test/test_helper.rb +34 -0
 - data/uninstall.rb +1 -0
 - metadata +67 -0
 
    
        data/MIT-LICENSE
    ADDED
    
    | 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Copyright (c) 2011 Jeremiah Dodds <jeremiah.dodds@gmail.com>
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Permission is hereby granted, free of charge, to any person obtaining
         
     | 
| 
      
 4 
     | 
    
         
            +
            a copy of this software and associated documentation files (the
         
     | 
| 
      
 5 
     | 
    
         
            +
            "Software"), to deal in the Software without restriction, including
         
     | 
| 
      
 6 
     | 
    
         
            +
            without limitation the rights to use, copy, modify, merge, publish,
         
     | 
| 
      
 7 
     | 
    
         
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         
     | 
| 
      
 8 
     | 
    
         
            +
            permit persons to whom the Software is furnished to do so, subject to
         
     | 
| 
      
 9 
     | 
    
         
            +
            the following conditions:
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            The above copyright notice and this permission notice shall be
         
     | 
| 
      
 12 
     | 
    
         
            +
            included in all copies or substantial portions of the Software.
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         
     | 
| 
      
 15 
     | 
    
         
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         
     | 
| 
      
 16 
     | 
    
         
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         
     | 
| 
      
 17 
     | 
    
         
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         
     | 
| 
      
 18 
     | 
    
         
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         
     | 
| 
      
 19 
     | 
    
         
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         
     | 
| 
      
 20 
     | 
    
         
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         
     | 
    
        data/README
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,23 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake/testtask'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'rdoc/task'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            desc 'Default: run unit tests.'
         
     | 
| 
      
 6 
     | 
    
         
            +
            task :default => :test
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            desc 'Test the polymorphic_as_table plugin.'
         
     | 
| 
      
 9 
     | 
    
         
            +
            Rake::TestTask.new(:test) do |t|
         
     | 
| 
      
 10 
     | 
    
         
            +
              t.libs << 'lib'
         
     | 
| 
      
 11 
     | 
    
         
            +
              t.libs << 'test'
         
     | 
| 
      
 12 
     | 
    
         
            +
              t.pattern = 'test/**/*_test.rb'
         
     | 
| 
      
 13 
     | 
    
         
            +
              t.verbose = true
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            desc 'Generate documentation for the polymorphic_as_table plugin.'
         
     | 
| 
      
 17 
     | 
    
         
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         
     | 
| 
      
 18 
     | 
    
         
            +
              rdoc.rdoc_dir = 'rdoc'
         
     | 
| 
      
 19 
     | 
    
         
            +
              rdoc.title    = 'PolymorphicAsTable'
         
     | 
| 
      
 20 
     | 
    
         
            +
              rdoc.options << '--line-numbers' << '--inline-source'
         
     | 
| 
      
 21 
     | 
    
         
            +
              rdoc.rdoc_files.include('README')
         
     | 
| 
      
 22 
     | 
    
         
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
    
        data/install.rb
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Install hook code here
         
     | 
| 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              require 'polymorphic_as_table/association_proxy'
         
     | 
| 
      
 3 
     | 
    
         
            +
              require 'polymorphic_as_table/belongs_to_association'
         
     | 
| 
      
 4 
     | 
    
         
            +
              require 'polymorphic_as_table/has_many_association'
         
     | 
| 
      
 5 
     | 
    
         
            +
              require 'polymorphic_as_table/has_one_association'
         
     | 
| 
      
 6 
     | 
    
         
            +
              require 'polymorphic_as_table/through_reflection'
         
     | 
| 
      
 7 
     | 
    
         
            +
              require 'polymorphic_as_table/through_association_scope'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              module ClassMethods
         
     | 
| 
      
 10 
     | 
    
         
            +
                def has_polymorphic_as_table
         
     | 
| 
      
 11 
     | 
    
         
            +
                  ActiveRecord::Associations::AssociationProxy.send(
         
     | 
| 
      
 12 
     | 
    
         
            +
                    :include, PolymorphicAsTable::AssociationProxy)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  ActiveRecord::Associations::HasOneAssociation.send(
         
     | 
| 
      
 14 
     | 
    
         
            +
                    :include, PolymorphicAsTable::HasOneAssociation)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  ActiveRecord::Associations::HasManyAssociation.send(
         
     | 
| 
      
 16 
     | 
    
         
            +
                    :include, PolymorphicAsTable::HasManyAssociation)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  ActiveRecord::Associations::ThroughAssociationScope.send(
         
     | 
| 
      
 18 
     | 
    
         
            +
                    :include, PolymorphicAsTable::ThroughAssociationScope)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  ActiveRecord::Reflection::ThroughReflection.send(
         
     | 
| 
      
 20 
     | 
    
         
            +
                    :include, PolymorphicAsTable::ThroughReflection)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  class << self
         
     | 
| 
      
 23 
     | 
    
         
            +
                    def sti_name
         
     | 
| 
      
 24 
     | 
    
         
            +
                      table_name
         
     | 
| 
      
 25 
     | 
    
         
            +
                    end
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                def is_polymorphic_as_table
         
     | 
| 
      
 30 
     | 
    
         
            +
                  ActiveRecord::Associations::AssociationProxy.send(
         
     | 
| 
      
 31 
     | 
    
         
            +
                    :include, PolymorphicAsTable::AssociationProxy)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  ActiveRecord::Associations::BelongsToPolymorphicAssociation.send(
         
     | 
| 
      
 33 
     | 
    
         
            +
                    :include, PolymorphicAsTable::BelongsToAssociation)
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                  class << self
         
     | 
| 
      
 36 
     | 
    
         
            +
                    def define_attribute_methods
         
     | 
| 
      
 37 
     | 
    
         
            +
                      if super && @@association
         
     | 
| 
      
 38 
     | 
    
         
            +
                        define_method("#{@@association}_type=") do |value|
         
     | 
| 
      
 39 
     | 
    
         
            +
                          debugger
         
     | 
| 
      
 40 
     | 
    
         
            +
                          write_attribute("#{@@association}_type", value.tableize)
         
     | 
| 
      
 41 
     | 
    
         
            +
                        end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                        define_method("#{@@association}_type") do
         
     | 
| 
      
 44 
     | 
    
         
            +
                          read_attribute("#{@@association}_type").classify
         
     | 
| 
      
 45 
     | 
    
         
            +
                        end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                        define_method("#{@@association}=") do |association|
         
     | 
| 
      
 48 
     | 
    
         
            +
                          write_attribute("#{@@association}", association)
         
     | 
| 
      
 49 
     | 
    
         
            +
                          write_attribute("#{@@association}_type", association.class.to_s.tableize)
         
     | 
| 
      
 50 
     | 
    
         
            +
                        end
         
     | 
| 
      
 51 
     | 
    
         
            +
                      end
         
     | 
| 
      
 52 
     | 
    
         
            +
                    end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                    def belongs_to(association_id, options={})
         
     | 
| 
      
 55 
     | 
    
         
            +
                      @@association = association_id
         
     | 
| 
      
 56 
     | 
    
         
            +
                      super
         
     | 
| 
      
 57 
     | 
    
         
            +
                    end
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              def self.included(base)
         
     | 
| 
      
 63 
     | 
    
         
            +
                base.extend(ClassMethods)
         
     | 
| 
      
 64 
     | 
    
         
            +
              end
         
     | 
| 
      
 65 
     | 
    
         
            +
            end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            ActiveRecord::Base.send(:include, PolymorphicAsTable)
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module AssociationProxy
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    def set_belongs_to_association_for(record)
         
     | 
| 
      
 6 
     | 
    
         
            +
                      if @reflection.options[:as]
         
     | 
| 
      
 7 
     | 
    
         
            +
                        record["#{@reflection.options[:as]}_id"]   = @owner.id unless @owner.new_record?
         
     | 
| 
      
 8 
     | 
    
         
            +
                        record["#{@reflection.options[:as]}_type"] = @owner.class.base_class.table_name
         
     | 
| 
      
 9 
     | 
    
         
            +
                      else
         
     | 
| 
      
 10 
     | 
    
         
            +
                        unless @owner.new_record?
         
     | 
| 
      
 11 
     | 
    
         
            +
                          primary_key = @reflection.options[:primary_key] || :id
         
     | 
| 
      
 12 
     | 
    
         
            +
                          record[@reflection.primary_key_name] = @owner.send(primary_key)
         
     | 
| 
      
 13 
     | 
    
         
            +
                        end
         
     | 
| 
      
 14 
     | 
    
         
            +
                      end
         
     | 
| 
      
 15 
     | 
    
         
            +
                    end
         
     | 
| 
      
 16 
     | 
    
         
            +
                  end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module BelongsToAssociation
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    def association_class
         
     | 
| 
      
 6 
     | 
    
         
            +
                      @owner[@reflection.options[:foreign_type]].present? ? @owner[@reflection.options[:foreign_type]].classify.constantize : nil
         
     | 
| 
      
 7 
     | 
    
         
            +
                    end
         
     | 
| 
      
 8 
     | 
    
         
            +
                  end
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,26 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module HasManyAssociation
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    def construct_sql
         
     | 
| 
      
 6 
     | 
    
         
            +
                      case
         
     | 
| 
      
 7 
     | 
    
         
            +
                      when @reflection.options[:finder_sql]
         
     | 
| 
      
 8 
     | 
    
         
            +
                        @finder_sql = interpolate_and_sanitize_sql(@reflection.options[:finder_sql])
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                      when @reflection.options[:as]
         
     | 
| 
      
 11 
     | 
    
         
            +
                        @finder_sql =
         
     | 
| 
      
 12 
     | 
    
         
            +
                          "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
         
     | 
| 
      
 13 
     | 
    
         
            +
                          "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.table_name)}"
         
     | 
| 
      
 14 
     | 
    
         
            +
                        @finder_sql << " AND (#{conditions})" if conditions
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                      else
         
     | 
| 
      
 17 
     | 
    
         
            +
                        @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
         
     | 
| 
      
 18 
     | 
    
         
            +
                        @finder_sql << " AND (#{conditions})" if conditions
         
     | 
| 
      
 19 
     | 
    
         
            +
                      end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                      construct_counter_sql
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,30 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module HasOneAssociation
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    def find_target
         
     | 
| 
      
 6 
     | 
    
         
            +
                      options = @reflection.options.dup
         
     | 
| 
      
 7 
     | 
    
         
            +
                      (options.keys - [:select, :order, :include, :readonly]).each do |key|
         
     | 
| 
      
 8 
     | 
    
         
            +
                        options.delete key
         
     | 
| 
      
 9 
     | 
    
         
            +
                      end
         
     | 
| 
      
 10 
     | 
    
         
            +
                      options[:conditions] = @finder_sql
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                      the_target = @reflection.klass.find(:first, options)
         
     | 
| 
      
 13 
     | 
    
         
            +
                      set_inverse_instance(the_target, @owner)
         
     | 
| 
      
 14 
     | 
    
         
            +
                      the_target
         
     | 
| 
      
 15 
     | 
    
         
            +
                    end
         
     | 
| 
      
 16 
     | 
    
         
            +
                    def construct_sql
         
     | 
| 
      
 17 
     | 
    
         
            +
                      case
         
     | 
| 
      
 18 
     | 
    
         
            +
                      when @reflection.options[:as]
         
     | 
| 
      
 19 
     | 
    
         
            +
                        @finder_sql =
         
     | 
| 
      
 20 
     | 
    
         
            +
                          "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
         
     | 
| 
      
 21 
     | 
    
         
            +
                          "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.table_name)}"
         
     | 
| 
      
 22 
     | 
    
         
            +
                      else
         
     | 
| 
      
 23 
     | 
    
         
            +
                        @finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
         
     | 
| 
      
 24 
     | 
    
         
            +
                      end
         
     | 
| 
      
 25 
     | 
    
         
            +
                      @finder_sql << " AND (#{conditions})" if conditions
         
     | 
| 
      
 26 
     | 
    
         
            +
                    end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,64 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module PolymorphicAsTable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ThroughAssociationScope
         
     | 
| 
      
 3 
     | 
    
         
            +
                def self.included(base)
         
     | 
| 
      
 4 
     | 
    
         
            +
                  base.class_eval do
         
     | 
| 
      
 5 
     | 
    
         
            +
                    def construct_owner_attributes(reflection)
         
     | 
| 
      
 6 
     | 
    
         
            +
                      if as = reflection.options[:as]
         
     | 
| 
      
 7 
     | 
    
         
            +
                        { "#{as}_id" => @owner.id,
         
     | 
| 
      
 8 
     | 
    
         
            +
                          "#{as}_type" => @owner.class.base_class.table_name }
         
     | 
| 
      
 9 
     | 
    
         
            +
                      else
         
     | 
| 
      
 10 
     | 
    
         
            +
                        { reflection.primary_key_name => @owner.id }
         
     | 
| 
      
 11 
     | 
    
         
            +
                      end
         
     | 
| 
      
 12 
     | 
    
         
            +
                    end
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                    def construct_quoted_owner_attributes(reflection)
         
     | 
| 
      
 15 
     | 
    
         
            +
                      if as = reflection.options[:as]
         
     | 
| 
      
 16 
     | 
    
         
            +
                        { "#{as}_id"   => @owner.class.quote_value(
         
     | 
| 
      
 17 
     | 
    
         
            +
                            @owner[reflection.active_record_primary_key],
         
     | 
| 
      
 18 
     | 
    
         
            +
                            reflection.klass.columns_hash["#{as}_id"]),
         
     | 
| 
      
 19 
     | 
    
         
            +
                          "#{as}_type" => reflection.klass.quote_value(
         
     | 
| 
      
 20 
     | 
    
         
            +
                            @owner.class.base_class.table_name.to_s,
         
     | 
| 
      
 21 
     | 
    
         
            +
                            reflection.klass.columns_hash["#{as}_type"]) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                      elsif reflection.macro == :belongs_to
         
     | 
| 
      
 23 
     | 
    
         
            +
                        { reflection.klass.primary_key => @owner.class.quote_value(@owner[reflection.primary_key_name]) }
         
     | 
| 
      
 24 
     | 
    
         
            +
                      else
         
     | 
| 
      
 25 
     | 
    
         
            +
                        column = @owner.class.columns_hash[reflection.active_record_primary_key]
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                        { reflection.primary_key_name => @owner.class.quote_value(@owner[reflection.active_record_primary_key], column) }
         
     | 
| 
      
 28 
     | 
    
         
            +
                      end
         
     | 
| 
      
 29 
     | 
    
         
            +
                    end
         
     | 
| 
      
 30 
     | 
    
         
            +
                    def construct_joins(custom_joins = nil)
         
     | 
| 
      
 31 
     | 
    
         
            +
                      polymorphic_join = nil
         
     | 
| 
      
 32 
     | 
    
         
            +
                      if @reflection.source_reflection.macro == :belongs_to
         
     | 
| 
      
 33 
     | 
    
         
            +
                        reflection_primary_key = @reflection.source_reflection.options[:primary_key] ||
         
     | 
| 
      
 34 
     | 
    
         
            +
                          @reflection.klass.primary_key
         
     | 
| 
      
 35 
     | 
    
         
            +
                        source_primary_key = @reflection.source_reflection.primary_key_name
         
     | 
| 
      
 36 
     | 
    
         
            +
                        if @reflection.options[:source_type]
         
     | 
| 
      
 37 
     | 
    
         
            +
                          polymorphic_join = "AND %s.%s = %s" % [
         
     | 
| 
      
 38 
     | 
    
         
            +
                            @reflection.through_reflection.quoted_table_name, "#{@reflection.source_reflection.options[:foreign_type]}",
         
     | 
| 
      
 39 
     | 
    
         
            +
                            @owner.class.quote_value(@reflection.options[:source_type])
         
     | 
| 
      
 40 
     | 
    
         
            +
                          ]
         
     | 
| 
      
 41 
     | 
    
         
            +
                        end
         
     | 
| 
      
 42 
     | 
    
         
            +
                      else
         
     | 
| 
      
 43 
     | 
    
         
            +
                        reflection_primary_key = @reflection.source_reflection.primary_key_name
         
     | 
| 
      
 44 
     | 
    
         
            +
                        source_primary_key     = @reflection.source_reflection.options[:primary_key] ||
         
     | 
| 
      
 45 
     | 
    
         
            +
                          @reflection.through_reflection.klass.primary_key
         
     | 
| 
      
 46 
     | 
    
         
            +
                        if @reflection.source_reflection.options[:as]
         
     | 
| 
      
 47 
     | 
    
         
            +
                          polymorphic_join = "AND %s.%s = %s" % [
         
     | 
| 
      
 48 
     | 
    
         
            +
                            @reflection.quoted_table_name, "#{@reflection.source_reflection.options[:as]}_type",
         
     | 
| 
      
 49 
     | 
    
         
            +
                            @owner.class.quote_value(@reflection.through_reflection.klass.table_name)
         
     | 
| 
      
 50 
     | 
    
         
            +
                          ]
         
     | 
| 
      
 51 
     | 
    
         
            +
                        end
         
     | 
| 
      
 52 
     | 
    
         
            +
                      end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                      "INNER JOIN %s ON %s.%s = %s.%s %s #{@reflection.options[:joins]} #{custom_joins}" % [
         
     | 
| 
      
 55 
     | 
    
         
            +
                        @reflection.through_reflection.quoted_table_name,
         
     | 
| 
      
 56 
     | 
    
         
            +
                        @reflection.quoted_table_name, reflection_primary_key,
         
     | 
| 
      
 57 
     | 
    
         
            +
                        @reflection.through_reflection.quoted_table_name, source_primary_key,
         
     | 
| 
      
 58 
     | 
    
         
            +
                        polymorphic_join
         
     | 
| 
      
 59 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 60 
     | 
    
         
            +
                    end
         
     | 
| 
      
 61 
     | 
    
         
            +
                  end
         
     | 
| 
      
 62 
     | 
    
         
            +
                end
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rake'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            PKG_FILES = Rake::FileList[
         
     | 
| 
      
 5 
     | 
    
         
            +
              '[a-zA-Z]*',
         
     | 
| 
      
 6 
     | 
    
         
            +
              'generators/**/*',
         
     | 
| 
      
 7 
     | 
    
         
            +
              'lib/**/*',
         
     | 
| 
      
 8 
     | 
    
         
            +
              'rails/**/*',
         
     | 
| 
      
 9 
     | 
    
         
            +
              'tasks/**/*',
         
     | 
| 
      
 10 
     | 
    
         
            +
              'test/**/*'
         
     | 
| 
      
 11 
     | 
    
         
            +
            ]
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.name = "polymorphic_as_table"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.version = "0.5.0"
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.author = "Jeremiah Dodds"
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.email = "jeremiah.dodds@gmail.com"
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.homepage = "https://github.com/jdodds/polymorphic_as_table"
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.platform = Gem::Platform::RUBY
         
     | 
| 
      
 20 
     | 
    
         
            +
              s.summary = "Allow for ActiveRecord polymorphic assocations that write their table name as their type"
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.files = PKG_FILES.to_a
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.require_path = "lib"
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.has_rdoc = false
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.extra_rdoc_files = ["README"]
         
     | 
| 
      
 25 
     | 
    
         
            +
            end
         
     | 
    
        data/rails/init.rb
    ADDED
    
    
    
        data/test/database.yml
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            sqlite:
         
     | 
| 
      
 2 
     | 
    
         
            +
                :adapter: sqlite
         
     | 
| 
      
 3 
     | 
    
         
            +
                :database: vendor/plugins/polymorphic_as_table/test/polymorphic_as_table_plugin.sqlite.db
         
     | 
| 
      
 4 
     | 
    
         
            +
            sqlite3:
         
     | 
| 
      
 5 
     | 
    
         
            +
                :adapter: sqlite3
         
     | 
| 
      
 6 
     | 
    
         
            +
                :database: vendor/plugins/polymorphic_as_table/test/polymorphic_as_table_plugin.sqlit3.db
         
     | 
| 
      
 7 
     | 
    
         
            +
            postgresql:
         
     | 
| 
      
 8 
     | 
    
         
            +
                :adapter: postgresql
         
     | 
| 
      
 9 
     | 
    
         
            +
                :username: postgres
         
     | 
| 
      
 10 
     | 
    
         
            +
                :password: postgres
         
     | 
| 
      
 11 
     | 
    
         
            +
                :database: polymorphic_as_table_plugin_test
         
     | 
| 
      
 12 
     | 
    
         
            +
                :min_messages: ERROR
         
     | 
| 
      
 13 
     | 
    
         
            +
            mysql:
         
     | 
| 
      
 14 
     | 
    
         
            +
                :adapter: mysql
         
     | 
| 
      
 15 
     | 
    
         
            +
                :host: localhost
         
     | 
| 
      
 16 
     | 
    
         
            +
                :username: root
         
     | 
| 
      
 17 
     | 
    
         
            +
                :password: password
         
     | 
| 
      
 18 
     | 
    
         
            +
                :database: polymorphic_as_table_plugin_test
         
     | 
| 
         Binary file 
     | 
| 
         @@ -0,0 +1,447 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Logfile created on 2011-08-25 21:03:45 -0400 by logger.rb/25413
         
     | 
| 
      
 2 
     | 
    
         
            +
              [1m[36mSQL (0.6ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 3 
     | 
    
         
            +
              [1m[35mSQL (0.1ms)[0m   SELECT name
         
     | 
| 
      
 4 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 5 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              [1m[36mSQL (11.8ms)[0m  [1mCREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) [0m
         
     | 
| 
      
 8 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 9 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 10 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              [1m[36mSQL (2.6ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 13 
     | 
    
         
            +
              [1m[35mSQL (0.3ms)[0m   SELECT name
         
     | 
| 
      
 14 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 15 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              [1m[36mSQL (3.7ms)[0m  [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
         
     | 
| 
      
 18 
     | 
    
         
            +
              [1m[35mSQL (0.1ms)[0m  PRAGMA index_list("schema_migrations")
         
     | 
| 
      
 19 
     | 
    
         
            +
              [1m[36mSQL (2.8ms)[0m  [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
         
     | 
| 
      
 20 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 21 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 22 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 25 
     | 
    
         
            +
              [1m[35mSQL (2.7ms)[0m  INSERT INTO "schema_migrations" (version) VALUES ('0')
         
     | 
| 
      
 26 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 27 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 28 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 29 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              [1m[36mSQL (10.1ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 32 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 33 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 34 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 35 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 36 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 37 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 38 
     | 
    
         
            +
              [1m[36mSQL (3.1ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 39 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 40 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 41 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 44 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 45 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 46 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 47 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 48 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 49 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              [1m[36mSQL (11.2ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 52 
     | 
    
         
            +
              [1m[35mSQL (3.0ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 53 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 54 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 55 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 56 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 57 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 58 
     | 
    
         
            +
              [1m[36mSQL (3.1ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 59 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 60 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 61 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 64 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 65 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 66 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 67 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 68 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 69 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              [1m[36mSQL (3.5ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 72 
     | 
    
         
            +
              [1m[35mSQL (2.4ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 73 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 74 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 75 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 76 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 77 
     | 
    
         
            +
              [1m[35mSQL (2.4ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 78 
     | 
    
         
            +
              [1m[36mSQL (2.4ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 79 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 80 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 81 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 84 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 85 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 86 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 87 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
              [1m[36mSQL (15.3ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 90 
     | 
    
         
            +
              [1m[35mSQL (2.5ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 91 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 92 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 93 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 94 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 95 
     | 
    
         
            +
              [1m[35mSQL (2.3ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 96 
     | 
    
         
            +
              [1m[36mSQL (2.4ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 97 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 98 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 99 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 102 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 103 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 104 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 105 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
              [1m[36mSQL (10.8ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 108 
     | 
    
         
            +
              [1m[35mSQL (2.3ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 109 
     | 
    
         
            +
              [1m[36mSQL (0.3ms)[0m  [1m SELECT name
         
     | 
| 
      
 110 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 111 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 112 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 113 
     | 
    
         
            +
              [1m[35mSQL (2.6ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 114 
     | 
    
         
            +
              [1m[36mSQL (2.4ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 115 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 116 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 117 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 120 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 121 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 122 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 123 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
              [1m[36mSQL (12.0ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 126 
     | 
    
         
            +
              [1m[35mSQL (2.4ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 127 
     | 
    
         
            +
              [1m[36mSQL (0.3ms)[0m  [1m SELECT name
         
     | 
| 
      
 128 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 129 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 130 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 131 
     | 
    
         
            +
              [1m[35mSQL (2.6ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 132 
     | 
    
         
            +
              [1m[36mSQL (2.4ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 133 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 134 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 135 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 138 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 139 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 140 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 141 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
              [1m[36mSQL (12.9ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 144 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 145 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 146 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 147 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 148 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 149 
     | 
    
         
            +
              [1m[35mSQL (2.6ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 150 
     | 
    
         
            +
              [1m[36mSQL (3.1ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 151 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 152 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 153 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 156 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 157 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 158 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 159 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 160 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
              [1m[36mAREL (0.3ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 163 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 164 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 165 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 168 
     | 
    
         
            +
              [1m[35mSQL (0.3ms)[0m   SELECT name
         
     | 
| 
      
 169 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 170 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 173 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 174 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 175 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
              [1m[36mSQL (9.7ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 178 
     | 
    
         
            +
              [1m[35mSQL (2.4ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 179 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 180 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 181 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 182 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 183 
     | 
    
         
            +
              [1m[35mSQL (2.3ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 184 
     | 
    
         
            +
              [1m[36mSQL (2.4ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 185 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 186 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 187 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 188 
     | 
    
         
            +
             
     | 
| 
      
 189 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 190 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 191 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 192 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 193 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 194 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 195 
     | 
    
         
            +
             
     | 
| 
      
 196 
     | 
    
         
            +
              [1m[36mAREL (0.3ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 197 
     | 
    
         
            +
              [1m[35mAREL (0.4ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:30:49.135365', '2011-08-26 01:30:49.135365')
         
     | 
| 
      
 198 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 199 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:30:49.153912', '2011-08-26 01:30:49.153912')
         
     | 
| 
      
 200 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 201 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 202 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 203 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
              [1m[36mSQL (11.2ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 206 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 207 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 208 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 209 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 210 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 211 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 212 
     | 
    
         
            +
              [1m[36mSQL (2.6ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 213 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 214 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 215 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 218 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 219 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 220 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 221 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 222 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 225 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:31:09.960169', '2011-08-26 01:31:09.960169')
         
     | 
| 
      
 226 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 227 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:31:09.979935', '2011-08-26 01:31:09.979935')
         
     | 
| 
      
 228 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 229 
     | 
    
         
            +
              [1m[35mSQL (0.3ms)[0m   SELECT name
         
     | 
| 
      
 230 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 231 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
              [1m[36mSQL (12.1ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 234 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 235 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 236 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 237 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 238 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 239 
     | 
    
         
            +
              [1m[35mSQL (2.7ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 240 
     | 
    
         
            +
              [1m[36mSQL (2.8ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 241 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 242 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 243 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 246 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 247 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 248 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 249 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 250 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 253 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:31:57.016395', '2011-08-26 01:31:57.016395')
         
     | 
| 
      
 254 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 255 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:31:57.035766', '2011-08-26 01:31:57.035766')
         
     | 
| 
      
 256 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 257 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 258 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 259 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 260 
     | 
    
         
            +
             
     | 
| 
      
 261 
     | 
    
         
            +
              [1m[36mSQL (13.6ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 262 
     | 
    
         
            +
              [1m[35mSQL (3.5ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 263 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 264 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 265 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 266 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 267 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 268 
     | 
    
         
            +
              [1m[36mSQL (2.8ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 269 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 270 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 271 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 272 
     | 
    
         
            +
             
     | 
| 
      
 273 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 274 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 275 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 276 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 277 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 278 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
      
 280 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 281 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:34:20.431842', '2011-08-26 01:34:20.431842')
         
     | 
| 
      
 282 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 283 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:34:20.450938', '2011-08-26 01:34:20.450938')
         
     | 
| 
      
 284 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT imageable_type from `pictures` where id=?[0m
         
     | 
| 
      
 285 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 286 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 287 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 288 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 289 
     | 
    
         
            +
             
     | 
| 
      
 290 
     | 
    
         
            +
              [1m[36mSQL (13.0ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 291 
     | 
    
         
            +
              [1m[35mSQL (2.7ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 292 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 293 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 294 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 295 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 296 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 297 
     | 
    
         
            +
              [1m[36mSQL (2.9ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 298 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 299 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 300 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 301 
     | 
    
         
            +
             
     | 
| 
      
 302 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 303 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 304 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 305 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 306 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 307 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 308 
     | 
    
         
            +
             
     | 
| 
      
 309 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 310 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:34:41.808537', '2011-08-26 01:34:41.808537')
         
     | 
| 
      
 311 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 312 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:34:41.827747', '2011-08-26 01:34:41.827747')
         
     | 
| 
      
 313 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT imageable_type from `pictures` where id=?[0m
         
     | 
| 
      
 314 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 315 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 316 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 317 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
      
 319 
     | 
    
         
            +
              [1m[36mSQL (11.8ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 320 
     | 
    
         
            +
              [1m[35mSQL (3.0ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 321 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 322 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 323 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 324 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 325 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 326 
     | 
    
         
            +
              [1m[36mSQL (2.8ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 327 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 328 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 329 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 330 
     | 
    
         
            +
             
     | 
| 
      
 331 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 332 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 333 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 334 
     | 
    
         
            +
              [1m[35mSQL (0.3ms)[0m   SELECT name
         
     | 
| 
      
 335 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 336 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 337 
     | 
    
         
            +
             
     | 
| 
      
 338 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 339 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:35:39.402742', '2011-08-26 01:35:39.402742')
         
     | 
| 
      
 340 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 341 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:35:39.422133', '2011-08-26 01:35:39.422133')
         
     | 
| 
      
 342 
     | 
    
         
            +
              [1m[36m2 (0.1ms)[0m  [1mSELECT imageable_type from `pictures` where id=?[0m
         
     | 
| 
      
 343 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 344 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 345 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 346 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 347 
     | 
    
         
            +
             
     | 
| 
      
 348 
     | 
    
         
            +
              [1m[36mSQL (9.7ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 349 
     | 
    
         
            +
              [1m[35mSQL (3.4ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 350 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 351 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 352 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 353 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 354 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 355 
     | 
    
         
            +
              [1m[36mSQL (3.0ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 356 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 357 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 358 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 359 
     | 
    
         
            +
             
     | 
| 
      
 360 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 361 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 362 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 363 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 364 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 365 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
      
 367 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 368 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:36:58.477784', '2011-08-26 01:36:58.477784')
         
     | 
| 
      
 369 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 370 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:36:58.496449', '2011-08-26 01:36:58.496449')
         
     | 
| 
      
 371 
     | 
    
         
            +
              [1m[36m2 (0.1ms)[0m  [1mSELECT imageable_type from `pictures` where imageable_id=?[0m
         
     | 
| 
      
 372 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 373 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 374 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 375 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
              [1m[36mSQL (14.9ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 378 
     | 
    
         
            +
              [1m[35mSQL (2.9ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 379 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 380 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 381 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 382 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 383 
     | 
    
         
            +
              [1m[35mSQL (3.2ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 384 
     | 
    
         
            +
              [1m[36mSQL (2.7ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 385 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 386 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 387 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 388 
     | 
    
         
            +
             
     | 
| 
      
 389 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 390 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 391 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 392 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 393 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 394 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 395 
     | 
    
         
            +
             
     | 
| 
      
 396 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 397 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:37:51.749837', '2011-08-26 01:37:51.749837')
         
     | 
| 
      
 398 
     | 
    
         
            +
              [1m[36mAREL (0.3ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 399 
     | 
    
         
            +
              [1m[35mAREL (0.4ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:37:51.775068', '2011-08-26 01:37:51.775068')
         
     | 
| 
      
 400 
     | 
    
         
            +
              [1m[36mSQL (0.3ms)[0m  [1mSELECT imageable_type from `pictures` where imageable_id=2[0m
         
     | 
| 
      
 401 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 402 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 403 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 404 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
              [1m[36mSQL (13.5ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 407 
     | 
    
         
            +
              [1m[35mSQL (2.8ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 408 
     | 
    
         
            +
              [1m[36mSQL (0.4ms)[0m  [1m SELECT name
         
     | 
| 
      
 409 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 410 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 411 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 412 
     | 
    
         
            +
              [1m[35mSQL (3.2ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 413 
     | 
    
         
            +
              [1m[36mSQL (2.9ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 414 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 415 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 416 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 419 
     | 
    
         
            +
              [1m[36mSQL (0.7ms)[0m  [1mselect sqlite_version(*)[0m
         
     | 
| 
      
 420 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 421 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 422 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 423 
     | 
    
         
            +
             
     | 
| 
      
 424 
     | 
    
         
            +
              [1m[36mSQL (9.9ms)[0m  [1mDROP TABLE "pictures"[0m
         
     | 
| 
      
 425 
     | 
    
         
            +
              [1m[35mSQL (3.0ms)[0m  CREATE TABLE "pictures" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "imageable_id" integer, "imageable_type" varchar(255), "created_at" datetime, "updated_at" datetime) 
         
     | 
| 
      
 426 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1m SELECT name
         
     | 
| 
      
 427 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 428 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 429 
     | 
    
         
            +
            [0m
         
     | 
| 
      
 430 
     | 
    
         
            +
              [1m[35mSQL (2.7ms)[0m  DROP TABLE "employees"
         
     | 
| 
      
 431 
     | 
    
         
            +
              [1m[36mSQL (2.8ms)[0m  [1mCREATE TABLE "employees" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255)) [0m
         
     | 
| 
      
 432 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 433 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 434 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 435 
     | 
    
         
            +
             
     | 
| 
      
 436 
     | 
    
         
            +
              [1m[36mSQL (0.1ms)[0m  [1mSELECT version FROM "schema_migrations"[0m
         
     | 
| 
      
 437 
     | 
    
         
            +
              [1m[35mPolymorphicAsTableTest::Picture Load (0.3ms)[0m  SELECT "pictures".* FROM "pictures"
         
     | 
| 
      
 438 
     | 
    
         
            +
              [1m[36mPolymorphicAsTableTest::Employee Load (0.1ms)[0m  [1mSELECT "employees".* FROM "employees"[0m
         
     | 
| 
      
 439 
     | 
    
         
            +
              [1m[35mSQL (0.2ms)[0m   SELECT name
         
     | 
| 
      
 440 
     | 
    
         
            +
             FROM sqlite_master
         
     | 
| 
      
 441 
     | 
    
         
            +
             WHERE type = 'table' AND NOT name = 'sqlite_sequence'
         
     | 
| 
      
 442 
     | 
    
         
            +
             
     | 
| 
      
 443 
     | 
    
         
            +
              [1m[36mAREL (0.4ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 444 
     | 
    
         
            +
              [1m[35mAREL (0.3ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 1, 'employees', '2011-08-26 01:42:44.175030', '2011-08-26 01:42:44.175030')
         
     | 
| 
      
 445 
     | 
    
         
            +
              [1m[36mAREL (0.2ms)[0m  [1mINSERT INTO "employees" ("name") VALUES ('JimBob')[0m
         
     | 
| 
      
 446 
     | 
    
         
            +
              [1m[35mAREL (0.2ms)[0m  INSERT INTO "pictures" ("name", "imageable_id", "imageable_type", "created_at", "updated_at") VALUES ('picture1', 2, 'employees', '2011-08-26 01:42:44.193759', '2011-08-26 01:42:44.193759')
         
     | 
| 
      
 447 
     | 
    
         
            +
              [1m[36mSQL (0.2ms)[0m  [1mSELECT imageable_type from `pictures` where imageable_id=2[0m
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'test_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class PolymorphicAsTableTest < ActiveSupport::TestCase
         
     | 
| 
      
 4 
     | 
    
         
            +
              load_schema
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              class Picture < ActiveRecord::Base
         
     | 
| 
      
 7 
     | 
    
         
            +
                is_polymorphic_as_table
         
     | 
| 
      
 8 
     | 
    
         
            +
                belongs_to :imageable, :polymorphic => true
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              class Employee < ActiveRecord::Base
         
     | 
| 
      
 12 
     | 
    
         
            +
                has_polymorphic_as_table
         
     | 
| 
      
 13 
     | 
    
         
            +
                has_many :pictures, :as => :imageable
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def test_schema_has_loaded_correctly
         
     | 
| 
      
 17 
     | 
    
         
            +
                assert_equal [], Picture.all
         
     | 
| 
      
 18 
     | 
    
         
            +
                assert_equal [], Employee.all
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def test_type_is_written_as_table_name
         
     | 
| 
      
 22 
     | 
    
         
            +
                e = Employee.create(:name => "JimBob")
         
     | 
| 
      
 23 
     | 
    
         
            +
                p = e.pictures.create(:name => "picture1")
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                sql = "SELECT imageable_type from `pictures` where imageable_id=%d"
         
     | 
| 
      
 26 
     | 
    
         
            +
                type = ActiveRecord::Base.connection.select_value(sql %e.id)
         
     | 
| 
      
 27 
     | 
    
         
            +
                assert_equal("employees", type)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              def test_type_is_read_as_class_name
         
     | 
| 
      
 31 
     | 
    
         
            +
                e = Employee.create(:name => "JimBob")
         
     | 
| 
      
 32 
     | 
    
         
            +
                p = e.pictures.create(:name => "picture1")
         
     | 
| 
      
 33 
     | 
    
         
            +
                assert_equal("Employee", p.imageable_type)
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
    
        data/test/schema.rb
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ActiveRecord::Schema.define(:version => 0) do
         
     | 
| 
      
 2 
     | 
    
         
            +
              create_table :pictures, :force => true do |t|
         
     | 
| 
      
 3 
     | 
    
         
            +
                t.string :name
         
     | 
| 
      
 4 
     | 
    
         
            +
                t.integer :imageable_id
         
     | 
| 
      
 5 
     | 
    
         
            +
                t.string :imageable_type
         
     | 
| 
      
 6 
     | 
    
         
            +
                t.timestamps
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
              create_table :employees, :force => true do |t|
         
     | 
| 
      
 9 
     | 
    
         
            +
                t.string :name
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
    
        data/test/test_helper.rb
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            DIR = File.dirname(__FILE__)
         
     | 
| 
      
 2 
     | 
    
         
            +
            ENV['RAILS_ENV'] = 'test'
         
     | 
| 
      
 3 
     | 
    
         
            +
            ENV['RAILS_ROOT'] ||= DIR + '/../../../..'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            def load_schema
         
     | 
| 
      
 9 
     | 
    
         
            +
              config = YAML::load(IO.read(DIR + '/database.yml'))
         
     | 
| 
      
 10 
     | 
    
         
            +
              ActiveRecord::Base.logger = Logger.new(DIR + "/polymorphic_as_table_test.log")
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              db_adapter = ENV['DB']
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              db_adapter ||=
         
     | 
| 
      
 15 
     | 
    
         
            +
                begin
         
     | 
| 
      
 16 
     | 
    
         
            +
                  require 'rubygems'
         
     | 
| 
      
 17 
     | 
    
         
            +
                  require 'sqlite'
         
     | 
| 
      
 18 
     | 
    
         
            +
                  'sqlite'
         
     | 
| 
      
 19 
     | 
    
         
            +
                rescue MissingSourceFile
         
     | 
| 
      
 20 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 21 
     | 
    
         
            +
                    require 'sqlite3'
         
     | 
| 
      
 22 
     | 
    
         
            +
                    'sqlite3'
         
     | 
| 
      
 23 
     | 
    
         
            +
                  rescue MissingSourceFile
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              if db_adapter.nil?
         
     | 
| 
      
 28 
     | 
    
         
            +
                rase "No DB Adapter selected. Set the DB environment variable or install sqlite or sqlite3"
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              ActiveRecord::Base.establish_connection(config[db_adapter])
         
     | 
| 
      
 32 
     | 
    
         
            +
              load(DIR + "/schema.rb")
         
     | 
| 
      
 33 
     | 
    
         
            +
              require DIR + '/../rails/init'
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/uninstall.rb
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # Uninstall hook code here
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,67 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: polymorphic_as_table
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.0
         
     | 
| 
      
 5 
     | 
    
         
            +
              prerelease: 
         
     | 
| 
      
 6 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 7 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Jeremiah Dodds
         
     | 
| 
      
 9 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 10 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 11 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2011-08-26 00:00:00.000000000Z
         
     | 
| 
      
 13 
     | 
    
         
            +
            dependencies: []
         
     | 
| 
      
 14 
     | 
    
         
            +
            description: 
         
     | 
| 
      
 15 
     | 
    
         
            +
            email: jeremiah.dodds@gmail.com
         
     | 
| 
      
 16 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 17 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 18 
     | 
    
         
            +
            extra_rdoc_files:
         
     | 
| 
      
 19 
     | 
    
         
            +
            - README
         
     | 
| 
      
 20 
     | 
    
         
            +
            files:
         
     | 
| 
      
 21 
     | 
    
         
            +
            - install.rb
         
     | 
| 
      
 22 
     | 
    
         
            +
            - uninstall.rb
         
     | 
| 
      
 23 
     | 
    
         
            +
            - polymorphic_as_table-0.5.0.gem
         
     | 
| 
      
 24 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 25 
     | 
    
         
            +
            - README
         
     | 
| 
      
 26 
     | 
    
         
            +
            - MIT-LICENSE
         
     | 
| 
      
 27 
     | 
    
         
            +
            - polymorphic_as_table.gemspec
         
     | 
| 
      
 28 
     | 
    
         
            +
            - lib/polymorphic_as_table.rb
         
     | 
| 
      
 29 
     | 
    
         
            +
            - lib/polymorphic_as_table/association_proxy.rb
         
     | 
| 
      
 30 
     | 
    
         
            +
            - lib/polymorphic_as_table/has_one_association.rb
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/polymorphic_as_table/through_association_scope.rb
         
     | 
| 
      
 32 
     | 
    
         
            +
            - lib/polymorphic_as_table/has_many_association.rb
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/polymorphic_as_table/belongs_to_association.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/polymorphic_as_table/through_reflection.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            - rails/init.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - test/polymorphic_as_table_test.log
         
     | 
| 
      
 37 
     | 
    
         
            +
            - test/schema.rb
         
     | 
| 
      
 38 
     | 
    
         
            +
            - test/test_helper.rb
         
     | 
| 
      
 39 
     | 
    
         
            +
            - test/database.yml
         
     | 
| 
      
 40 
     | 
    
         
            +
            - test/polymorphic_as_table_plugin.sqlit3.db
         
     | 
| 
      
 41 
     | 
    
         
            +
            - test/polymorphic_as_table_test.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            homepage: https://github.com/jdodds/polymorphic_as_table
         
     | 
| 
      
 43 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 44 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 46 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 47 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 48 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 49 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 51 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 52 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 53 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 54 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 55 
     | 
    
         
            +
              none: false
         
     | 
| 
      
 56 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 57 
     | 
    
         
            +
              - - ! '>='
         
     | 
| 
      
 58 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 59 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 60 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 61 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 62 
     | 
    
         
            +
            rubygems_version: 1.8.8
         
     | 
| 
      
 63 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 64 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 65 
     | 
    
         
            +
            summary: Allow for ActiveRecord polymorphic assocations that write their table name
         
     | 
| 
      
 66 
     | 
    
         
            +
              as their type
         
     | 
| 
      
 67 
     | 
    
         
            +
            test_files: []
         
     |