datamapper-dm-core 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +1 -1
- data/Rakefile +1 -3
- data/deps.rip +2 -0
- data/dm-core.gemspec +9 -9
- data/lib/dm-core/associations/many_to_many.rb +28 -16
- data/lib/dm-core/associations/one_to_many.rb +1 -1
- data/lib/dm-core/resource.rb +13 -3
- data/lib/dm-core/version.rb +1 -1
- data/spec/public/migrations_spec.rb +359 -0
- data/spec/public/shared/resource_shared_spec.rb +2 -2
- data/spec/semipublic/shared/condition_shared_spec.rb +9 -0
- data/tasks/hoe.rb +2 -2
- metadata +7 -4
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby -KU
|
2
|
-
|
3
1
|
require 'pathname'
|
4
2
|
require 'rubygems'
|
5
3
|
require 'rake'
|
@@ -14,7 +12,7 @@ EMAIL = 'dan.kubb@gmail.com'
|
|
14
12
|
GEM_NAME = 'dm-core'
|
15
13
|
GEM_VERSION = DataMapper::VERSION
|
16
14
|
GEM_DEPENDENCIES = [
|
17
|
-
%w[ extlib ~>0.9.
|
15
|
+
%w[ extlib ~>0.9.14 ],
|
18
16
|
%w[ addressable ~>2.1 ],
|
19
17
|
]
|
20
18
|
|
data/deps.rip
ADDED
data/dm-core.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{dm-core}
|
5
|
-
s.version = "0.10.
|
5
|
+
s.version = "0.10.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Dan Kubb"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-09-21}
|
10
10
|
s.description = %q{Faster, Better, Simpler.}
|
11
11
|
s.email = ["dan.kubb@gmail.com"]
|
12
12
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
13
|
-
s.files = [".autotest", ".gitignore", "CONTRIBUTING", "FAQ", "History.txt", "MIT-LICENSE", "Manifest.txt", "QUICKLINKS", "README.txt", "Rakefile", "SPECS", "TODO", "dm-core.gemspec", "lib/dm-core.rb", "lib/dm-core/adapters.rb", "lib/dm-core/adapters/abstract_adapter.rb", "lib/dm-core/adapters/data_objects_adapter.rb", "lib/dm-core/adapters/in_memory_adapter.rb", "lib/dm-core/adapters/mysql_adapter.rb", "lib/dm-core/adapters/oracle_adapter.rb", "lib/dm-core/adapters/postgres_adapter.rb", "lib/dm-core/adapters/sqlite3_adapter.rb", "lib/dm-core/adapters/yaml_adapter.rb", "lib/dm-core/associations/many_to_many.rb", "lib/dm-core/associations/many_to_one.rb", "lib/dm-core/associations/one_to_many.rb", "lib/dm-core/associations/one_to_one.rb", "lib/dm-core/associations/relationship.rb", "lib/dm-core/collection.rb", "lib/dm-core/core_ext/kernel.rb", "lib/dm-core/core_ext/symbol.rb", "lib/dm-core/identity_map.rb", "lib/dm-core/migrations.rb", "lib/dm-core/model.rb", "lib/dm-core/model/descendant_set.rb", "lib/dm-core/model/hook.rb", "lib/dm-core/model/is.rb", "lib/dm-core/model/property.rb", "lib/dm-core/model/relationship.rb", "lib/dm-core/model/scope.rb", "lib/dm-core/property.rb", "lib/dm-core/property_set.rb", "lib/dm-core/query.rb", "lib/dm-core/query/conditions/comparison.rb", "lib/dm-core/query/conditions/operation.rb", "lib/dm-core/query/direction.rb", "lib/dm-core/query/operator.rb", "lib/dm-core/query/path.rb", "lib/dm-core/query/sort.rb", "lib/dm-core/repository.rb", "lib/dm-core/resource.rb", "lib/dm-core/spec/adapter_shared_spec.rb", "lib/dm-core/spec/data_objects_adapter_shared_spec.rb", "lib/dm-core/support/chainable.rb", "lib/dm-core/support/deprecate.rb", "lib/dm-core/support/equalizer.rb", "lib/dm-core/support/logger.rb", "lib/dm-core/support/naming_conventions.rb", "lib/dm-core/transaction.rb", "lib/dm-core/type.rb", "lib/dm-core/types/boolean.rb", "lib/dm-core/types/discriminator.rb", "lib/dm-core/types/object.rb", "lib/dm-core/types/paranoid_boolean.rb", "lib/dm-core/types/paranoid_datetime.rb", "lib/dm-core/types/serial.rb", "lib/dm-core/types/text.rb", "lib/dm-core/version.rb", "script/performance.rb", "script/profile.rb", "spec/lib/adapter_helpers.rb", "spec/lib/collection_helpers.rb", "spec/lib/counter_adapter.rb", "spec/lib/pending_helpers.rb", "spec/lib/rspec_immediate_feedback_formatter.rb", "spec/public/associations/many_to_many_spec.rb", "spec/public/associations/many_to_one_spec.rb", "spec/public/associations/one_to_many_spec.rb", "spec/public/associations/one_to_one_spec.rb", "spec/public/collection_spec.rb", "spec/public/model/relationship_spec.rb", "spec/public/model_spec.rb", "spec/public/property_spec.rb", "spec/public/resource_spec.rb", "spec/public/sel_spec.rb", "spec/public/setup_spec.rb", "spec/public/shared/association_collection_shared_spec.rb", "spec/public/shared/collection_shared_spec.rb", "spec/public/shared/finder_shared_spec.rb", "spec/public/shared/resource_shared_spec.rb", "spec/public/shared/sel_shared_spec.rb", "spec/public/transaction_spec.rb", "spec/public/types/discriminator_spec.rb", "spec/semipublic/adapters/abstract_adapter_spec.rb", "spec/semipublic/adapters/in_memory_adapter_spec.rb", "spec/semipublic/adapters/mysql_adapter_spec.rb", "spec/semipublic/adapters/oracle_adapter_spec.rb", "spec/semipublic/adapters/postgres_adapter_spec.rb", "spec/semipublic/adapters/sqlite3_adapter_spec.rb", "spec/semipublic/adapters/yaml_adapter_spec.rb", "spec/semipublic/associations/many_to_one_spec.rb", "spec/semipublic/associations/relationship_spec.rb", "spec/semipublic/associations_spec.rb", "spec/semipublic/collection_spec.rb", "spec/semipublic/property_spec.rb", "spec/semipublic/query/conditions_spec.rb", "spec/semipublic/query/path_spec.rb", "spec/semipublic/query_spec.rb", "spec/semipublic/resource_spec.rb", "spec/semipublic/shared/resource_shared_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/ci.rb", "tasks/dm.rb", "tasks/doc.rb", "tasks/gemspec.rb", "tasks/hoe.rb", "tasks/install.rb"]
|
13
|
+
s.files = [".autotest", ".gitignore", "CONTRIBUTING", "FAQ", "History.txt", "MIT-LICENSE", "Manifest.txt", "QUICKLINKS", "README.txt", "Rakefile", "SPECS", "TODO", "deps.rip", "dm-core.gemspec", "lib/dm-core.rb", "lib/dm-core/adapters.rb", "lib/dm-core/adapters/abstract_adapter.rb", "lib/dm-core/adapters/data_objects_adapter.rb", "lib/dm-core/adapters/in_memory_adapter.rb", "lib/dm-core/adapters/mysql_adapter.rb", "lib/dm-core/adapters/oracle_adapter.rb", "lib/dm-core/adapters/postgres_adapter.rb", "lib/dm-core/adapters/sqlite3_adapter.rb", "lib/dm-core/adapters/yaml_adapter.rb", "lib/dm-core/associations/many_to_many.rb", "lib/dm-core/associations/many_to_one.rb", "lib/dm-core/associations/one_to_many.rb", "lib/dm-core/associations/one_to_one.rb", "lib/dm-core/associations/relationship.rb", "lib/dm-core/collection.rb", "lib/dm-core/core_ext/kernel.rb", "lib/dm-core/core_ext/symbol.rb", "lib/dm-core/identity_map.rb", "lib/dm-core/migrations.rb", "lib/dm-core/model.rb", "lib/dm-core/model/descendant_set.rb", "lib/dm-core/model/hook.rb", "lib/dm-core/model/is.rb", "lib/dm-core/model/property.rb", "lib/dm-core/model/relationship.rb", "lib/dm-core/model/scope.rb", "lib/dm-core/property.rb", "lib/dm-core/property_set.rb", "lib/dm-core/query.rb", "lib/dm-core/query/conditions/comparison.rb", "lib/dm-core/query/conditions/operation.rb", "lib/dm-core/query/direction.rb", "lib/dm-core/query/operator.rb", "lib/dm-core/query/path.rb", "lib/dm-core/query/sort.rb", "lib/dm-core/repository.rb", "lib/dm-core/resource.rb", "lib/dm-core/spec/adapter_shared_spec.rb", "lib/dm-core/spec/data_objects_adapter_shared_spec.rb", "lib/dm-core/support/chainable.rb", "lib/dm-core/support/deprecate.rb", "lib/dm-core/support/equalizer.rb", "lib/dm-core/support/logger.rb", "lib/dm-core/support/naming_conventions.rb", "lib/dm-core/transaction.rb", "lib/dm-core/type.rb", "lib/dm-core/types/boolean.rb", "lib/dm-core/types/discriminator.rb", "lib/dm-core/types/object.rb", "lib/dm-core/types/paranoid_boolean.rb", "lib/dm-core/types/paranoid_datetime.rb", "lib/dm-core/types/serial.rb", "lib/dm-core/types/text.rb", "lib/dm-core/version.rb", "script/performance.rb", "script/profile.rb", "spec/lib/adapter_helpers.rb", "spec/lib/collection_helpers.rb", "spec/lib/counter_adapter.rb", "spec/lib/pending_helpers.rb", "spec/lib/rspec_immediate_feedback_formatter.rb", "spec/public/associations/many_to_many_spec.rb", "spec/public/associations/many_to_one_spec.rb", "spec/public/associations/one_to_many_spec.rb", "spec/public/associations/one_to_one_spec.rb", "spec/public/collection_spec.rb", "spec/public/migrations_spec.rb", "spec/public/model/relationship_spec.rb", "spec/public/model_spec.rb", "spec/public/property_spec.rb", "spec/public/resource_spec.rb", "spec/public/sel_spec.rb", "spec/public/setup_spec.rb", "spec/public/shared/association_collection_shared_spec.rb", "spec/public/shared/collection_shared_spec.rb", "spec/public/shared/finder_shared_spec.rb", "spec/public/shared/resource_shared_spec.rb", "spec/public/shared/sel_shared_spec.rb", "spec/public/transaction_spec.rb", "spec/public/types/discriminator_spec.rb", "spec/semipublic/adapters/abstract_adapter_spec.rb", "spec/semipublic/adapters/in_memory_adapter_spec.rb", "spec/semipublic/adapters/mysql_adapter_spec.rb", "spec/semipublic/adapters/oracle_adapter_spec.rb", "spec/semipublic/adapters/postgres_adapter_spec.rb", "spec/semipublic/adapters/sqlite3_adapter_spec.rb", "spec/semipublic/adapters/yaml_adapter_spec.rb", "spec/semipublic/associations/many_to_one_spec.rb", "spec/semipublic/associations/relationship_spec.rb", "spec/semipublic/associations_spec.rb", "spec/semipublic/collection_spec.rb", "spec/semipublic/property_spec.rb", "spec/semipublic/query/conditions_spec.rb", "spec/semipublic/query/path_spec.rb", "spec/semipublic/query_spec.rb", "spec/semipublic/resource_spec.rb", "spec/semipublic/shared/condition_shared_spec.rb", "spec/semipublic/shared/resource_shared_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "tasks/ci.rb", "tasks/dm.rb", "tasks/doc.rb", "tasks/gemspec.rb", "tasks/hoe.rb", "tasks/install.rb"]
|
14
14
|
s.homepage = %q{http://datamapper.org}
|
15
15
|
s.rdoc_options = ["--main", "README.txt"]
|
16
16
|
s.require_paths = ["lib"]
|
@@ -23,14 +23,14 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.specification_version = 3
|
24
24
|
|
25
25
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
-
s.add_runtime_dependency(%q<extlib>, ["~> 0.9.
|
27
|
-
s.add_runtime_dependency(%q<addressable>, ["~> 2.
|
26
|
+
s.add_runtime_dependency(%q<extlib>, ["~> 0.9.14"])
|
27
|
+
s.add_runtime_dependency(%q<addressable>, ["~> 2.1"])
|
28
28
|
else
|
29
|
-
s.add_dependency(%q<extlib>, ["~> 0.9.
|
30
|
-
s.add_dependency(%q<addressable>, ["~> 2.
|
29
|
+
s.add_dependency(%q<extlib>, ["~> 0.9.14"])
|
30
|
+
s.add_dependency(%q<addressable>, ["~> 2.1"])
|
31
31
|
end
|
32
32
|
else
|
33
|
-
s.add_dependency(%q<extlib>, ["~> 0.9.
|
34
|
-
s.add_dependency(%q<addressable>, ["~> 2.
|
33
|
+
s.add_dependency(%q<extlib>, ["~> 0.9.14"])
|
34
|
+
s.add_dependency(%q<addressable>, ["~> 2.1"])
|
35
35
|
end
|
36
36
|
end
|
@@ -343,6 +343,26 @@ module DataMapper
|
|
343
343
|
super
|
344
344
|
end
|
345
345
|
|
346
|
+
# Return the intermediaries between the source and the targets
|
347
|
+
#
|
348
|
+
# @return [Collection]
|
349
|
+
# the intermediary collection
|
350
|
+
#
|
351
|
+
# @api public
|
352
|
+
def intermediaries
|
353
|
+
return @intermediaries if @intermediaries
|
354
|
+
|
355
|
+
intermediaries = if through.loaded?(source)
|
356
|
+
through.get!(source)
|
357
|
+
else
|
358
|
+
through.set!(source, through.collection_for(source))
|
359
|
+
end
|
360
|
+
|
361
|
+
scoped = intermediaries.all(via => self)
|
362
|
+
|
363
|
+
@intermediaries = scoped.query == intermediaries.query ? intermediaries : scoped
|
364
|
+
end
|
365
|
+
|
346
366
|
private
|
347
367
|
|
348
368
|
# TODO: document
|
@@ -363,9 +383,13 @@ module DataMapper
|
|
363
383
|
# TODO: document
|
364
384
|
# @api private
|
365
385
|
def _save(safe)
|
366
|
-
|
367
|
-
|
368
|
-
|
386
|
+
if @removed.any?
|
387
|
+
# delete only intermediaries linked to the removed targets
|
388
|
+
removed_intermediaries = intermediaries.all(via => @removed).each do |resource|
|
389
|
+
intermediaries.delete(resource)
|
390
|
+
end
|
391
|
+
|
392
|
+
return false unless removed_intermediaries.send(safe ? :destroy : :destroy!)
|
369
393
|
end
|
370
394
|
|
371
395
|
if via.respond_to?(:resource_for)
|
@@ -374,25 +398,13 @@ module DataMapper
|
|
374
398
|
else
|
375
399
|
if intermediary = create_intermediary(safe)
|
376
400
|
inverse = via.inverse
|
377
|
-
loaded_entries.
|
401
|
+
loaded_entries.each { |resource| inverse.set(resource, intermediary) }
|
378
402
|
end
|
379
403
|
|
380
404
|
super
|
381
405
|
end
|
382
406
|
end
|
383
407
|
|
384
|
-
# TODO: document
|
385
|
-
# @api private
|
386
|
-
def intermediaries(targets = self)
|
387
|
-
intermediaries = if through.loaded?(source)
|
388
|
-
through.get!(source)
|
389
|
-
else
|
390
|
-
through.set!(source, through.collection_for(source))
|
391
|
-
end
|
392
|
-
|
393
|
-
intermediaries.all(via => targets)
|
394
|
-
end
|
395
|
-
|
396
408
|
# TODO: document
|
397
409
|
# @api private
|
398
410
|
def create_intermediary(safe, attributes = {})
|
@@ -315,7 +315,7 @@ module DataMapper
|
|
315
315
|
assert_source_saved 'The source must be saved before saving the collection'
|
316
316
|
|
317
317
|
# update removed resources to not reference the source
|
318
|
-
@removed.all? { |resource| resource.send(safe ? :save : :save!) } && super
|
318
|
+
@removed.all? { |resource| resource.destroyed? || resource.send(safe ? :save : :save!) } && super
|
319
319
|
end
|
320
320
|
|
321
321
|
# TODO: document
|
data/lib/dm-core/resource.rb
CHANGED
@@ -118,6 +118,16 @@ module DataMapper
|
|
118
118
|
@saved == true
|
119
119
|
end
|
120
120
|
|
121
|
+
# Checks if this Resource instance is destroyed
|
122
|
+
#
|
123
|
+
# @return [Boolean]
|
124
|
+
# true if the resource has been destroyed
|
125
|
+
#
|
126
|
+
# @api public
|
127
|
+
def destroyed?
|
128
|
+
@destroyed == true
|
129
|
+
end
|
130
|
+
|
121
131
|
# Checks if the resource has no changes to save
|
122
132
|
#
|
123
133
|
# @return [Boolean]
|
@@ -364,13 +374,13 @@ module DataMapper
|
|
364
374
|
# @api public
|
365
375
|
def destroy!
|
366
376
|
if saved? && repository.delete(Collection.new(query, [ self ])) == 1
|
377
|
+
@destroyed = true
|
367
378
|
@collection.delete(self) if @collection
|
368
379
|
reset
|
369
380
|
freeze
|
370
|
-
true
|
371
|
-
else
|
372
|
-
false
|
373
381
|
end
|
382
|
+
|
383
|
+
destroyed?
|
374
384
|
end
|
375
385
|
|
376
386
|
# Compares another Resource for equality
|
data/lib/dm-core/version.rb
CHANGED
@@ -0,0 +1,359 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
|
2
|
+
|
3
|
+
describe DataMapper::Migrations do
|
4
|
+
def capture_log(mod)
|
5
|
+
original, mod.logger = mod.logger, DataObjects::Logger.new(@log = StringIO.new, :debug)
|
6
|
+
yield
|
7
|
+
ensure
|
8
|
+
@log.rewind
|
9
|
+
@output = @log.readlines.map do |line|
|
10
|
+
line.chomp.gsub(/\A.+?~ \(\d+\.?\d*\)\s+/, '')
|
11
|
+
end
|
12
|
+
|
13
|
+
mod.logger = original
|
14
|
+
end
|
15
|
+
|
16
|
+
supported_by :mysql do
|
17
|
+
before :all do
|
18
|
+
module ::Blog
|
19
|
+
class Article
|
20
|
+
include DataMapper::Resource
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@model = ::Blog::Article
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#auto_migrate' do
|
28
|
+
describe 'Integer property' do
|
29
|
+
[
|
30
|
+
[ 0, 1, 'TINYINT(1) UNSIGNED' ],
|
31
|
+
[ 0, 9, 'TINYINT(1) UNSIGNED' ],
|
32
|
+
[ 0, 10, 'TINYINT(2) UNSIGNED' ],
|
33
|
+
[ 0, 99, 'TINYINT(2) UNSIGNED' ],
|
34
|
+
[ 0, 100, 'TINYINT(3) UNSIGNED' ],
|
35
|
+
[ 0, 255, 'TINYINT(3) UNSIGNED' ],
|
36
|
+
[ 0, 256, 'SMALLINT(3) UNSIGNED' ],
|
37
|
+
[ 0, 999, 'SMALLINT(3) UNSIGNED' ],
|
38
|
+
[ 0, 1000, 'SMALLINT(4) UNSIGNED' ],
|
39
|
+
[ 0, 9999, 'SMALLINT(4) UNSIGNED' ],
|
40
|
+
[ 0, 10000, 'SMALLINT(5) UNSIGNED' ],
|
41
|
+
[ 0, 65535, 'SMALLINT(5) UNSIGNED' ],
|
42
|
+
[ 0, 65536, 'MEDIUMINT(5) UNSIGNED' ],
|
43
|
+
[ 0, 99999, 'MEDIUMINT(5) UNSIGNED' ],
|
44
|
+
[ 0, 100000, 'MEDIUMINT(6) UNSIGNED' ],
|
45
|
+
[ 0, 999999, 'MEDIUMINT(6) UNSIGNED' ],
|
46
|
+
[ 0, 1000000, 'MEDIUMINT(7) UNSIGNED' ],
|
47
|
+
[ 0, 9999999, 'MEDIUMINT(7) UNSIGNED' ],
|
48
|
+
[ 0, 10000000, 'MEDIUMINT(8) UNSIGNED' ],
|
49
|
+
[ 0, 16777215, 'MEDIUMINT(8) UNSIGNED' ],
|
50
|
+
[ 0, 16777216, 'INT(8) UNSIGNED' ],
|
51
|
+
[ 0, 99999999, 'INT(8) UNSIGNED' ],
|
52
|
+
[ 0, 100000000, 'INT(9) UNSIGNED' ],
|
53
|
+
[ 0, 999999999, 'INT(9) UNSIGNED' ],
|
54
|
+
[ 0, 1000000000, 'INT(10) UNSIGNED' ],
|
55
|
+
[ 0, 4294967295, 'INT(10) UNSIGNED' ],
|
56
|
+
[ 0, 4294967296, 'BIGINT(10) UNSIGNED' ],
|
57
|
+
[ 0, 9999999999, 'BIGINT(10) UNSIGNED' ],
|
58
|
+
[ 0, 10000000000, 'BIGINT(11) UNSIGNED' ],
|
59
|
+
[ 0, 99999999999, 'BIGINT(11) UNSIGNED' ],
|
60
|
+
[ 0, 100000000000, 'BIGINT(12) UNSIGNED' ],
|
61
|
+
[ 0, 999999999999, 'BIGINT(12) UNSIGNED' ],
|
62
|
+
[ 0, 1000000000000, 'BIGINT(13) UNSIGNED' ],
|
63
|
+
[ 0, 9999999999999, 'BIGINT(13) UNSIGNED' ],
|
64
|
+
[ 0, 10000000000000, 'BIGINT(14) UNSIGNED' ],
|
65
|
+
[ 0, 99999999999999, 'BIGINT(14) UNSIGNED' ],
|
66
|
+
[ 0, 100000000000000, 'BIGINT(15) UNSIGNED' ],
|
67
|
+
[ 0, 999999999999999, 'BIGINT(15) UNSIGNED' ],
|
68
|
+
[ 0, 1000000000000000, 'BIGINT(16) UNSIGNED' ],
|
69
|
+
[ 0, 9999999999999999, 'BIGINT(16) UNSIGNED' ],
|
70
|
+
[ 0, 10000000000000000, 'BIGINT(17) UNSIGNED' ],
|
71
|
+
[ 0, 99999999999999999, 'BIGINT(17) UNSIGNED' ],
|
72
|
+
[ 0, 100000000000000000, 'BIGINT(18) UNSIGNED' ],
|
73
|
+
[ 0, 999999999999999999, 'BIGINT(18) UNSIGNED' ],
|
74
|
+
[ 0, 1000000000000000000, 'BIGINT(19) UNSIGNED' ],
|
75
|
+
[ 0, 9999999999999999999, 'BIGINT(19) UNSIGNED' ],
|
76
|
+
[ 0, 10000000000000000000, 'BIGINT(20) UNSIGNED' ],
|
77
|
+
[ 0, 18446744073709551615, 'BIGINT(20) UNSIGNED' ],
|
78
|
+
|
79
|
+
[ -1, 0, 'TINYINT(2)' ],
|
80
|
+
[ -1, 9, 'TINYINT(2)' ],
|
81
|
+
[ -1, 10, 'TINYINT(2)' ],
|
82
|
+
[ -1, 99, 'TINYINT(2)' ],
|
83
|
+
[ -1, 100, 'TINYINT(3)' ],
|
84
|
+
[ -1, 127, 'TINYINT(3)' ],
|
85
|
+
[ -1, 128, 'SMALLINT(3)' ],
|
86
|
+
[ -1, 999, 'SMALLINT(3)' ],
|
87
|
+
[ -1, 1000, 'SMALLINT(4)' ],
|
88
|
+
[ -1, 9999, 'SMALLINT(4)' ],
|
89
|
+
[ -1, 10000, 'SMALLINT(5)' ],
|
90
|
+
[ -1, 32767, 'SMALLINT(5)' ],
|
91
|
+
[ -1, 32768, 'MEDIUMINT(5)' ],
|
92
|
+
[ -1, 99999, 'MEDIUMINT(5)' ],
|
93
|
+
[ -1, 100000, 'MEDIUMINT(6)' ],
|
94
|
+
[ -1, 999999, 'MEDIUMINT(6)' ],
|
95
|
+
[ -1, 1000000, 'MEDIUMINT(7)' ],
|
96
|
+
[ -1, 8388607, 'MEDIUMINT(7)' ],
|
97
|
+
[ -1, 8388608, 'INT(7)' ],
|
98
|
+
[ -1, 9999999, 'INT(7)' ],
|
99
|
+
[ -1, 10000000, 'INT(8)' ],
|
100
|
+
[ -1, 99999999, 'INT(8)' ],
|
101
|
+
[ -1, 100000000, 'INT(9)' ],
|
102
|
+
[ -1, 999999999, 'INT(9)' ],
|
103
|
+
[ -1, 1000000000, 'INT(10)' ],
|
104
|
+
[ -1, 2147483647, 'INT(10)' ],
|
105
|
+
[ -1, 2147483648, 'BIGINT(10)' ],
|
106
|
+
[ -1, 9999999999, 'BIGINT(10)' ],
|
107
|
+
[ -1, 10000000000, 'BIGINT(11)' ],
|
108
|
+
[ -1, 99999999999, 'BIGINT(11)' ],
|
109
|
+
[ -1, 100000000000, 'BIGINT(12)' ],
|
110
|
+
[ -1, 999999999999, 'BIGINT(12)' ],
|
111
|
+
[ -1, 1000000000000, 'BIGINT(13)' ],
|
112
|
+
[ -1, 9999999999999, 'BIGINT(13)' ],
|
113
|
+
[ -1, 10000000000000, 'BIGINT(14)' ],
|
114
|
+
[ -1, 99999999999999, 'BIGINT(14)' ],
|
115
|
+
[ -1, 100000000000000, 'BIGINT(15)' ],
|
116
|
+
[ -1, 999999999999999, 'BIGINT(15)' ],
|
117
|
+
[ -1, 1000000000000000, 'BIGINT(16)' ],
|
118
|
+
[ -1, 9999999999999999, 'BIGINT(16)' ],
|
119
|
+
[ -1, 10000000000000000, 'BIGINT(17)' ],
|
120
|
+
[ -1, 99999999999999999, 'BIGINT(17)' ],
|
121
|
+
[ -1, 100000000000000000, 'BIGINT(18)' ],
|
122
|
+
[ -1, 999999999999999999, 'BIGINT(18)' ],
|
123
|
+
[ -1, 1000000000000000000, 'BIGINT(19)' ],
|
124
|
+
[ -1, 9223372036854775807, 'BIGINT(19)' ],
|
125
|
+
|
126
|
+
[ -1, 0, 'TINYINT(2)' ],
|
127
|
+
[ -9, 0, 'TINYINT(2)' ],
|
128
|
+
[ -10, 0, 'TINYINT(3)' ],
|
129
|
+
[ -99, 0, 'TINYINT(3)' ],
|
130
|
+
[ -100, 0, 'TINYINT(4)' ],
|
131
|
+
[ -128, 0, 'TINYINT(4)' ],
|
132
|
+
[ -129, 0, 'SMALLINT(4)' ],
|
133
|
+
[ -999, 0, 'SMALLINT(4)' ],
|
134
|
+
[ -1000, 0, 'SMALLINT(5)' ],
|
135
|
+
[ -9999, 0, 'SMALLINT(5)' ],
|
136
|
+
[ -10000, 0, 'SMALLINT(6)' ],
|
137
|
+
[ -32768, 0, 'SMALLINT(6)' ],
|
138
|
+
[ -32769, 0, 'MEDIUMINT(6)' ],
|
139
|
+
[ -99999, 0, 'MEDIUMINT(6)' ],
|
140
|
+
[ -100000, 0, 'MEDIUMINT(7)' ],
|
141
|
+
[ -999999, 0, 'MEDIUMINT(7)' ],
|
142
|
+
[ -1000000, 0, 'MEDIUMINT(8)' ],
|
143
|
+
[ -8388608, 0, 'MEDIUMINT(8)' ],
|
144
|
+
[ -8388609, 0, 'INT(8)' ],
|
145
|
+
[ -9999999, 0, 'INT(8)' ],
|
146
|
+
[ -10000000, 0, 'INT(9)' ],
|
147
|
+
[ -99999999, 0, 'INT(9)' ],
|
148
|
+
[ -100000000, 0, 'INT(10)' ],
|
149
|
+
[ -999999999, 0, 'INT(10)' ],
|
150
|
+
[ -1000000000, 0, 'INT(11)' ],
|
151
|
+
[ -2147483648, 0, 'INT(11)' ],
|
152
|
+
[ -2147483649, 0, 'BIGINT(11)' ],
|
153
|
+
[ -9999999999, 0, 'BIGINT(11)' ],
|
154
|
+
[ -10000000000, 0, 'BIGINT(12)' ],
|
155
|
+
[ -99999999999, 0, 'BIGINT(12)' ],
|
156
|
+
[ -100000000000, 0, 'BIGINT(13)' ],
|
157
|
+
[ -999999999999, 0, 'BIGINT(13)' ],
|
158
|
+
[ -1000000000000, 0, 'BIGINT(14)' ],
|
159
|
+
[ -9999999999999, 0, 'BIGINT(14)' ],
|
160
|
+
[ -10000000000000, 0, 'BIGINT(15)' ],
|
161
|
+
[ -99999999999999, 0, 'BIGINT(15)' ],
|
162
|
+
[ -100000000000000, 0, 'BIGINT(16)' ],
|
163
|
+
[ -999999999999999, 0, 'BIGINT(16)' ],
|
164
|
+
[ -1000000000000000, 0, 'BIGINT(17)' ],
|
165
|
+
[ -9999999999999999, 0, 'BIGINT(17)' ],
|
166
|
+
[ -10000000000000000, 0, 'BIGINT(18)' ],
|
167
|
+
[ -99999999999999999, 0, 'BIGINT(18)' ],
|
168
|
+
[ -100000000000000000, 0, 'BIGINT(19)' ],
|
169
|
+
[ -999999999999999999, 0, 'BIGINT(19)' ],
|
170
|
+
[ -1000000000000000000, 0, 'BIGINT(20)' ],
|
171
|
+
[ -9223372036854775808, 0, 'BIGINT(20)' ],
|
172
|
+
|
173
|
+
[ nil, 2147483647, 'INT(10) UNSIGNED' ],
|
174
|
+
[ 0, nil, 'INT(10) UNSIGNED' ],
|
175
|
+
[ nil, nil, 'INTEGER' ],
|
176
|
+
].each do |min, max, statement|
|
177
|
+
options = { :key => true }
|
178
|
+
options[:min] = min if min
|
179
|
+
options[:max] = max if max
|
180
|
+
|
181
|
+
describe "with a min of #{min} and a max of #{max}" do
|
182
|
+
before :all do
|
183
|
+
@property = @model.property(:id, Integer, options)
|
184
|
+
|
185
|
+
@response = capture_log(DataObjects::Mysql) { @model.auto_migrate! }
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should return true' do
|
189
|
+
@response.should be_true
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should create a #{statement} column" do
|
193
|
+
@output.last.should =~ %r{\ACREATE TABLE `blog_articles` \(`id` #{Regexp.escape(statement)} NOT NULL, PRIMARY KEY\(`id`\)\) ENGINE = InnoDB CHARACTER SET [a-z\d]+ COLLATE (?:[a-z\d](?:_?[a-z\d]+)*)\z}
|
194
|
+
end
|
195
|
+
|
196
|
+
options.only(:min, :max).each do |key, value|
|
197
|
+
it "should allow the #{key} value #{value} to be stored" do
|
198
|
+
lambda {
|
199
|
+
resource = @model.create(@property => value)
|
200
|
+
@model.first(@property => value).should eql(resource)
|
201
|
+
}.should_not raise_error
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
describe 'Text property' do
|
209
|
+
before :all do
|
210
|
+
@model.property(:id, DataMapper::Types::Serial)
|
211
|
+
end
|
212
|
+
|
213
|
+
[
|
214
|
+
[ 0, 'TINYTEXT' ],
|
215
|
+
[ 1, 'TINYTEXT' ],
|
216
|
+
[ 255, 'TINYTEXT' ],
|
217
|
+
[ 256, 'TEXT' ],
|
218
|
+
[ 65535, 'TEXT' ],
|
219
|
+
[ 65536, 'MEDIUMTEXT' ],
|
220
|
+
[ 16777215, 'MEDIUMTEXT' ],
|
221
|
+
[ 16777216, 'LONGTEXT' ],
|
222
|
+
[ 4294967295, 'LONGTEXT' ],
|
223
|
+
|
224
|
+
[ nil, 'TEXT' ],
|
225
|
+
].each do |length, statement|
|
226
|
+
options = {}
|
227
|
+
options[:length] = length if length
|
228
|
+
|
229
|
+
describe "with a length of #{length}" do
|
230
|
+
before :all do
|
231
|
+
@property = @model.property(:body, DataMapper::Types::Text, options)
|
232
|
+
|
233
|
+
@response = capture_log(DataObjects::Mysql) { @model.auto_migrate! }
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should return true' do
|
237
|
+
@response.should be_true
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should create a #{statement} column" do
|
241
|
+
@output.last.should =~ %r{\ACREATE TABLE `blog_articles` \(`id` INT\(10\) UNSIGNED NOT NULL AUTO_INCREMENT, `body` #{Regexp.escape(statement)}, PRIMARY KEY\(`id`\)\) ENGINE = InnoDB CHARACTER SET [a-z\d]+ COLLATE (?:[a-z\d](?:_?[a-z\d]+)*)\z}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
supported_by :postgres do
|
250
|
+
before :all do
|
251
|
+
module ::Blog
|
252
|
+
class Article
|
253
|
+
include DataMapper::Resource
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
@model = ::Blog::Article
|
258
|
+
end
|
259
|
+
|
260
|
+
describe '#auto_migrate' do
|
261
|
+
describe 'Integer property' do
|
262
|
+
[
|
263
|
+
[ 0, 1, 'SMALLINT' ],
|
264
|
+
[ 0, 32767, 'SMALLINT' ],
|
265
|
+
[ 0, 32768, 'INTEGER' ],
|
266
|
+
[ 0, 2147483647, 'INTEGER' ],
|
267
|
+
[ 0, 2147483648, 'BIGINT' ],
|
268
|
+
[ 0, 9223372036854775807, 'BIGINT' ],
|
269
|
+
|
270
|
+
[ -1, 1, 'SMALLINT' ],
|
271
|
+
[ -1, 32767, 'SMALLINT' ],
|
272
|
+
[ -1, 32768, 'INTEGER' ],
|
273
|
+
[ -1, 2147483647, 'INTEGER' ],
|
274
|
+
[ -1, 2147483648, 'BIGINT' ],
|
275
|
+
[ -1, 9223372036854775807, 'BIGINT' ],
|
276
|
+
|
277
|
+
[ -1, 0, 'SMALLINT' ],
|
278
|
+
[ -32768, 0, 'SMALLINT' ],
|
279
|
+
[ -32769, 0, 'INTEGER' ],
|
280
|
+
[ -2147483648, 0, 'INTEGER' ],
|
281
|
+
[ -2147483649, 0, 'BIGINT' ],
|
282
|
+
[ -9223372036854775808, 0, 'BIGINT' ],
|
283
|
+
|
284
|
+
[ nil, 2147483647, 'INTEGER' ],
|
285
|
+
[ 0, nil, 'INTEGER' ],
|
286
|
+
[ nil, nil, 'INTEGER' ],
|
287
|
+
].each do |min, max, statement|
|
288
|
+
options = { :key => true }
|
289
|
+
options[:min] = min if min
|
290
|
+
options[:max] = max if max
|
291
|
+
|
292
|
+
describe "with a min of #{min} and a max of #{max}" do
|
293
|
+
before :all do
|
294
|
+
@property = @model.property(:id, Integer, options)
|
295
|
+
|
296
|
+
@response = capture_log(DataObjects::Postgres) { @model.auto_migrate! }
|
297
|
+
end
|
298
|
+
|
299
|
+
it 'should return true' do
|
300
|
+
@response.should be_true
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should create a #{statement} column" do
|
304
|
+
@output[-2].should == "CREATE TABLE \"blog_articles\" (\"id\" #{statement} NOT NULL, PRIMARY KEY(\"id\"))"
|
305
|
+
end
|
306
|
+
|
307
|
+
options.only(:min, :max).each do |key, value|
|
308
|
+
it "should allow the #{key} value #{value} to be stored" do
|
309
|
+
lambda {
|
310
|
+
resource = @model.create(@property => value)
|
311
|
+
@model.first(@property => value).should eql(resource)
|
312
|
+
}.should_not raise_error
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
describe 'Serial property' do
|
320
|
+
[
|
321
|
+
[ 1, 'SERIAL' ],
|
322
|
+
[ 2147483647, 'SERIAL' ],
|
323
|
+
[ 2147483648, 'BIGSERIAL' ],
|
324
|
+
[ 9223372036854775807, 'BIGSERIAL' ],
|
325
|
+
|
326
|
+
[ nil, 'SERIAL' ],
|
327
|
+
].each do |max, statement|
|
328
|
+
options = {}
|
329
|
+
options[:max] = max if max
|
330
|
+
|
331
|
+
describe "with a max of #{max}" do
|
332
|
+
before :all do
|
333
|
+
@property = @model.property(:id, DataMapper::Types::Serial, options)
|
334
|
+
|
335
|
+
@response = capture_log(DataObjects::Postgres) { @model.auto_migrate! }
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should return true' do
|
339
|
+
@response.should be_true
|
340
|
+
end
|
341
|
+
|
342
|
+
it "should create a #{statement} column" do
|
343
|
+
@output[-2].should == "CREATE TABLE \"blog_articles\" (\"id\" #{statement} NOT NULL, PRIMARY KEY(\"id\"))"
|
344
|
+
end
|
345
|
+
|
346
|
+
options.only(:min, :max).each do |key, value|
|
347
|
+
it "should allow the #{key} value #{value} to be stored" do
|
348
|
+
lambda {
|
349
|
+
resource = @model.create(@property => value)
|
350
|
+
@model.first(@property => value).should eql(resource)
|
351
|
+
}.should_not raise_error
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
end
|
359
|
+
end
|
@@ -237,8 +237,8 @@ share_examples_for 'A public Resource' do
|
|
237
237
|
@resource.should be_frozen
|
238
238
|
end
|
239
239
|
|
240
|
-
it
|
241
|
-
@resource.
|
240
|
+
it "should return true when calling #{method} on a destroyed resource" do
|
241
|
+
@resource.send(method).should be_true
|
242
242
|
end
|
243
243
|
|
244
244
|
it 'should remove object from persistent storage' do
|
data/tasks/hoe.rb
CHANGED
@@ -40,6 +40,6 @@ hoe = Hoe.spec(GEM_NAME) do
|
|
40
40
|
|
41
41
|
self.rubyforge_name = PROJECT_NAME
|
42
42
|
|
43
|
-
clean_globs |= %w[ {coverage,doc,log,tmp} **/*.{log,db} profile_results.* **/.DS_Store spec/db ]
|
44
|
-
extra_deps |= GEM_DEPENDENCIES
|
43
|
+
self.clean_globs |= %w[ {coverage,doc,log,tmp} **/*.{log,db} profile_results.* **/.DS_Store spec/db ]
|
44
|
+
self.extra_deps |= GEM_DEPENDENCIES
|
45
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datamapper-dm-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Kubb
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-09-21 00:00:00 -07: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.14
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: addressable
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: "2.
|
33
|
+
version: "2.1"
|
34
34
|
version:
|
35
35
|
description: Faster, Better, Simpler.
|
36
36
|
email:
|
@@ -56,6 +56,7 @@ files:
|
|
56
56
|
- Rakefile
|
57
57
|
- SPECS
|
58
58
|
- TODO
|
59
|
+
- deps.rip
|
59
60
|
- dm-core.gemspec
|
60
61
|
- lib/dm-core.rb
|
61
62
|
- lib/dm-core/adapters.rb
|
@@ -124,6 +125,7 @@ files:
|
|
124
125
|
- spec/public/associations/one_to_many_spec.rb
|
125
126
|
- spec/public/associations/one_to_one_spec.rb
|
126
127
|
- spec/public/collection_spec.rb
|
128
|
+
- spec/public/migrations_spec.rb
|
127
129
|
- spec/public/model/relationship_spec.rb
|
128
130
|
- spec/public/model_spec.rb
|
129
131
|
- spec/public/property_spec.rb
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- spec/semipublic/query/path_spec.rb
|
154
156
|
- spec/semipublic/query_spec.rb
|
155
157
|
- spec/semipublic/resource_spec.rb
|
158
|
+
- spec/semipublic/shared/condition_shared_spec.rb
|
156
159
|
- spec/semipublic/shared/resource_shared_spec.rb
|
157
160
|
- spec/spec.opts
|
158
161
|
- spec/spec_helper.rb
|