composite_primary_keys 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -18,7 +18,7 @@ RUBY_FORGE_PROJECT = "compositekeys"
18
18
  RUBY_FORGE_USER = "nicwilliams"
19
19
 
20
20
  PKG_FILES = FileList[
21
- "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "[A-Z]*", "install.rb", "Rakefile"
21
+ "lib/**/*", "test/**/*", "examples/**/*", "doc/**/*", "scripts/**/*", "website/**/*", "[A-Z]*", "install.rb", "CHANGELOG", "README", "Rakefile"
22
22
  ].exclude(/\bCVS\b|~$/)
23
23
 
24
24
 
@@ -151,7 +151,7 @@ module CompositePrimaryKeys
151
151
  connection.update(
152
152
  "UPDATE #{self.class.table_name} " +
153
153
  "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
154
- "WHERE (#{self.class.primary_key}) = (#{id})",
154
+ "WHERE (#{self.class.primary_key}) = (#{quoted_id})",
155
155
  "#{self.class.name} Update"
156
156
  )
157
157
  return true
@@ -276,10 +276,13 @@ module CompositePrimaryKeys
276
276
  # If ids = [[10, 50], [11, 51]], then :conditions =>
277
277
  # "(#{table_name}.a, #{table_name}.b) IN ((10, 50), (11, 51))"
278
278
 
279
- keys_sql = primary_keys.map {|key| "#{table_name}.#{key.to_s}"}.join(',')
280
- ids_sql = ids.map {|id_set| id_set.map {|id| sanitize(id)}.join(',')}.join('),(')
281
- options.update :conditions => "(#{keys_sql}) IN ((#{ids_sql}))"
282
-
279
+ conditions = ids.map do |id_set|
280
+ [primary_keys, id_set].transpose.map do |key, id|
281
+ "#{table_name}.#{key.to_s}=#{sanitize(id)}"
282
+ end.join(" AND ")
283
+ end.join(") OR (")
284
+ options.update :conditions => "(#{conditions})"
285
+
283
286
  result = find_every(options)
284
287
 
285
288
  if result.size == ids.size
@@ -1,8 +1,8 @@
1
1
  module CompositePrimaryKeys
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 6
5
- TINY = 3
4
+ MINOR = 7
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: composite_primary_keys
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.6.3
7
- date: 2006-08-15 00:00:00 +02:00
6
+ version: 0.7.0
7
+ date: 2006-08-31 00:00:00 +02:00
8
8
  summary: Support for composite primary keys in ActiveRecords
9
9
  require_paths:
10
10
  - lib