activesalesforce 0.6.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/asf_adapter.rb +23 -4
  2. metadata +2 -2
data/lib/asf_adapter.rb CHANGED
@@ -31,7 +31,7 @@ require File.dirname(__FILE__) + '/id_resolver'
31
31
  require File.dirname(__FILE__) + '/sid_authentication_filter'
32
32
  require File.dirname(__FILE__) + '/recording_binding'
33
33
  require File.dirname(__FILE__) + '/result_array'
34
-
34
+
35
35
 
36
36
 
37
37
  module ActiveRecord
@@ -409,10 +409,11 @@ module ActiveRecord
409
409
  values.map! { |v| v.first == "'" ? v.slice(1, v.length - 2) : v == "NULL" ? nil : v }
410
410
 
411
411
  fields = get_fields(columns, names, values, :updateable)
412
+ null_fields = get_null_fields(columns, names, values, :updateable)
412
413
 
413
414
  id = sql.match(/WHERE\s+id\s*=\s*'(\w+)'/mi)[1]
414
415
 
415
- sobject = create_sobject(entity_def.api_name, id, fields)
416
+ sobject = create_sobject(entity_def.api_name, id, fields, null_fields)
416
417
 
417
418
  @command_boxcar << ActiveSalesforce::BoxcarCommand::Update.new(self, sobject)
418
419
  }
@@ -540,6 +541,19 @@ module ActiveRecord
540
541
  fields
541
542
  end
542
543
 
544
+ def get_null_fields(columns, names, values, access_check)
545
+ fields = {}
546
+ names.each_with_index do | name, n |
547
+ value = values[n]
548
+
549
+ if !value
550
+ column = columns[name]
551
+ fields[column.api_name] = nil if column.send(access_check)
552
+ end
553
+ end
554
+
555
+ fields
556
+ end
543
557
 
544
558
  def extract_sql_modifier(soql, modifier)
545
559
  value = soql.match(/\s+#{modifier}\s+(\d+)/mi)
@@ -715,18 +729,23 @@ module ActiveRecord
715
729
  end
716
730
 
717
731
 
718
- def create_sobject(entity_name, id, fields)
732
+ def create_sobject(entity_name, id, fields, null_fields = [])
719
733
  sobj = []
720
734
 
721
735
  sobj << 'type { :xmlns => "urn:sobject.partner.soap.sforce.com" }' << entity_name
722
736
  sobj << 'Id { :xmlns => "urn:sobject.partner.soap.sforce.com" }' << id if id
723
737
 
724
- # now add any changed fields
738
+ # add any changed fields
725
739
  fieldValues = {}
726
740
  fields.each do | name, value |
727
741
  sobj << name.to_sym << value if value
728
742
  end
729
743
 
744
+ # add null fields
745
+ null_fields.each do | name, value |
746
+ sobj << 'fieldsToNull { :xmlns => "urn:sobject.partner.soap.sforce.com" }' << name
747
+ end
748
+
730
749
  [ :sObjects, sobj ]
731
750
  end
732
751
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: activesalesforce
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.3
7
- date: 2006-08-07 00:00:00 -04:00
6
+ version: 1.0.0
7
+ date: 2006-11-08 00:00:00 -05:00
8
8
  summary: ActiveSalesforce (ASF) is a Rails connection adapter that provides direct access to Salesforce.com hosted data and metadata via the ActiveRecord model layer. Objects, fields, and relationships are all auto surfaced as active record attributes and rels.
9
9
  require_paths:
10
10
  - lib