active_force 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/active_force/active_query.rb +0 -15
- data/lib/active_force/sobject.rb +1 -2
- data/lib/active_force/version.rb +1 -1
- data/spec/active_force/sobject_spec.rb +0 -65
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c325fe186d67cce9500a1df17360184bd97c2fa26fed2819b327f3ea8331df7c
|
4
|
+
data.tar.gz: 482d5c2fabed72c3d12b646037dad7900f26e17260000a65e171d42ab41ce394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a36678b1ba07b3e89b1a755e7526facd18cdef04cdfcb9dd1b08224f42bbcc779959c26e869a3ead38e5add649d710e4afc4f0c1f88cdbcd73287360da3f7a
|
7
|
+
data.tar.gz: 13724331bdafe67729dafd0ca31a863657e125c8bb458fb8a0316aa5a2fba9f466c0e3ff52bc6fbc80a9190639636e726ac8c9940cc92836260b774cc7024ec5
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
3
|
## Not released
|
4
|
+
|
5
|
+
## 0.15.1
|
6
|
+
|
7
|
+
- Revert new `pluck` implementation due to compatibility issues (https://github.com/Beyond-Finance/active_force/pull/60)
|
8
|
+
|
4
9
|
## 0.15.0
|
10
|
+
|
5
11
|
- Fix model defaults so data is persisted in Salesforce (https://github.com/Beyond-Finance/active_force/pull/55)
|
6
12
|
- Add `pluck` query method (https://github.com/Beyond-Finance/active_force/pull/51)
|
7
13
|
- Add `#order` method to active query that accepts arguments in several formats ( symbol, string that has raw soql) (https://github.com/Beyond-Finance/active_force/pull/58)
|
8
14
|
|
9
|
-
|
10
15
|
## 0.14.0
|
11
16
|
|
12
17
|
- Add `scoped_as` option to `has_one` association (https://github.com/Beyond-Finance/active_force/pull/50)
|
@@ -51,15 +51,6 @@ module ActiveForce
|
|
51
51
|
sfdc_client.query(to_s).first.expr0
|
52
52
|
end
|
53
53
|
|
54
|
-
def pluck(*fields)
|
55
|
-
fields = mappings.keys if fields.blank?
|
56
|
-
|
57
|
-
sfdc_client.query(select(*fields).to_s).map do |record|
|
58
|
-
values = fields.map { |field| cast_value(field, record) }
|
59
|
-
values.length == 1 ? values.first : values
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
54
|
def limit limit
|
64
55
|
super
|
65
56
|
limit == 1 ? to_a.first : self
|
@@ -217,12 +208,6 @@ module ActiveForce
|
|
217
208
|
sfdc_client.query(self.to_s)
|
218
209
|
end
|
219
210
|
|
220
|
-
def cast_value(field, object)
|
221
|
-
attribute_type = sobject.attribute_types[field.to_s]
|
222
|
-
value = object[mappings[field]]
|
223
|
-
attribute_type&.cast(value) || value
|
224
|
-
end
|
225
|
-
|
226
211
|
def clone_self_and_clear_cache
|
227
212
|
new_query = self.clone
|
228
213
|
new_query.instance_variable_set(:@decorated_records, nil)
|
data/lib/active_force/sobject.rb
CHANGED
@@ -29,8 +29,7 @@ module ActiveForce
|
|
29
29
|
|
30
30
|
class << self
|
31
31
|
extend Forwardable
|
32
|
-
def_delegators :query, :not, :or, :where, :first, :last, :all, :find, :find!, :find_by, :find_by!, :sum, :count,
|
33
|
-
:includes, :limit, :order, :select, :none, :pluck
|
32
|
+
def_delegators :query, :not, :or, :where, :first, :last, :all, :find, :find!, :find_by, :find_by!, :sum, :count, :includes, :limit, :order, :select, :none
|
34
33
|
def_delegators :mapping, :table, :table_name, :custom_table?, :mappings
|
35
34
|
|
36
35
|
private
|
data/lib/active_force/version.rb
CHANGED
@@ -354,71 +354,6 @@ describe ActiveForce::SObject do
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
-
describe '#pluck' do
|
358
|
-
let(:record_attributes) { [] }
|
359
|
-
|
360
|
-
before do
|
361
|
-
collection = build_restforce_collection(record_attributes.map { |a| build_restforce_sobject(a) })
|
362
|
-
allow(client).to receive(:query).and_return(collection)
|
363
|
-
end
|
364
|
-
|
365
|
-
it 'returns empty array if no records returned from query' do
|
366
|
-
expect(Whizbang.pluck).to eq([])
|
367
|
-
end
|
368
|
-
|
369
|
-
it 'works with another query' do
|
370
|
-
expected = 'SELECT Id, Text_Label FROM Whizbang__c WHERE (Checkbox_Label = true)'
|
371
|
-
Whizbang.where(checkbox: true).pluck(:id, :text)
|
372
|
-
expect(client).to have_received(:query).with(expected)
|
373
|
-
end
|
374
|
-
|
375
|
-
context 'when given no fields' do
|
376
|
-
it 'queries for all fields' do
|
377
|
-
expected = "SELECT #{Whizbang.fields.join ', '} FROM Whizbang__c"
|
378
|
-
Whizbang.pluck
|
379
|
-
expect(client).to have_received(:query).with(expected)
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
context 'when given one field' do
|
384
|
-
let(:ids) { ['a', 'b', 1] }
|
385
|
-
let(:record_attributes) { ids.map { |v| { 'Id' => v } } }
|
386
|
-
|
387
|
-
it 'queries for only that field' do
|
388
|
-
expected = 'SELECT Id FROM Whizbang__c'
|
389
|
-
Whizbang.pluck(:id)
|
390
|
-
expect(client).to have_received(:query).with(expected)
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'returns an array of casted values for that field' do
|
394
|
-
expect(Whizbang.pluck(:id)).to match_array(ids.map(&:to_s))
|
395
|
-
end
|
396
|
-
end
|
397
|
-
|
398
|
-
context 'when given more than one field' do
|
399
|
-
let(:record_attributes) do
|
400
|
-
[
|
401
|
-
{ 'Text_Label' => 'test1', 'Date_Label' => '2023-01-01' },
|
402
|
-
{ 'Text_Label' => 'test2', 'Date_Label' => '2023-01-02' }
|
403
|
-
]
|
404
|
-
end
|
405
|
-
|
406
|
-
it 'queries for only those fields' do
|
407
|
-
expected = 'SELECT Text_Label, Date_Label FROM Whizbang__c'
|
408
|
-
Whizbang.pluck(:text, :date)
|
409
|
-
expect(client).to have_received(:query).with(expected)
|
410
|
-
end
|
411
|
-
|
412
|
-
it 'returns an array of arrays of casted values in the correct order' do
|
413
|
-
expected = [
|
414
|
-
['test1', Date.new(2023, 1, 1)],
|
415
|
-
['test2', Date.new(2023, 1, 2)]
|
416
|
-
]
|
417
|
-
expect(Whizbang.pluck(:text, :date)).to match_array(expected)
|
418
|
-
end
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
357
|
describe '#reload' do
|
423
358
|
let(:client) do
|
424
359
|
double("sfdc_client", query: [Restforce::Mash.new(Id: 1, Name: 'Jeff')])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_force
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Espinaco
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2023-05-
|
14
|
+
date: 2023-05-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activemodel
|