composite_primary_keys 6.0.3 → 6.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTRiYTBhMGQzN2IxNDdkMGZhNjE1MGQ3NDc2ZWZkYTI2NWQ2Nzg1ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzNmMGQzNmIxODQ1NTk1ODk1ZDJjMTk4OTg4NDIxZDZlM2I5NzI4Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWYyNTQwMDYyNTgxYmMyM2FjMTdlMjg2ZWU5Yjg4OTZjOTc5YzIzNzRlZDAx
|
10
|
+
MjhmNzk3NzI4NjFmOTc3OWVhMDY4ZThhYjI2NDhiMDQ3YzM0MTA1ZWQzOGM3
|
11
|
+
ZWZjOWE2NDhlNGJkZGU2MGI1Mjk1ZDJmODU2MDIzOTQ0NjExZDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTZmZTQ0ZTNlYjhiZjBmYmE5YWEwZDNkMjViMTM0YjIyYTc1NDRhOTQ3YWU1
|
14
|
+
YzlmMTdkZDc3MmIxNDMwYTUwYWIyOWMwM2IzYzM2YTI3MzVlNmI3YzUzZTVk
|
15
|
+
YmIxZWJjNzc4YWU0YWE3YmRhZjVlODJjMGQwYzZmNWIwMGZmYWM=
|
@@ -9,15 +9,20 @@ module CompositePrimaryKeys
|
|
9
9
|
# For some reason when we overide here we lose dirty!
|
10
10
|
# So, for now, timestamps are recorded explicitly
|
11
11
|
def create_record(attribute_names = nil)
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
run_callbacks(:create) do
|
13
|
+
record_timestamps!
|
14
|
+
attribute_names ||= keys_for_partial_write
|
15
|
+
attributes_values = arel_attributes_with_values_for_create(attribute_names)
|
15
16
|
|
16
|
-
|
17
|
-
self.id = new_id if self.class.primary_key
|
17
|
+
new_id = self.class.unscoped.insert attributes_values
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
# DB like MySQL doesn't return the newly inserted result.
|
20
|
+
# self.id cannot be updated for this case.
|
21
|
+
self.id = new_id if self.class.primary_key and new_id.kind_of?(Array)
|
22
|
+
|
23
|
+
@new_record = false
|
24
|
+
id
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def record_timestamps!
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionAdapters
|
3
|
+
class PostgreSQLColumn
|
4
|
+
# This overide is needed to ensure ActiveRecord::Dirty behaves as expected
|
5
|
+
def type_cast(value)
|
6
|
+
return value if value.kind_of?(Array)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
class PostgreSQLAdapter
|
4
12
|
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
|
5
13
|
unless pk
|
@@ -36,7 +44,7 @@ module ActiveRecord
|
|
36
44
|
# otherwise returns an array coresponding to the composite keys
|
37
45
|
#
|
38
46
|
def last_inserted_id(result)
|
39
|
-
row = result.rows.first
|
47
|
+
row = result && result.rows.first
|
40
48
|
if Array === row
|
41
49
|
row.size == 1 ? row[0] : row
|
42
50
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# To run tests:
|
2
|
+
# 1. Copy this file to test/connections/databases.yml.
|
3
|
+
# 2. Update to match the databases you want to test against.
|
4
|
+
|
5
|
+
mysql:
|
6
|
+
adapter: mysql2
|
7
|
+
username: root
|
8
|
+
database: composite_primary_keys_unittest
|
9
|
+
|
10
|
+
sqlite3:
|
11
|
+
adapter: sqlite3
|
12
|
+
database: db/composite_primary_keys_unittest.sqlite
|
13
|
+
|
14
|
+
postgresql:
|
15
|
+
adapter: postgresql
|
16
|
+
database: composite_primary_keys_unittest
|
17
|
+
username: daniel
|
18
|
+
host: localhost
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: composite_primary_keys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- test/abstract_unit.rb
|
86
86
|
- test/connections/connection_spec.rb
|
87
87
|
- test/connections/databases.example.yml
|
88
|
+
- test/connections/databases.yml
|
88
89
|
- test/connections/native_ibm_db/connection.rb
|
89
90
|
- test/connections/native_mysql/connection.rb
|
90
91
|
- test/connections/native_oracle/connection.rb
|