dm-core 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +12 -141
- data/QUICKLINKS +1 -2
- data/Rakefile +3 -3
- data/SPECS +9 -10
- data/dm-core.gemspec +10 -13
- data/lib/dm-core.rb +5 -5
- data/lib/dm-core/adapters/data_objects_adapter.rb +1 -1
- data/lib/dm-core/adapters/mysql_adapter.rb +1 -1
- data/lib/dm-core/adapters/postgres_adapter.rb +1 -1
- data/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
- data/lib/dm-core/associations/many_to_one.rb +1 -1
- data/lib/dm-core/associations/one_to_many.rb +3 -6
- data/lib/dm-core/query.rb +2 -3
- data/lib/dm-core/resource.rb +6 -6
- data/lib/dm-core/version.rb +1 -1
- data/script/performance.rb +4 -6
- data/script/profile.rb +2 -2
- data/spec/integration/property_spec.rb +1 -1
- data/spec/integration/resource_spec.rb +6 -0
- data/spec/integration/type_spec.rb +1 -1
- data/spec/models/zoo.rb +1 -0
- data/spec/spec_helper.rb +3 -2
- data/spec/unit/associations/many_to_one_spec.rb +7 -0
- data/spec/unit/query_spec.rb +5 -11
- data/spec/unit/resource_spec.rb +16 -2
- metadata +5 -15
data/History.txt
CHANGED
@@ -1,145 +1,16 @@
|
|
1
|
+
=== 0.9.8 / 2008-12-07
|
1
2
|
|
2
|
-
|
3
|
-
* HasManyAssociation::Set now has a nil? method, so we can do stuff like cage.animal.nil?
|
3
|
+
* 3 minor enhancements:
|
4
4
|
|
5
|
-
|
6
|
-
*
|
7
|
-
|
8
|
-
|
9
|
-
*
|
10
|
-
|
11
|
-
* Added private/protected properties
|
12
|
-
* Remove HasOneAssociation, Make HasManyAssociation impersonate has_one relationships
|
13
|
-
* Added #get method
|
14
|
-
* Persistence module added, inheriting from DataMapper::Base no longer necessary
|
5
|
+
* Updated Resource#inspect to not lazy-load unloaded attributes.
|
6
|
+
* Updated ManyToOne::Proxy to delegate #class to parent. This will
|
7
|
+
allow the Merb resource() route helper method to use the association
|
8
|
+
proxy to generate the URL.
|
9
|
+
* Updated Resource#attributes= to respect method visibility. This means
|
10
|
+
that only public mutators will set the attribute value.
|
15
11
|
|
16
|
-
|
17
|
-
* Bug fixes
|
18
|
-
* Added paranoia
|
12
|
+
* 1 bug fix:
|
19
13
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
* MAJOR: Resolve issue with non-unique-hash values and #dirty?; now frozen original values are stored instead
|
24
|
-
* Added Base#update_attributes
|
25
|
-
* MAJOR: Queries are now passed to the database drivers in a parameterized fashion
|
26
|
-
* Updated PostgreSQL driver and adapter to current
|
27
|
-
|
28
|
-
== 0.2.2
|
29
|
-
* Removed C extension bundles and log files from package
|
30
|
-
|
31
|
-
== 0.2.1
|
32
|
-
* Added :float column support
|
33
|
-
* Added association proxies: ie: Zoo.first.exhibits.animals
|
34
|
-
* Columns stored in SortedSet
|
35
|
-
* Swig files are no longer RDOCed
|
36
|
-
* Added :date column support
|
37
|
-
* BUG: Fixed UTC issues with datetimes
|
38
|
-
* Added #to_yaml method
|
39
|
-
* Added #to_xml method
|
40
|
-
* Added #to_json method
|
41
|
-
* BUG: Fixed HasManyAssociation::Set#inspect
|
42
|
-
* BUG: Fixed #reload!
|
43
|
-
* BUG: Column copy for STI moved into Table#initialize to better handle STI with multiple mapped databases
|
44
|
-
* BUG: before_create callbacks moved in the execution flow since they weren't guaranteed to fire before
|
45
|
-
* Threading enhancements: Removed single_threaded_mode, #database block form adjusted for thread-safety
|
46
|
-
* BUG: Fixed String#blank? when a multi-line string contained a blank line (thanks zapnap!)
|
47
|
-
* Performance enhancements: (thanks wycats!)
|
48
|
-
|
49
|
-
== 0.2.0
|
50
|
-
* AdvancedHasManyAssociation now functional for fetches
|
51
|
-
* AdvancedHasManyAssociation renamed to HasNAssociation
|
52
|
-
* HasManyAssociation refactored to use HasNAssociation superclass
|
53
|
-
* Slight spec tweaks to accomodate the updates
|
54
|
-
* HasOneAssociation refactored to use HasNAssociation superclass
|
55
|
-
* Added HasAndBelongsToManyAssociation, using HasNAssociation as a basis; Need to add corresponding SQL generation code in AdvancedLoadCommand
|
56
|
-
* Added spec for habtm query generation
|
57
|
-
* HasNAssociation#foreign_key returns a DataMapper::Adapters::Sql::Mappings::Column instance instead of a raw String now
|
58
|
-
* Added table, association, association_table and to_sql methods to HasNAssociation
|
59
|
-
* Added associations_spec.rb
|
60
|
-
* Added a forced table-recreation to spec_helper.rb so the tests could run with a clean version of the database, including any new columns added to the models
|
61
|
-
* Added HasAndBelongsToManyAssociation#to_sql (all current specs pass now!)
|
62
|
-
* Minor tweaks to Callbacks
|
63
|
-
* Added CallbacksHelper to declare class-method ::callbacks on DataMapper::Base
|
64
|
-
* Implemented before_validate and after_validate hooks in ValidationHelper
|
65
|
-
* Minor documentation additions in callbacks.rb
|
66
|
-
* Added callbacks_spec
|
67
|
-
* Moved class-method declarations for built-in callbacks to the callbacks helper instead of DataMapper::Base
|
68
|
-
* Renamed :before/after_validate callback to :before/after_validation to match ActiveRecord
|
69
|
-
* Callbacks#add now accepts a Symbol which maps a callback to a method call on the targetted instance, also added a spec to verify this behavior
|
70
|
-
* Documented callbacks.rb
|
71
|
-
* Added DataMapper::Associations::Reference class
|
72
|
-
* Documented DataMapper::Associations::Reference class
|
73
|
-
* Upgraded BelongsToAssociation to new style
|
74
|
-
* Added AssociationsSet to handle simple "last-in" for association bindings
|
75
|
-
* Fixed extra spec loading
|
76
|
-
* Added *Association#columns
|
77
|
-
* Some refactoring in AdvancedLoadCommand regarding :include options
|
78
|
-
* Added support for class-less Mappings::Table instances, with just a string name
|
79
|
-
* HasAndBelongsToManyAssociation#join_table #left_foreign_key and #right_foreign_key reference actual Table or Column objects now
|
80
|
-
* Added :shallow_include option for HABTM joins in AdvancedLoadCommand and corresponding spec
|
81
|
-
* Added Commands::AdvancedConditions
|
82
|
-
* Added ORDER, LIMIT, OFFSET and WHERE support to AdvancedLoadCommand
|
83
|
-
* Renamed spec/has_many.rb to spec/has_many_spec.rb
|
84
|
-
* Tweaked the loading of has_many relationships; big performance boost; got rid of an extra query
|
85
|
-
* Added EmbeddedValue support, and accompanying spec
|
86
|
-
* Fleshed out AdvancedConditions a bit; added conditions_spec.rb
|
87
|
-
* Added more AdvancedConditions specs
|
88
|
-
* Added Loader to handle multi-instanced rows
|
89
|
-
* AdvancedLoadCommand replaced LoadCommand; down to 3 failing specs
|
90
|
-
* All specs pass
|
91
|
-
* Added :intercept_load finder option and accompanying spec
|
92
|
-
* Modified :intercept_load block signature to |instance,columns,row|
|
93
|
-
* HasAndBelongsToMany works, all specs pass
|
94
|
-
* Fixed a couple bugs with keys; Added DataMapper::Base#key= method
|
95
|
-
* Made DataMapper::Base#lazy_load! a little more flexible
|
96
|
-
* Removed LoadCommand overwrites from MysqlAdapter
|
97
|
-
* Default Database#single_threaded mode is true now
|
98
|
-
* Removed MysqlAdapter#initialize, which only served to setup the connections, moved to SqlAdapter
|
99
|
-
* Added SqlAdapter#create_connection and SqlAdapter#close_connection abstract methods
|
100
|
-
* Added MysqlAdapter#create_connection and MysqlAdapter#close_connection concrete methods
|
101
|
-
* Made SqlAdapter#connection a concrete method (instead of abstract), with support for single_threaded operation
|
102
|
-
* Database#setup now takes a Hash of options instead of a block-initializer
|
103
|
-
* Validation chaining should work for all association types
|
104
|
-
* Save chaining should work for has_many associations
|
105
|
-
* Added benchmarks for in-session performance to performance.rb
|
106
|
-
* Removed block conditions; They're slower and don't offer any real advantages
|
107
|
-
* Removed DeleteCommand
|
108
|
-
* Removed SaveCommand
|
109
|
-
* Removed TableExistsCommand
|
110
|
-
* Session renamed to Context
|
111
|
-
* Most command implementations moved to methods in SqlAdapter
|
112
|
-
* Removed UnitOfWork module, instead moving a slightly refactored implementation into Base
|
113
|
-
|
114
|
-
== 0.1.1
|
115
|
-
* Removed /lib/data_mapper/extensions
|
116
|
-
* Moved ActiveRecordImpersonation into DataMapper::Support module
|
117
|
-
* Moved CallbackHelper methods into DataMapper::Base class
|
118
|
-
* Moved ValidationHelper into DataMapper::Validations module
|
119
|
-
* Removed LoadedSet since it's not necessary for it to reference the Database, so it's nothing more than an array now; Replaced with Array
|
120
|
-
* Modified data_mapper.rb to load DataMapper::Support::Enumerable
|
121
|
-
* Modified example.rb and performance.rb to require 'lib/data_mapper' instead of modifying $LOADPATH
|
122
|
-
* Created SqlAdapter base-class
|
123
|
-
* Refactored MysqlAdapter to use SqlAdapter superclass
|
124
|
-
* Refactored Sqlite3Adapter to use SqlAdapter superclass
|
125
|
-
* Moved /lib/data_mapper/queries to /lib/data_mapper/adapters/sql/queries
|
126
|
-
* Moved Connection, Result and Reader classes along with Coersion and Quoting modules to DataMapper::Adapters::Sql module
|
127
|
-
* Moved DataMapper::Adapters::Sql::Queries to ::Commands
|
128
|
-
* Moved Mappings to SqlAdapter
|
129
|
-
* Added monolithic DeleteCommand
|
130
|
-
* Added monolithic SaveCommand
|
131
|
-
* Added TableExistsCommand
|
132
|
-
* Moved save/delete logic out of Session
|
133
|
-
* Added create-table functionality to SaveCommand
|
134
|
-
* Cleaned up Session; #find no longer supported, use #all or #first
|
135
|
-
* Moved object materialization into LoadCommand
|
136
|
-
* Migrated Sqlite3Adapter::Commands
|
137
|
-
* Added Session#query support back in
|
138
|
-
* Removed Connection/Reader/Result classes
|
139
|
-
* Set DataMapper::Base#key on load to avoid double-hit against Schema
|
140
|
-
* Added DataMapper::Support::Struct for increased Session#query performance
|
141
|
-
* Added AdvancedHasManyAssociation (preview status)
|
142
|
-
* Added benchmarks comparing ActiveRecord::Base::find_by_sql with Session#query
|
143
|
-
|
144
|
-
== 0.1.0
|
145
|
-
* Initial Public Release
|
14
|
+
* Fixed regression where an update to a resource with a lazy property
|
15
|
+
could cause the record to reload when accessing the lazy property,
|
16
|
+
clobbering any changes made prior.
|
data/QUICKLINKS
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= Quick Links
|
2
2
|
|
3
3
|
* Setup and Configuration - DataMapper
|
4
|
-
* Finders and CRUD -
|
4
|
+
* Finders and CRUD -
|
5
5
|
* Properties - DataMapper::Property
|
6
6
|
* FAQ[link:/files/FAQ.html]
|
7
7
|
* Contact Us
|
@@ -9,4 +9,3 @@
|
|
9
9
|
* Bug Reports - http://wm.lighthouseapp.com/projects/4819-datamapper/overview
|
10
10
|
* IRC Channel - <tt>##datamapper</tt> on irc.freenode.net
|
11
11
|
* Mailing List - http://groups.google.com/group/datamapper/
|
12
|
-
|
data/Rakefile
CHANGED
@@ -13,9 +13,9 @@ AUTHOR = "Sam Smoot"
|
|
13
13
|
EMAIL = "ssmoot@gmail.com"
|
14
14
|
GEM_NAME = "dm-core"
|
15
15
|
GEM_VERSION = DataMapper::VERSION
|
16
|
-
GEM_DEPENDENCIES = ["data_objects", "~>0.9.
|
17
|
-
["
|
18
|
-
|
16
|
+
GEM_DEPENDENCIES = ["data_objects", "~>0.9.9"],
|
17
|
+
["extlib", "~>0.9.9"],
|
18
|
+
["addressable", "~>2.0.1"]
|
19
19
|
|
20
20
|
PROJECT_NAME = "datamapper"
|
21
21
|
PROJECT_DESCRIPTION = "Faster, Better, Simpler."
|
data/SPECS
CHANGED
@@ -2,14 +2,14 @@ Reading Specs
|
|
2
2
|
=============
|
3
3
|
|
4
4
|
Blah blah blah...
|
5
|
-
|
5
|
+
|
6
6
|
Writing Specs
|
7
7
|
=============
|
8
8
|
|
9
9
|
Here are some general dos and don'ts
|
10
|
-
|
10
|
+
|
11
11
|
= DO:
|
12
|
-
|
12
|
+
|
13
13
|
* Write more specs for error conditions than clean conditions.
|
14
14
|
* Write specs with readability in mind. Somebody knew to DataMapper should be
|
15
15
|
able to read specs to learn how something works.
|
@@ -18,14 +18,14 @@ Writing Specs
|
|
18
18
|
* Limit a describe block to 10 - 15 examples.
|
19
19
|
* Group specs by method being tested. (See the 'Ordering Specs' section)
|
20
20
|
* Use custom matchers.
|
21
|
-
|
21
|
+
|
22
22
|
= DON'T:
|
23
|
-
|
23
|
+
|
24
24
|
* Spec more than one unit of functionality in an example. An example should be
|
25
25
|
as short as possible (while still remaining readable).
|
26
26
|
* Spec implementation. Refactoring code should not break specs.
|
27
27
|
* Declare models in the spec file.
|
28
|
-
|
28
|
+
|
29
29
|
And a final do: Do go against the guidelines if your best judgement tells you
|
30
30
|
to. These are just guidelines and are obviously not fast rules.
|
31
31
|
|
@@ -39,7 +39,7 @@ Models
|
|
39
39
|
few simple metaphors, such as a zoo, a blog implementation, etc... Following
|
40
40
|
metaphors makes it easier for a reader to guess what is going on with respect
|
41
41
|
to the models.
|
42
|
-
|
42
|
+
|
43
43
|
The second reason is to allow the spec environment to be as pristine as
|
44
44
|
possible going into an example. Models being loaded from the model directory
|
45
45
|
are tracked and reloaded before each example. Any changes that might be made
|
@@ -51,13 +51,12 @@ Mocks and Stubs
|
|
51
51
|
Obviously, mocks and stubs are a powerful feature when it comes to BDD;
|
52
52
|
however, remember that you are writing specs for behavior and NOT
|
53
53
|
implementation.
|
54
|
-
|
54
|
+
|
55
55
|
Ordering Specs
|
56
56
|
==============
|
57
57
|
|
58
58
|
Specs aren't much use if nobody can find where anything is, so keeping specs
|
59
59
|
well organized is critical. Currently, we are trying out the following
|
60
60
|
structure:
|
61
|
-
|
61
|
+
|
62
62
|
* List guidelines here...
|
63
|
-
|
data/dm-core.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{dm-core}
|
3
|
-
s.version =
|
3
|
+
s.version = '0.9.8'
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Sam Smoot"]
|
@@ -22,20 +22,17 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.specification_version = 2
|
23
23
|
|
24
24
|
if current_version >= 3 then
|
25
|
-
s.add_runtime_dependency(%q<data_objects>, ["~> 0.9.
|
26
|
-
s.add_runtime_dependency(%q<extlib>, ["~> 0.9.
|
27
|
-
s.add_runtime_dependency(%q<
|
28
|
-
s.add_runtime_dependency(%q<addressable>, ["~> 2.0"])
|
25
|
+
s.add_runtime_dependency(%q<data_objects>, ["~> 0.9.9"])
|
26
|
+
s.add_runtime_dependency(%q<extlib>, ["~> 0.9.9"])
|
27
|
+
s.add_runtime_dependency(%q<addressable>, ["~> 2.0.1"])
|
29
28
|
else
|
30
|
-
s.add_dependency(%q<data_objects>, ["~> 0.9.
|
31
|
-
s.add_dependency(%q<extlib>, ["~> 0.9.
|
32
|
-
s.add_dependency(%q<
|
33
|
-
s.add_dependency(%q<addressable>, ["~> 2.0"])
|
29
|
+
s.add_dependency(%q<data_objects>, ["~> 0.9.9"])
|
30
|
+
s.add_dependency(%q<extlib>, ["~> 0.9.9"])
|
31
|
+
s.add_dependency(%q<addressable>, ["~> 2.0.1"])
|
34
32
|
end
|
35
33
|
else
|
36
|
-
s.add_dependency(%q<data_objects>, ["~> 0.9.
|
37
|
-
s.add_dependency(%q<extlib>, ["~> 0.9.
|
38
|
-
s.add_dependency(%q<
|
39
|
-
s.add_dependency(%q<addressable>, ["~> 2.0"])
|
34
|
+
s.add_dependency(%q<data_objects>, ["~> 0.9.9"])
|
35
|
+
s.add_dependency(%q<extlib>, ["~> 0.9.9"])
|
36
|
+
s.add_dependency(%q<addressable>, ["~> 2.0.1"])
|
40
37
|
end
|
41
38
|
end
|
data/lib/dm-core.rb
CHANGED
@@ -11,20 +11,20 @@
|
|
11
11
|
|
12
12
|
require 'date'
|
13
13
|
require 'pathname'
|
14
|
+
require 'rubygems'
|
14
15
|
require 'set'
|
15
16
|
require 'time'
|
16
17
|
require 'yaml'
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
gem 'addressable', '~>2.0'
|
19
|
+
gem 'addressable', '~>2.0.1'
|
21
20
|
require 'addressable/uri'
|
22
21
|
|
23
|
-
gem 'extlib', '~>0.9.
|
22
|
+
gem 'extlib', '~>0.9.9'
|
24
23
|
require 'extlib'
|
25
|
-
require
|
24
|
+
require 'extlib/inflection'
|
26
25
|
|
27
26
|
begin
|
27
|
+
gem 'fastthread', '~>1.0.1'
|
28
28
|
require 'fastthread'
|
29
29
|
rescue LoadError
|
30
30
|
# fastthread not installed
|
@@ -48,7 +48,7 @@ module DataMapper
|
|
48
48
|
class Proxy
|
49
49
|
include Assertions
|
50
50
|
|
51
|
-
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__
|
51
|
+
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
|
52
52
|
|
53
53
|
def replace(parent)
|
54
54
|
@parent = parent
|
@@ -72,7 +72,7 @@ module DataMapper
|
|
72
72
|
class Proxy
|
73
73
|
include Assertions
|
74
74
|
|
75
|
-
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
|
75
|
+
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ class kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m.to_s) }
|
76
76
|
|
77
77
|
# FIXME: remove when RelationshipChain#get_children can return a Collection
|
78
78
|
def all(query = {})
|
@@ -306,11 +306,8 @@ module DataMapper
|
|
306
306
|
end
|
307
307
|
|
308
308
|
def method_missing(method, *args, &block)
|
309
|
-
results = children.
|
310
|
-
|
311
|
-
return self if LazyArray::RETURN_SELF.include?(method) && results.kind_of?(Array)
|
312
|
-
|
313
|
-
results
|
309
|
+
results = children.send(method, *args, &block)
|
310
|
+
results.equal?(children) ? self : results
|
314
311
|
end
|
315
312
|
end # class Proxy
|
316
313
|
end # module OneToMany
|
data/lib/dm-core/query.rb
CHANGED
@@ -51,11 +51,10 @@ module DataMapper
|
|
51
51
|
@limit = other.limit unless other.limit == nil
|
52
52
|
@order = other.order unless other.order == model.default_order
|
53
53
|
@add_reversed = other.add_reversed? unless other.add_reversed? == false
|
54
|
+
@fields = other.fields unless other.fields == @properties.defaults
|
54
55
|
@links = other.links unless other.links == []
|
55
56
|
@includes = other.includes unless other.includes == []
|
56
57
|
|
57
|
-
@fields == @properties.defaults ? @fields = other.fields : @fields |= other.fields
|
58
|
-
|
59
58
|
update_conditions(other)
|
60
59
|
|
61
60
|
self
|
@@ -574,7 +573,7 @@ module DataMapper
|
|
574
573
|
class Path
|
575
574
|
include Assertions
|
576
575
|
|
577
|
-
|
576
|
+
instance_methods.each { |m| undef_method m if %w[ id type ].include?(m.to_s) }
|
578
577
|
|
579
578
|
attr_reader :relationships, :model, :property, :operator
|
580
579
|
|
data/lib/dm-core/resource.rb
CHANGED
@@ -198,7 +198,7 @@ module DataMapper
|
|
198
198
|
attrs = []
|
199
199
|
|
200
200
|
properties.each do |property|
|
201
|
-
value = if
|
201
|
+
value = if !attribute_loaded?(property.name) && !new_record?
|
202
202
|
'<not loaded>'
|
203
203
|
else
|
204
204
|
send(property.getter).inspect
|
@@ -491,13 +491,13 @@ module DataMapper
|
|
491
491
|
# --
|
492
492
|
# @api public
|
493
493
|
def attributes=(values_hash)
|
494
|
-
values_hash.
|
495
|
-
|
494
|
+
values_hash.each do |name, value|
|
495
|
+
name = name.to_s.sub(/\?\z/, '')
|
496
496
|
|
497
|
-
if
|
498
|
-
send(setter,
|
497
|
+
if self.class.public_method_defined?(setter = "#{name}=")
|
498
|
+
send(setter, value)
|
499
499
|
else
|
500
|
-
raise
|
500
|
+
raise ArgumentError, "The property '#{name}' is not a public property."
|
501
501
|
end
|
502
502
|
end
|
503
503
|
end
|
data/lib/dm-core/version.rb
CHANGED
data/script/performance.rb
CHANGED
@@ -3,18 +3,16 @@
|
|
3
3
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core')
|
4
4
|
require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core', 'version')
|
5
5
|
|
6
|
-
require 'rubygems'
|
7
6
|
require 'ftools'
|
7
|
+
require 'rubygems'
|
8
8
|
|
9
|
-
|
10
|
-
# OR git clone git://github.com/somebee/rbench.git , rake install
|
11
|
-
gem 'rbench', '>=0.2.2'
|
9
|
+
gem 'rbench', '~>0.2.3'
|
12
10
|
require 'rbench'
|
13
11
|
|
14
|
-
gem 'faker', '
|
12
|
+
gem 'faker', '~>0.3.1'
|
15
13
|
require 'faker'
|
16
14
|
|
17
|
-
gem 'activerecord', '
|
15
|
+
gem 'activerecord', '~>2.2.2'
|
18
16
|
require 'active_record'
|
19
17
|
|
20
18
|
socket_file = Pathname.glob(%w[
|
data/script/profile.rb
CHANGED
@@ -4,10 +4,10 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'dm-core')
|
|
4
4
|
|
5
5
|
require 'rubygems'
|
6
6
|
|
7
|
-
gem 'ruby-prof', '
|
7
|
+
gem 'ruby-prof', '~>0.7.1'
|
8
8
|
require 'ruby-prof'
|
9
9
|
|
10
|
-
gem 'faker', '
|
10
|
+
gem 'faker', '~>0.3.1'
|
11
11
|
require 'faker'
|
12
12
|
|
13
13
|
OUTPUT = DataMapper.root / 'profile_results.txt'
|
@@ -21,6 +21,12 @@ if ADAPTER
|
|
21
21
|
lambda { @zoo.destroy.should be_true }.should_not raise_error
|
22
22
|
end
|
23
23
|
|
24
|
+
it 'should not overwrite attributes when lazy loading' do
|
25
|
+
zoo = Zoo.first
|
26
|
+
zoo.name = 'San Diego'
|
27
|
+
lambda { zoo.description }.should_not change(zoo, :name)
|
28
|
+
end
|
29
|
+
|
24
30
|
describe '#attribute_get' do
|
25
31
|
it 'should provide #attribute_get' do
|
26
32
|
Zoo.new.should respond_to(:attribute_get)
|
data/spec/models/zoo.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -30,6 +30,13 @@ describe DataMapper::Associations::ManyToOne::Proxy do
|
|
30
30
|
@association.should respond_to(:replace)
|
31
31
|
end
|
32
32
|
|
33
|
+
describe '#class' do
|
34
|
+
it 'should be forwarded to parent' do
|
35
|
+
@parent.should_receive(:class).and_return(Manufacturer)
|
36
|
+
@association.class.should == Manufacturer
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
33
40
|
describe '#replace' do
|
34
41
|
before do
|
35
42
|
@other = mock('other parent')
|
data/spec/unit/query_spec.rb
CHANGED
@@ -219,17 +219,6 @@ describe DataMapper::Query do
|
|
219
219
|
@query.update(other).should == @query
|
220
220
|
end
|
221
221
|
|
222
|
-
it "should merge #fields if :fields != model.properties.defaults" do
|
223
|
-
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
|
224
|
-
@query.update(other).fields.should == Article.properties.slice(:id, :author, :blog_id)
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should replace #fields if fields == model.properties.defaults" do
|
228
|
-
query = DataMapper::Query.new(@repository, Article, :fields => Article.properties.defaults.map { |property| property.name })
|
229
|
-
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
|
230
|
-
query.update(other).fields.should == Article.properties.slice(:blog_id)
|
231
|
-
end
|
232
|
-
|
233
222
|
describe 'should overwrite the attribute' do
|
234
223
|
it '#reload? with other reload?' do
|
235
224
|
other = DataMapper::Query.new(@repository, Article, :reload => true)
|
@@ -314,6 +303,11 @@ describe DataMapper::Query do
|
|
314
303
|
end
|
315
304
|
end
|
316
305
|
|
306
|
+
it "#fields with other fields unique values" do
|
307
|
+
other = DataMapper::Query.new(@repository, Article, :fields => [ :blog_id ])
|
308
|
+
@query.update(other).fields.should == Article.properties.slice(:blog_id)
|
309
|
+
end
|
310
|
+
|
317
311
|
it '#conditions with other conditions when they are unique' do
|
318
312
|
# set the initial conditions
|
319
313
|
@query.update(:title => 'On DataMapper')
|
data/spec/unit/resource_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe DataMapper::Resource do
|
|
11
11
|
zoo.description = "This is a pretty awesome zoo"
|
12
12
|
zoo.attributes.should == {
|
13
13
|
:name => "San Francisco", :description => "This is a pretty awesome zoo",
|
14
|
-
:id => nil, :inception => nil, :open => false, :size => nil
|
14
|
+
:id => nil, :inception => nil, :open => false, :size => nil, :mission => nil
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
@@ -24,6 +24,20 @@ describe DataMapper::Resource do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
describe "#attributes=" do
|
28
|
+
before(:each) do
|
29
|
+
@zoo = Zoo.new(:name => "San Francisco", :size => 10)
|
30
|
+
@zoo.attributes = {:size => 12 }
|
31
|
+
end
|
32
|
+
it "should change a public property" do
|
33
|
+
@zoo.size.should == 12
|
34
|
+
end
|
35
|
+
it "should raise when attempting to change a property with a non-public writer" do
|
36
|
+
lambda { @zoo.attributes = {:mission => "Just keep some odd
|
37
|
+
critters, y'know?" } }.should raise_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
27
41
|
# ---------- REPOSITORY WRITE METHODS ---------------
|
28
42
|
|
29
43
|
describe '#save' do
|
@@ -348,7 +362,7 @@ describe DataMapper::Resource do
|
|
348
362
|
it "should not be able to set private attributes" do
|
349
363
|
lambda {
|
350
364
|
jupiter = Planet.new({ :core => "Molten Metal" })
|
351
|
-
}.should raise_error(
|
365
|
+
}.should raise_error(ArgumentError)
|
352
366
|
end
|
353
367
|
|
354
368
|
it "should not mark attributes dirty if they are similar after update" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Smoot
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-07 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.9
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: extlib
|
@@ -30,17 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 1.1.3
|
33
|
+
version: 0.9.9
|
44
34
|
version:
|
45
35
|
- !ruby/object:Gem::Dependency
|
46
36
|
name: addressable
|
@@ -50,7 +40,7 @@ dependencies:
|
|
50
40
|
requirements:
|
51
41
|
- - ~>
|
52
42
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
43
|
+
version: 2.0.1
|
54
44
|
version:
|
55
45
|
description: Faster, Better, Simpler.
|
56
46
|
email:
|