dm-persevere-adapter 0.60.5 → 0.70.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.60.5
1
+ 0.70.0
@@ -19,7 +19,7 @@ module DataMapper
19
19
  def query
20
20
  @query
21
21
  end
22
-
22
+
23
23
  def set(source, target)
24
24
  assert_kind_of 'source', source, source_model
25
25
  assert_kind_of 'target', target, Array
@@ -14,21 +14,38 @@ module DataMapper
14
14
  relationship_schema = {}
15
15
 
16
16
  case self
17
- when DataMapper::Associations::OneToMany::Relationship, DataMapper::Associations::ManyToMany::Relationship
17
+ when DataMapper::Associations::ManyToMany::Relationship
18
+ # puts "-> M:M #{child.storage_name}"
18
19
  relationship_schema = { "type" => "array",
20
+ "dm_relation" => "many_to_many",
19
21
  "lazy" => true,
20
22
  "optional" => true,
21
23
  "items" => {"$ref" => "/Class/#{child.storage_name}"},
22
24
  "minItems" => self.min
23
25
  }
24
-
25
-
26
26
  relationship_schema["maxItems"] = self.max if self.max != Infinity
27
-
27
+ when DataMapper::Associations::OneToMany::Relationship
28
+ # puts "-> 1:M #{child.storage_name}"
29
+ relationship_schema = { "type" => "array",
30
+ "dm_relation" => "has_n",
31
+ "lazy" => true,
32
+ "optional" => true,
33
+ "items" => {"$ref" => "/Class/#{child.storage_name}"},
34
+ "minItems" => self.min
35
+ }
36
+ relationship_schema["maxItems"] = self.max if self.max != Infinity
37
+ when DataMapper::Associations::ManyToOne::Relationship
38
+ # puts "-> M:1 #{parent.storage_name}"
39
+ relationship_schema = { "type" => { "$ref" => "/Class/#{parent.storage_name}" },
40
+ "dm_relation" => "belongs_to",
41
+ "lazy" => true,
42
+ "optional" => true }
28
43
  when DataMapper::Associations::OneToOne::Relationship
29
- relationship_schema = { "type" => { "$ref" => "/Class/#{child.storage_name}" }, "lazy" => true, "optional" => true }
30
- when DataMapper::Associations::ManyToOne::Relationship
31
- relationship_schema = { "type" => { "$ref" => "/Class/#{parent.storage_name}" }, "lazy" => true, "optional" => true }
44
+ # puts "-> 1:1 #{child.storage_name}"
45
+ relationship_schema = { "type" => { "$ref" => "/Class/#{child.storage_name}" },
46
+ "dm_relation" => "has_n",
47
+ "lazy" => true,
48
+ "optional" => true }
32
49
  end
33
50
 
34
51
  relationship_schema.merge!("prefix" => @prefix ) unless @prefix.nil?
@@ -361,6 +361,8 @@ module DataMapper
361
361
  # @api semipublic
362
362
 
363
363
  def read_one(query)
364
+ # TODO: This would be more efficient if it modified the query to limit = 1,
365
+ # rather than getting all of them and only returning the first one.
364
366
  results = read_many(query)
365
367
  results[0,1]
366
368
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 60
8
- - 5
9
- version: 0.60.5
7
+ - 70
8
+ - 0
9
+ version: 0.70.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan R. Judson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-24 00:00:00 -06:00
18
+ date: 2010-06-25 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency