dm-persevere-adapter 0.41.0 → 0.42.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.41.0
1
+ 0.42.0
@@ -387,11 +387,11 @@ module DataMapper
387
387
 
388
388
  # This won't work if the RegExp is nested more then 1 layer deep.
389
389
  if query.conditions.class == DataMapper::Query::Conditions::AndOperation
390
- regexp_conds = query.conditions.operands.select{ |obj| obj.is_a?(DataMapper::Query::Conditions::RegexpComparison) ||
390
+ regexp_conds = query.conditions.operands.select{ |obj| obj.is_a?(DataMapper::Query::Conditions::RegexpComparison) ||
391
391
  (obj.is_a?(DataMapper::Query::Conditions::NotOperation) && obj.operand.is_a?(DataMapper::Query::Conditions::RegexpComparison))}
392
- regexp_conds.each{|cond| resources = resources.select{|resource| cond.matches?(resource)} }
392
+ regexp_conds.each{|cond| resources = resources.select{|resource| cond.matches?(resource)} }
393
393
 
394
- end
394
+ end
395
395
  # query.match_records(resources)
396
396
  resources
397
397
  end
@@ -706,7 +706,11 @@ module DataMapper
706
706
  "[=#{field.target.name}]"
707
707
  end
708
708
  else
709
- fields << "#{field.name}:#{field.name}"
709
+ if field.name.to_s.match(/\d/) != nil
710
+ fields << "'#{field.name}':'#{field.name}'"
711
+ else
712
+ fields << "#{field.name}:#{field.name}"
713
+ end
710
714
  end
711
715
  end
712
716
 
@@ -38,6 +38,15 @@ describe DataMapper::Adapters::PersevereAdapter do
38
38
  property :name, String
39
39
  end
40
40
 
41
+ class ::Mukatron
42
+ include DataMapper::Resource
43
+
44
+ property :id, Serial
45
+ property :street1, String
46
+ property :b8te, String
47
+ property :name, String
48
+ end
49
+
41
50
  @test_schema_hash = {
42
51
  'id' => 'Vanilla',
43
52
  'properties' => {
@@ -221,6 +230,7 @@ describe DataMapper::Adapters::PersevereAdapter do
221
230
  describe 'finding models' do
222
231
  before(:each) do
223
232
  Bozon.auto_migrate!
233
+ Mukatron.auto_migrate!
224
234
  end
225
235
 
226
236
  it "should find simple strings" do
@@ -243,8 +253,30 @@ describe DataMapper::Adapters::PersevereAdapter do
243
253
  Bozon.all(:created_at => time).length.should eql(1)
244
254
  end
245
255
 
256
+ it "should be able to pull one field" do
257
+ Bozon.create(:title => 'Story')
258
+ Bozon.create(:title => 'Tail')
259
+ Bozon.all(:fields => [:title]).length.should == 2
260
+ end
261
+
262
+ it "should retrieve properties that end in a number" do
263
+ Mukatron.create(:street1 => "11th", :b8te => 'true', :name => 'Porky')
264
+ Mukatron.create(:street1 => "12th", :b8te => 'false', :name => 'Porky')
265
+ Mukatron.all.length.should == 2
266
+ Mukatron.all(:fields => [:id,:street1]).length.should == 2
267
+ end
268
+ require 'ruby-debug'
269
+ it "should retrieve properties that have a number in the middle" do
270
+ Mukatron.create(:street1 => "11th", :b8te => 'true', :name => 'Porky')
271
+ Mukatron.create(:street1 => "12th", :b8te => 'false', :name => 'Porky')
272
+ # /mukatron/[/id][={'b8te':'b8te'}]
273
+ debugger
274
+ Mukatron.all(:fields => [:b8te]).length.should == 2
275
+ end
276
+
246
277
  after(:all) do
247
278
  Bozon.auto_migrate_down!
279
+ Mukatron.auto_migrate_down!
248
280
  end
249
281
  end
250
282
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 41
7
+ - 42
8
8
  - 0
9
- version: 0.41.0
9
+ version: 0.42.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ivan R. Judson