intermine 0.99.02 → 0.99.03

Sign up to get free protection for your applications and to get access to all the features.
@@ -580,8 +580,11 @@ module Metadata
580
580
  klass.class_eval do
581
581
  define_method(fd.name) do
582
582
  if instance_variable_get("@" + fd.name).nil?
583
- q = __cd__.select(fd.name + ".*").where(:id => objectId)
584
- instance_var = q.results.first[fd.name]
583
+ q = __cd__.select("id", fd.name + ".*").where(:id => objectId).outerjoin(fd.name)
584
+ instance_var = q.results.first.instance_variable_get('@' + fd.name)
585
+ if fd.is_a?(CollectionDescriptor) and instance_var.nil?
586
+ instance_var = []
587
+ end
585
588
  instance_variable_set("@" + fd.name, instance_var)
586
589
  end
587
590
  return instance_variable_get("@" + fd.name)
@@ -611,14 +614,16 @@ module Metadata
611
614
  type = fd.referencedType
612
615
  if fd.is_a?(CollectionDescriptor)
613
616
  instance_var = []
614
- val.each do |item|
615
- if item.is_a?(Hash)
616
- item = type.model.make_new(type.name, item)
617
- end
618
- if !item.is_a?(type)
619
- raise ArgumentError, "Arguments to #{fd.name} in #{@name} must be #{type.name}s"
617
+ if not val.nil?
618
+ val.each do |item|
619
+ if item.is_a?(Hash)
620
+ item = type.model.make_new(type.name, item)
621
+ end
622
+ if !item.is_a?(type)
623
+ raise ArgumentError, "Arguments to #{fd.name} in #{@name} must be #{type.name}s"
624
+ end
625
+ instance_var << item
620
626
  end
621
- instance_var << item
622
627
  end
623
628
  instance_variable_set("@" + fd.name, instance_var)
624
629
  else
@@ -16,5 +16,6 @@ module Intermine
16
16
  # - Added support for "json" format (performance) improvement
17
17
  # 0.99.01 - Added support for sort-orders on selected classes which are not in the view
18
18
  # 0.99.02 - Fixed bug with null values in new result rows (resulting commonly from outer joins)
19
- VERSION = "0.99.02"
19
+ # 0.99.03 - Fixed handling of null references and empty collections in lazy reference fetching.
20
+ VERSION = "0.99.03"
20
21
  end
data/test/live_test.rb CHANGED
@@ -76,10 +76,10 @@ class LiveDemoTest < Test::Unit::TestCase
76
76
  def testLazyCollectionFetching
77
77
  list = @service.list("My-Favourite-Employees")
78
78
  emps = list.map {|manager| manager.department.employees.map {|employee| employee.age} }
79
- exp = [[34, 36, 41, 55, 61, 61],
79
+ exp = [[41, 36, 55, 34, 61, 61],
80
80
  [44, 49, 62],
81
- [30, 37, 45, 46, 58, 64],
82
- [36, 37, 39, 49, 57, 59]]
81
+ [37, 45, 30, 64, 46, 58],
82
+ [37, 49, 39, 57, 36, 59]]
83
83
  assert_equal(exp, emps)
84
84
 
85
85
  sum = list.reduce(0) {|m, manager| m + manager.department.employees.reduce(0) {|n, emp| n + emp.age}}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intermine
3
3
  version: !ruby/object:Gem::Version
4
- hash: 407
4
+ hash: 405
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 99
9
- - 2
10
- version: 0.99.02
9
+ - 3
10
+ version: 0.99.03
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Kalderimis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-27 00:00:00 Z
18
+ date: 2012-01-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: json