diff --git a/lib/dm-core/adapters/data_objects_adapter.rb b/lib/dm-core/adapters/data_objects_adapter.rb index 9fbbf0ed..41977324 100644 --- a/lib/dm-core/adapters/data_objects_adapter.rb +++ b/lib/dm-core/adapters/data_objects_adapter.rb @@ -328,7 +328,7 @@ def condition_statement(query, operator, left_condition, right_condition) opposite = condition == left_condition ? right_condition : left_condition query.merge_subquery(operator, opposite, condition) "(#{read_statement(condition)})" - + # [].all? is always true elsif condition.kind_of?(Array) && condition.any? && condition.all? { |p| p.kind_of?(Property) } property_values = condition.map { |p| property_to_column_name(query.repository, p, qualify) } diff --git a/lib/dm-core/property.rb b/lib/dm-core/property.rb index 99034c59..de9213fb 100644 --- a/lib/dm-core/property.rb +++ b/lib/dm-core/property.rb @@ -393,7 +393,7 @@ def get(resource) set_original_value(resource, value) - # [YK] Why did we previously care whether options[:default] is nil. + # [YK] Why did we previously care whether options[:default] is nil. # The default value of nil will be applied either way if value.nil? && resource.new_record? && !resource.attribute_loaded?(name) value = default_for(resource) @@ -422,7 +422,7 @@ def set_original_value(resource, val) # @api private def set(resource, value) # [YK] We previously checked for new_record? here, but lazy loading - # is blocked anyway if we're in a new record by by + # is blocked anyway if we're in a new record by by # Resource#reload_attributes. This may eventually be useful for # optimizing, but let's (a) benchmark it first, and (b) do # whatever refactoring is necessary, which will benefit from the diff --git a/lib/dm-core/query.rb b/lib/dm-core/query.rb index fcaf06b7..81c2b322 100644 --- a/lib/dm-core/query.rb +++ b/lib/dm-core/query.rb @@ -439,7 +439,7 @@ def dump_custom_value(property_or_path, bind_value) dump_custom_value(property_or_path.property, bind_value) when Property if property_or_path.custom? - property_or_path.type.dump(bind_value, property_or_path) + property_or_path.type.dump(bind_value, property_or_path) else bind_value end diff --git a/lib/dm-core/resource.rb b/lib/dm-core/resource.rb index f21c8cf2..d011a60d 100644 --- a/lib/dm-core/resource.rb +++ b/lib/dm-core/resource.rb @@ -575,7 +575,7 @@ def initialize(attributes = {}) # :nodoc: assert_valid_model self.attributes = attributes end - + def assert_valid_model # :nodoc: return if self.class._valid_model properties = self.properties diff --git a/spec/integration/association_spec.rb b/spec/integration/association_spec.rb index c6ff918a..7c10454c 100644 --- a/spec/integration/association_spec.rb +++ b/spec/integration/association_spec.rb @@ -376,7 +376,7 @@ class Ostrich y.machine.name.should == 'machine10' end - + it 'should convert NULL parent ids into nils' do Area.first(:name => 'area2').machine.should be_nil end @@ -570,13 +570,13 @@ class Ostrich end machine.areas.size.should == 4 end - + it "#build should add exactly one instance of the built record" do machine = Machine.create(:name => 'my machine') - + original_size = machine.areas.size machine.areas.build(:name => "an area", :machine => machine) - + machine.areas.size.should == original_size + 1 end diff --git a/spec/integration/query_spec.rb b/spec/integration/query_spec.rb index 567a1c37..57fd6262 100644 --- a/spec/integration/query_spec.rb +++ b/spec/integration/query_spec.rb @@ -268,20 +268,20 @@ class << operator find.should have(0).entries end end - + it "should work when id is NOT an empty Array" do repository(ADAPTER) do find = QuerySpec::SailBoat.all(:id.not => []) find.should have(3).entries end end - + it "should work when id is an empty Array and other conditions are specified" do repository(ADAPTER) do find = QuerySpec::SailBoat.all(:id => [], :name => "A") find.should have(0).entries end - end + end it "should work when id is NOT an empty Array and other conditions are specified" do repository(ADAPTER) do diff --git a/spec/integration/repository_spec.rb b/spec/integration/repository_spec.rb index 2b4ab9c4..73bc34aa 100644 --- a/spec/integration/repository_spec.rb +++ b/spec/integration/repository_spec.rb @@ -42,7 +42,7 @@ class SerialFinderSpec sfs = @repository.read_one(@query.merge(:fields => [ :id ], :limit => 1)) sfs.should be_a_kind_of(@model) sfs.should_not be_a_new_record - + sfs.attribute_loaded?(:sample).should be_false sfs.sample.should_not be_nil end diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 7c7dc942..2ef489a1 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -5,7 +5,7 @@ Object.send(:remove_const, :Zoo) if defined?(Zoo) class Zoo include DataMapper::Resource - + property :id, DataMapper::Types::Serial end @@ -13,20 +13,20 @@ class Zoo class Name < DataMapper::Type primitive String track :hash - + def self.load(value, property) value.split(", ").reverse end - + def self.dump(value, property) value && value.reverse.join(", ") end - + def self.typecast(value, property) value end end - + Object.send(:remove_const, :Tomato) if defined?(Tomato) class Tomato include DataMapper::Resource @@ -75,13 +75,13 @@ class Tomato before(:each) do Zoo.class_eval do property :location, String, :field => "City" - + repository(:mock) do property :location, String, :field => "MockCity" end end end - + it 'should accept a custom field' do Zoo.properties[:location].field.should == 'City' end @@ -109,9 +109,9 @@ class Tomato it 'should set the original value to nil' do @resource.original_values[:name].should == nil - end + end end - + it "should not reload the default if you set the property to nil" do @resource.name = nil @resource.name.should == nil @@ -136,11 +136,11 @@ class Tomato @resource.name @resource.original_values[:name].should == "San Diego".hash end - + it "should know it's dirty if a change was made to the object" do @resource.name.upcase! @resource.should be_dirty - end + end end end @@ -163,7 +163,7 @@ class Tomato @resource.original_values[:name].should == "San Diego" end end - + it "should know it's dirty if a change was made to the object" do @resource.name.upcase! @resource.name @@ -181,23 +181,23 @@ class Tomato Zoo.new.name.should == "San Diego" end - + it "provides the resource to the proc" do Zoo.class_eval do property :name, String, :default => proc {|r,p| r.address} property :address, String - end - + end + zoo = Zoo.new zoo.address = "San Diego" zoo.name.should == "San Diego" end - + it "provides the property to the proc" do Zoo.class_eval do property :name, String, :default => proc {|r,p| p.name.to_s} end - + zoo = Zoo.new zoo.name.should == "name" end @@ -209,7 +209,7 @@ class Tomato Zoo.class_eval do property :name, String end - + resource = Zoo.new(:name => "Portland Zoo") resource.name.should == "Portland Zoo" end @@ -223,7 +223,7 @@ class Tomato property :description, String, :lazy => true end Zoo.auto_migrate! - Zoo.create(:name => "San Diego Zoo", :age => 888, + Zoo.create(:name => "San Diego Zoo", :age => 888, :description => "Great Zoo") @resource = Zoo.new end @@ -232,13 +232,13 @@ class Tomato @resource.age = "888" @resource.age.should == 888 end - + it "should lazy load itself first" do resource = Zoo.first resource.description = "Still a Great Zoo" resource.original_values[:description].should == "Great Zoo" end - + it "should only set original_values once" do resource = Zoo.first resource.description = "Still a Great Zoo" @@ -254,7 +254,7 @@ class Tomato property :age, Integer end end - + it 'should set the resource' do resource = Zoo.new resource.name = "Seattle Zoo" @@ -278,7 +278,7 @@ class Tomato Zoo.class_eval do property :name, String, :size => 30 end - + resource = Zoo.new resource.name = 100 resource.name.should == "100" @@ -293,33 +293,33 @@ class Tomato Zoo.create(:id => "100", :name => "San Diego Zoo") zoo = Zoo.first - + # Do we mean for attribute_loaded? to be public? zoo.attribute_loaded?(:id).should == true end - + it "should lazily load other non-loaded, non-lazy fields" do - # This somewhat contorted setup is to successfully test that + # This somewhat contorted setup is to successfully test that # the list of eager properties to be loaded when it's initially # missing is, in fact, repository-scoped Zoo.class_eval do property :id, DataMapper::Types::Serial property :name, String, :lazy => true property :address, String, :lazy => true - + repository(:default2) do property :name, String property :address, String end end - repository(:default2) do + repository(:default2) do Zoo.auto_migrate! Zoo.create(:name => "San Diego Zoo", :address => "San Diego") end repository(:default2) do zoo = Zoo.first(:fields => [:id]) - + zoo.attribute_loaded?(:name).should == false zoo.attribute_loaded?(:address).should == false zoo.name @@ -334,7 +334,7 @@ class Tomato end Zoo.auto_migrate! - + zoo = Zoo.create(:name => %w(Zoo San\ Diego)) Zoo.first.name.should == %w(Zoo San\ Diego) end @@ -345,11 +345,11 @@ class Tomato end Zoo.auto_migrate! - + Zoo.create(:name => %w(Awesome Person\ Dude)) zoo = Zoo.first zoo.name = %w(Awesome Person\ Dude) - + # If we were tracking by hash, this would cause zoo to be dirty, # as its hash would not match the original. Since we've overridden # and are tracking by :get, it won't be dirty @@ -365,7 +365,7 @@ class Tomato end Zoo.auto_migrate! end - + it "should determine nullness" do Zoo.properties[:botanical_name].options[:nullable].should be_true end @@ -495,7 +495,7 @@ class Potato it "should set the field to the correct field_naming_convention" do Zoo.class_eval { property :species, String } Tomato.class_eval { property :genetic_history, DataMapper::Types::Text } - + Zoo.properties[:species].field.should == "species" Tomato.properties[:genetic_history].field.should == "genetic_history" end @@ -522,7 +522,7 @@ class Potato it "should make it possible to define a range size" do Zoo.class_eval { property :cleanliness, String, :size => 0..100 } - Zoo.properties[:cleanliness].size.should == 100 + Zoo.properties[:cleanliness].size.should == 100 end it "should make it possible to define a range length (which defines size)" do @@ -576,7 +576,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :boolean, TrueClass end - + zoo = Zoo.new zoo.boolean = value zoo.boolean.should == true @@ -588,7 +588,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :boolean, TrueClass end - + zoo = Zoo.new zoo.boolean = value zoo.boolean.should == false @@ -599,7 +599,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :boolean, TrueClass end - + zoo = Zoo.new zoo.boolean = nil zoo.boolean.should == nil @@ -609,7 +609,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :string, String end - + zoo = Zoo.new zoo.string = "0" zoo.string.should == "0" @@ -620,7 +620,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :float, Float end - + zoo = Zoo.new zoo.float = value zoo.float.should == expected @@ -635,7 +635,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :int, Integer end - + zoo = Zoo.new zoo.int = value zoo.int.should == expected @@ -647,7 +647,7 @@ def value.to_s() "San Francisco" end Zoo.class_eval do property :big_decimal, BigDecimal end - + zoo = Zoo.new zoo.big_decimal = value zoo.big_decimal.should == expected