marty 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f0f6b19ce2c15e5918e27386f89e6bf83bc3738
4
- data.tar.gz: 3da45154c7ad5476a9748af3b11ac158bbdf12d6
3
+ metadata.gz: 77e6182b8e9feb509b401e87c0fd8233bfa6777a
4
+ data.tar.gz: 78707cf573b3c33d872b0346a4751c38f26f14d3
5
5
  SHA512:
6
- metadata.gz: 44bd77724a580c2bd0ea7cbf22db382135dfe8bd4f853a9ca9c5299edfd25daa2f1a79421f4b85accd8364711a4183ccaa844a6c99be710d14b28f5a2cc16a60
7
- data.tar.gz: 28623145da5a246f826bd5879e2b1c5dab4a39fb73af9e45ce65e48c448dadb8bdb97746b1aacfac38672ef4ef0ef6c98a755238ef3c438730b3dbdb3745afea
6
+ metadata.gz: 7ca495f675cbe04547f2d885a6661f1da7cc6793bf7c9fc9a55759e24b4877df7878a032347dd3c0d81b5c5122b8cc504d47ed0560cdd2bd73ea8e0a51ece0d4
7
+ data.tar.gz: 1898fd8cd7daf7d3e7d2d0f8ed8560a45c7874339b2617291f782d005910a0d6ab8c3b68d5630c32521a597bfc27883737c4b28552a08745675742f144e5367e
@@ -50,5 +50,4 @@ class Marty::Grid < ::Netzke::Grid::Base
50
50
  r.order("#{json_col} ->> '#{field}' " + dir.to_s)
51
51
  end
52
52
  end
53
-
54
53
  end
@@ -13,7 +13,6 @@ class Marty::DataGrid < Marty::Base
13
13
  }
14
14
 
15
15
  ARRSEP = '|'
16
- NULLABLE_TYPES = Set["string", "integer"]
17
16
 
18
17
  class DataGridValidator < ActiveModel::Validator
19
18
  def validate(dg)
@@ -195,9 +194,7 @@ class Marty::DataGrid < Marty::Base
195
194
  where(q, v).uniq.pluck(:index)
196
195
  end
197
196
 
198
- if v.nil? || (ixa.empty? && NULLABLE_TYPES.member?(type))
199
- # NULLABLE_TYPES fields allow NULL key wildcards. If no match
200
- # for key was found, try NULL.
197
+ if v.nil? || ixa.empty?
201
198
  ixa = ix_class.
202
199
  where(data_grid_id: group_id,
203
200
  created_dt: created_dt,
@@ -1,4 +1,4 @@
1
1
  class Marty::GridIndexBoolean < Marty::Base
2
2
  validates_presence_of :created_dt, :data_grid_id, :attr, :index
3
- validates_inclusion_of :key, in: [true, false]
3
+ validates_inclusion_of :key, in: [true, false, nil]
4
4
  end
@@ -1,3 +1,3 @@
1
1
  class Marty::GridIndexInt4range < Marty::Base
2
- validates_presence_of :created_dt, :data_grid_id, :attr, :key, :index
2
+ validates_presence_of :created_dt, :data_grid_id, :attr, :index
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Marty::GridIndexInteger < Marty::Base
2
- validates_presence_of :created_dt, :data_grid_id, :attr, :key, :index
2
+ validates_presence_of :created_dt, :data_grid_id, :attr, :index
3
3
  end
@@ -1,3 +1,3 @@
1
1
  class Marty::GridIndexNumrange < Marty::Base
2
- validates_presence_of :created_dt, :data_grid_id, :attr, :key, :index
2
+ validates_presence_of :created_dt, :data_grid_id, :attr, :index
3
3
  end
@@ -0,0 +1,10 @@
1
+ class MakeGridIndexesNullable < ActiveRecord::Migration
2
+ include Marty::Migrations
3
+
4
+ def change
5
+ change_column_null(:marty_grid_index_numranges, :key, true)
6
+ change_column_null(:marty_grid_index_int4ranges, :key, true)
7
+ change_column_null(:marty_grid_index_integers, :key, true)
8
+ change_column_null(:marty_grid_index_booleans, :key, true)
9
+ end
10
+ end
data/lib/marty/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -115,6 +115,18 @@ ltv\tnumrange\th
115
115
 
116
116
  >110\t>120
117
117
  1.1\t1.1
118
+ EOS
119
+
120
+ Gf = <<EOS
121
+ lenient string
122
+ b\tboolean\tv
123
+ i\tinteger\tv
124
+ i4\tint4range\tv
125
+ n\tnumrange\tv
126
+
127
+ true\t1\t<10\t<10.0\tY
128
+ \t2\t\t\tM
129
+ false\t\t>10\t\tN
118
130
  EOS
119
131
 
120
132
  before(:each) do
@@ -177,20 +189,6 @@ EOS
177
189
  }.to raise_error(ActiveRecord::RecordInvalid)
178
190
  end
179
191
 
180
- it "NULL keys are only allowed on string fields" do
181
- g_bad = G2.sub(/1\|2/, "")
182
-
183
- expect {
184
- dg_from_import("G2", g_bad)
185
- }.to raise_error(ActiveRecord::RecordInvalid)
186
-
187
- g_bad = G2.sub(/<=80/, "")
188
-
189
- expect {
190
- dg_from_import("G2", g_bad)
191
- }.to raise_error(ActiveRecord::RecordInvalid)
192
- end
193
-
194
192
  it "Unknown keys for typed grids should raise error" do
195
193
  g_bad = G8.sub(/G3/, "XXXXX")
196
194
 
@@ -220,17 +218,63 @@ EOS
220
218
  end
221
219
  end
222
220
 
223
- describe "lookup" do
221
+ describe "lookups for infinity" do
222
+ let(:pt) { 'infinity'}
223
+
224
224
  before(:each) do
225
225
  ["G1", "G2", "G3", "G4", "G5", "G6", "G7", "G8", "Ga", "Gb",
226
- "Gc", "Gd", "Ge"].each { |g|
226
+ "Gc", "Gd", "Ge", "Gf"].each { |g|
227
227
  dg_from_import(g, "Marty::DataGridSpec::#{g}".constantize)
228
228
  }
229
229
  end
230
230
 
231
- it "should handle non-distinct lookups" do
232
- pt = 'infinity'
231
+ context "should handle NULL key values" do
232
+ let(:dg) { Marty::DataGrid.lookup(pt, "Gf") }
233
233
 
234
+ it 'true returns Y' do
235
+ res = Marty::DataGrid.
236
+ lookup_grid(pt, dg, {"b"=>true}, true)
237
+ expect(res).to eq('Y')
238
+ end
239
+
240
+ it '13 returns N' do
241
+ res = Marty::DataGrid.
242
+ lookup_grid(pt, dg, {"i"=>13}, true)
243
+ expect(res).to eq('N')
244
+ end
245
+
246
+ it '13 & numrange 0 returns nil' do
247
+ res = Marty::DataGrid.
248
+ lookup_grid(pt, dg, {"i"=>13, "n"=>0}, true)
249
+ expect(res).to be_nil
250
+ end
251
+
252
+ it '13 & int4range 15 returns N' do
253
+ res = Marty::DataGrid.
254
+ lookup_grid(pt, dg, {"i"=>13, "i4"=>15}, true)
255
+ expect(res).to eq('N')
256
+ end
257
+
258
+ it '13 & int4range 1 returns nil' do
259
+ res = Marty::DataGrid.
260
+ lookup_grid(pt, dg, {"i"=>13, "i4"=>1}, true)
261
+ expect(res).to be_nil
262
+ end
263
+
264
+ it 'false, 3, numrange 15 returns N' do
265
+ res = Marty::DataGrid.
266
+ lookup_grid(pt, dg, {"b"=>false, "i"=>3, "n"=>15}, true)
267
+ expect(res).to eq('N')
268
+ end
269
+
270
+ it '13, numrange 15 returns N' do
271
+ res = Marty::DataGrid.
272
+ lookup_grid(pt, dg, {"i"=>13, "n"=>15}, true)
273
+ expect(res).to eq('N')
274
+ end
275
+ end
276
+
277
+ it "should handle non-distinct lookups" do
234
278
  dg = Marty::DataGrid.lookup(pt, "Ge")
235
279
  res = Marty::DataGrid.lookup_grid(pt, dg, {"ltv"=>500}, false)
236
280
 
@@ -475,7 +519,6 @@ EOS
475
519
  end
476
520
 
477
521
  it "should return grid data and metadata simple" do
478
- pt = 'infinity'
479
522
  expected_data = [[1.1, 2.2, 3.3], [4.4, 5.5, 6.6], [1.2, 2.3, 3.4],
480
523
  [4.5, 5.6, 6.7]]
481
524
  expected_metadata = [{"dir"=>"v",
@@ -502,7 +545,6 @@ EOS
502
545
  end
503
546
 
504
547
  it "should return grid data and metadata multi (following)" do
505
- pt = 'infinity'
506
548
  expected_data = [[1.1, 2.2, 3.3],[4.4, 5.5, 6.6],[1.2, 2.3, 3.4],
507
549
  [4.5, 5.6, nil],[11.0, 22.0, 33.0]]
508
550
  expected_metadata = [{"dir"=>"v",
@@ -527,7 +569,6 @@ EOS
527
569
  end
528
570
 
529
571
  it "should return grid data and metadata multi (not following)" do
530
- pt = 'infinity'
531
572
  expected_data = [["G1"], ["G2"], ["G3"]]
532
573
  expected_metadata = [{"dir"=>"v",
533
574
  "attr"=>"ltv",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arman Bostani
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2016-06-16 00:00:00.000000000 Z
17
+ date: 2016-06-20 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg
@@ -430,6 +430,7 @@ files:
430
430
  - db/migrate/103_create_marty_grid_index_integers.rb
431
431
  - db/migrate/104_create_marty_grid_index_strings.rb
432
432
  - db/migrate/105_create_marty_grid_index_booleans.rb
433
+ - db/migrate/106_make_grid_indexes_nullable.rb
433
434
  - db/seeds.rb
434
435
  - gemini_deprecations.md
435
436
  - lib/marty.rb