dm-aggregates 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
@@ -52,12 +52,10 @@ module DataMapper
|
|
52
52
|
case property
|
53
53
|
when Query::Operator
|
54
54
|
aggregate_field_statement(repository, property.operator, property.target, qualify)
|
55
|
-
when Property
|
55
|
+
when Property, Query::Path
|
56
56
|
original_property_to_column_name(repository, property, qualify)
|
57
|
-
when Query::Path
|
58
|
-
original_property_to_column_name(repository, property, qualify)
|
59
57
|
else
|
60
|
-
raise ArgumentError, "+property+ must be a DataMapper::Query::Operator or a
|
58
|
+
raise ArgumentError, "+property+ must be a DataMapper::Query::Operator, a DataMapper::Property or a Query::Path, but was a #{property.class} (#{property.inspect})"
|
61
59
|
end
|
62
60
|
end
|
63
61
|
|
@@ -160,7 +160,8 @@ module DataMapper
|
|
160
160
|
query = scoped_query(query)
|
161
161
|
|
162
162
|
if query.fields.any? { |p| p.kind_of?(Property) }
|
163
|
-
|
163
|
+
# explicitly specify the fields to circumvent a bug in Query#update
|
164
|
+
query.repository.aggregate(query.update(:fields => query.fields, :unique => true))
|
164
165
|
else
|
165
166
|
query.repository.aggregate(query).first # only return one row
|
166
167
|
end
|
@@ -5,12 +5,12 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
5
5
|
describe 'DataMapper::Resource' do
|
6
6
|
before :all do
|
7
7
|
# A simplistic example, using with an Integer property
|
8
|
-
|
9
|
-
|
8
|
+
class Knight
|
9
|
+
include DataMapper::Resource
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
property :id, Serial
|
12
|
+
property :name, String
|
13
|
+
end
|
14
14
|
|
15
15
|
class Dragon
|
16
16
|
include DataMapper::Resource
|
@@ -23,10 +23,9 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
23
23
|
property :birth_on, Date
|
24
24
|
property :birth_time, Time
|
25
25
|
|
26
|
-
|
26
|
+
belongs_to :knight
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
29
|
# A more complex example, with BigDecimal and Float properties
|
31
30
|
# Statistics taken from CIA World Factbook:
|
32
31
|
# https://www.cia.gov/library/publications/the-world-factbook/
|
@@ -47,8 +46,8 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
47
46
|
@birth_on = Date.parse(@birth_at.to_s)
|
48
47
|
@birth_time = Time.parse(@birth_at.to_s)
|
49
48
|
|
50
|
-
|
51
|
-
|
49
|
+
@chuck = Knight.create(:name => 'Chuck')
|
50
|
+
@larry = Knight.create(:name => 'Larry')
|
52
51
|
|
53
52
|
Dragon.create(:name => 'George', :is_fire_breathing => false, :toes_on_claw => 3, :birth_at => @birth_at, :birth_on => @birth_on, :birth_time => @birth_time, :knight => @chuck )
|
54
53
|
Dragon.create(:name => 'Puff', :is_fire_breathing => true, :toes_on_claw => 4, :birth_at => @birth_at, :birth_on => @birth_on, :birth_time => @birth_time, :knight => @larry )
|
@@ -320,12 +319,12 @@ if HAS_SQLITE3 || HAS_MYSQL || HAS_POSTGRES
|
|
320
319
|
end
|
321
320
|
end
|
322
321
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
322
|
+
describe "query path issue" do
|
323
|
+
it "should not break when a query path is specified" do
|
324
|
+
dragon = Dragon.first(Dragon.knight.name => 'Chuck')
|
325
|
+
dragon.name.should == 'George'
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
330
329
|
end
|
331
330
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,7 +8,7 @@ def load_driver(name, default_uri)
|
|
8
8
|
lib = "do_#{name}"
|
9
9
|
|
10
10
|
begin
|
11
|
-
gem lib, '
|
11
|
+
gem lib, '~>0.9.7'
|
12
12
|
require lib
|
13
13
|
DataMapper.setup(name, ENV["#{name.to_s.upcase}_SPEC_URI"] || default_uri)
|
14
14
|
DataMapper::Repository.adapters[:default] = DataMapper::Repository.adapters[name]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-aggregates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foy Savas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-18 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.7
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.8.2
|
34
34
|
version:
|
35
35
|
description: DataMapper plugin providing support for aggregates, functions on collections and datasets
|
36
36
|
email:
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements: []
|
85
85
|
|
86
86
|
rubyforge_project: datamapper
|
87
|
-
rubygems_version: 1.
|
87
|
+
rubygems_version: 1.3.1
|
88
88
|
signing_key:
|
89
89
|
specification_version: 2
|
90
90
|
summary: DataMapper plugin providing support for aggregates, functions on collections and datasets
|