sequel_core 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- === HEAD
1
+ === 1.5.1 (2008-04-30)
2
+
3
+ * Have Dataset#graph give a nil value instead of a hash with all nil values if no matching rows exist in the graphed table (jeremyevans)
4
+
5
+ === 1.5.0 (2008-04-29)
2
6
 
3
7
  * Set a timeout in the Sqlite adapter, default to 5 seconds (hrvoje.marjanovic) (#218)
4
8
 
data/Rakefile CHANGED
@@ -9,15 +9,13 @@ include FileUtils
9
9
  # Configuration
10
10
  ##############################################################################
11
11
  NAME = "sequel_core"
12
- VERS = "1.5.0"
12
+ VERS = "1.5.1"
13
13
  CLEAN.include ["**/.*.sw?", "pkg/*", ".config", "doc/*", "coverage/*"]
14
14
  RDOC_OPTS = ["--quiet", "--line-numbers", "--inline-source"]
15
15
 
16
16
  ##############################################################################
17
17
  # RDoc
18
18
  ##############################################################################
19
- task :doc => [:rdoc]
20
-
21
19
  Rake::RDocTask.new do |rdoc|
22
20
  rdoc.rdoc_dir = "doc/rdoc"
23
21
  rdoc.options += RDOC_OPTS
@@ -71,16 +69,19 @@ end
71
69
  ##############################################################################
72
70
  # installation & removal
73
71
  ##############################################################################
72
+ desc "Install sequel_core gem"
74
73
  task :install do
75
74
  sh %{rake package}
76
75
  sh %{sudo gem install pkg/#{NAME}-#{VERS}}
77
76
  end
78
77
 
78
+ desc "Install sequel_core gem without docs"
79
79
  task :install_no_docs do
80
80
  sh %{rake package}
81
81
  sh %{sudo gem install pkg/#{NAME}-#{VERS} --no-rdoc --no-ri}
82
82
  end
83
83
 
84
+ desc "Uninstall sequel_core gem"
84
85
  task :uninstall => [:clean] do
85
86
  sh %{sudo gem uninstall #{NAME}}
86
87
  end
@@ -88,6 +89,7 @@ end
88
89
  ##############################################################################
89
90
  # gem and rdoc release
90
91
  ##############################################################################
92
+ desc "Upload sequel_core gem to rubyforge"
91
93
  task :release => [:package] do
92
94
  sh %{rubyforge login}
93
95
  sh %{rubyforge add_release sequel #{NAME} #{VERS} pkg/#{NAME}-#{VERS}.tgz}
@@ -20,6 +20,14 @@ module Sequel
20
20
  # any row_proc or transform attributes of the current dataset and the datasets
21
21
  # you use with graph.
22
22
  #
23
+ # If you are graphing a table and all columns for that table are nil, this
24
+ # indicates that no matching rows existed in the table, so graph will return nil
25
+ # instead of a hash with all nil values:
26
+ #
27
+ # # If the artist doesn't have any albums
28
+ # DB[:artists].graph(:albums, :artist_id=>:id).first
29
+ # => {:artists=>{:id=>artists.id, :name=>artists.name}, :albums=>nil}
30
+ #
23
31
  # Arguments:
24
32
  # * dataset - Can be a symbol (specifying a table), another dataset,
25
33
  # or an object that responds to .dataset and yields a symbol or a dataset
@@ -186,9 +194,13 @@ module Sequel
186
194
  # row_proc if applicable
187
195
  datasets.each do |ta,ds,tr,rp|
188
196
  g = graph[ta]
189
- g = ds.transform_load(g) if tr
190
- g = rp[g] if rp
191
- graph[ta] = g
197
+ graph[ta] = if g.values.any?
198
+ g = ds.transform_load(g) if tr
199
+ g = rp[g] if rp
200
+ g
201
+ else
202
+ nil
203
+ end
192
204
  end
193
205
 
194
206
  yield graph
@@ -152,6 +152,30 @@ describe Sequel::Dataset, " graphing" do
152
152
  results.first.should == {:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graph=>{:id=>8, :x=>9, :y=>10, :graph_id=>11}}
153
153
  end
154
154
 
155
+ it "#graph_each should give a nil value instead of a hash when all values for a table are nil" do
156
+ ds = @ds1.graph(@ds2, :x=>:id)
157
+ def ds.fetch_rows(sql, &block)
158
+ yield({:id=>1,:x=>2,:y=>3,:lines_id=>nil,:lines_x=>nil,:lines_y=>nil,:graph_id=>nil})
159
+ end
160
+ results = ds.all
161
+ results.length.should == 1
162
+ results.first.should == {:points=>{:id=>1, :x=>2, :y=>3}, :lines=>nil}
163
+
164
+ ds = @ds1.graph(@ds2, :x=>:id).graph(@ds3, :id=>:graph_id)
165
+ def ds.fetch_rows(sql, &block)
166
+ yield({:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>nil, :name=>nil, :graphs_x=>nil, :graphs_y=>nil, :graphs_lines_x=>nil})
167
+ yield({:id=>2,:x=>4,:y=>5,:lines_id=>nil,:lines_x=>nil,:lines_y=>nil,:graph_id=>nil, :graphs_id=>nil, :name=>nil, :graphs_x=>nil, :graphs_y=>nil, :graphs_lines_x=>nil})
168
+ yield({:id=>3,:x=>5,:y=>6,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>7, :name=>8, :graphs_x=>9, :graphs_y=>10, :graphs_lines_x=>11})
169
+ yield({:id=>3,:x=>5,:y=>6,:lines_id=>7,:lines_x=>5,:lines_y=>8,:graph_id=>9, :graphs_id=>9, :name=>10, :graphs_x=>10, :graphs_y=>11, :graphs_lines_x=>12})
170
+ end
171
+ results = ds.all
172
+ results.length.should == 4
173
+ results[0].should == {:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>nil}
174
+ results[1].should == {:points=>{:id=>2, :x=>4, :y=>5}, :lines=>nil, :graphs=>nil}
175
+ results[2].should == {:points=>{:id=>3, :x=>5, :y=>6}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>{:id=>7, :name=>8, :x=>9, :y=>10, :lines_x=>11}}
176
+ results[3].should == {:points=>{:id=>3, :x=>5, :y=>6}, :lines=>{:id=>7, :x=>5, :y=>8, :graph_id=>9}, :graphs=>{:id=>9, :name=>10, :x=>10, :y=>11, :lines_x=>12}}
177
+ end
178
+
155
179
  it "#graph_each should not included tables graphed with the :select option in the result set" do
156
180
  ds = @ds1.graph(:lines, {:x=>:id}, :select=>false).graph(:graphs, :id=>:graph_id)
157
181
  def ds.fetch_rows(sql, &block)
@@ -177,7 +201,7 @@ describe Sequel::Dataset, " graphing" do
177
201
  end
178
202
  results = ds.all
179
203
  results.length.should == 1
180
- results.first.should == {:points=>{:x=>2}, :lines=>{}}
204
+ results.first.should == {:points=>{:x=>2}, :lines=>nil}
181
205
  end
182
206
 
183
207
  it "#graph_each should run the row_proc and transform for graphed datasets" do
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: sequel_core
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.5.0
7
- date: 2008-04-29 00:00:00 -07:00
6
+ version: 1.5.1
7
+ date: 2008-04-30 00:00:00 -07:00
8
8
  summary: "The Database Toolkit for Ruby: Core Library and Adapters"
9
9
  require_paths:
10
10
  - lib