tyler-composite_primary_keys 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,7 @@ module CompositePrimaryKeys
18
18
  def set_primary_keys(*keys)
19
19
  keys = keys.first if keys.first.is_a?(Array)
20
20
  keys = keys.map { |k| k.to_sym }
21
- cattr_accessor :primary_keys
21
+ cattr_accessor :primary_keys, :auto_increment_column
22
22
  self.primary_keys = keys.to_composite_keys
23
23
 
24
24
  class_eval <<-EOV
@@ -37,7 +37,6 @@ module CompositePrimaryKeys
37
37
  end
38
38
 
39
39
  def set_auto_increment_column(column)
40
- cattr_accessor :auto_increment_column
41
40
  self.auto_increment_column = column
42
41
  end
43
42
  end
@@ -108,11 +107,13 @@ module CompositePrimaryKeys
108
107
  quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) }
109
108
  cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns
110
109
  vals = attributes_minus_pks.values << quoted_id
111
- send("#{self.class.auto_increment_column}=",
112
- connection.insert("INSERT INTO #{self.class.quoted_table_name} " \
113
- "(#{cols.join(', ')}) " \
114
- "VALUES (#{vals.join(', ')})",
115
- "#{self.class.name} Create"))
110
+
111
+ value = connection.insert("INSERT INTO #{self.class.quoted_table_name} " \
112
+ "(#{cols.join(', ')}) " \
113
+ "VALUES (#{vals.join(', ')})",
114
+ "#{self.class.name} Create")
115
+
116
+ send("#{self.class.auto_increment_column}=", value) if self.class.auto_increment_column
116
117
 
117
118
  @new_record = false
118
119
  return true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tyler-composite_primary_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams