active_record_upsert 0.2.0-java → 0.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +7 -0
- data/README.md +33 -0
- data/active_record_upsert.gemspec +3 -2
- data/lib/active_record_upsert/active_record.rb +4 -0
- data/lib/active_record_upsert/active_record/persistence.rb +2 -1
- data/lib/active_record_upsert/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a0bcdf80e0a32511f128657a665774fe7cb13bb
|
4
|
+
data.tar.gz: 7ea7295702c5fbb5d69cecda17c6734fc7d20233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86e4ea1f8d452bec401e7595275ce588bb78f2a7047cd617dc970a14c84feff8a68fe183fb2dcf13e6538fa83a5f2b914f9b5f4358cc16a659fb7bfa684f8115
|
7
|
+
data.tar.gz: 530ce0b3ad1a67a4f44527ed0f1db6daad600266d9684e082ccdf84d16d331d2f471aa066f14fc9e108537c4e27c1e08e98b0db51328f4c34d26b6c8399ac3eb
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -2,3 +2,10 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in active_record_upsert.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
gem 'activerecord-jdbc-adapter', github: 'jensnockert/activerecord-jdbc-adapter', branch: 'activerecord-50'
|
7
|
+
|
8
|
+
gem 'activerecord-jdbcpostgresql-adapter',
|
9
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
10
|
+
branch: 'activerecord-50',
|
11
|
+
platform: :jruby
|
data/README.md
CHANGED
@@ -2,6 +2,19 @@
|
|
2
2
|
|
3
3
|
Real upsert for PostgreSQL 9.5+ and ActiveRecord. Uses ON CONFLICT DO UPDATE.
|
4
4
|
|
5
|
+
## Main points
|
6
|
+
|
7
|
+
- Does upsert on a single record using `ON CONFLICT DO UPDATE`
|
8
|
+
- Updates timestamps as you would expect in ActiveRecord
|
9
|
+
- For partial upserts, loads any existing data from the database
|
10
|
+
|
11
|
+
## Prerequisites
|
12
|
+
|
13
|
+
- PostgreSQL 9.5+
|
14
|
+
- ActiveRecord ~> 5
|
15
|
+
- For MRI: pg
|
16
|
+
- For JRuby: You need to use a fork of `activerecord-jdbcpostgresql-adapter`
|
17
|
+
|
5
18
|
## Installation
|
6
19
|
|
7
20
|
Add this line to your application's Gemfile:
|
@@ -10,6 +23,20 @@ Add this line to your application's Gemfile:
|
|
10
23
|
gem 'active_record_upsert'
|
11
24
|
```
|
12
25
|
|
26
|
+
If you use JRuby, also add the following:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem 'activerecord-jdbc-adapter',
|
30
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
31
|
+
branch: 'activerecord-50',
|
32
|
+
platform: :jruby
|
33
|
+
|
34
|
+
gem 'activerecord-jdbcpostgresql-adapter',
|
35
|
+
github: 'jensnockert/activerecord-jdbc-adapter',
|
36
|
+
branch: 'activerecord-50',
|
37
|
+
platform: :jruby
|
38
|
+
```
|
39
|
+
|
13
40
|
And then execute:
|
14
41
|
|
15
42
|
$ bundle
|
@@ -42,3 +69,9 @@ r.upsert
|
|
42
69
|
|
43
70
|
Bug reports and pull requests are welcome on GitHub at https://github.com/jesjos/active_record_upsert.
|
44
71
|
|
72
|
+
## Contributors
|
73
|
+
|
74
|
+
- Jesper Josefsson
|
75
|
+
- Jens Nockert
|
76
|
+
- Olle Jonsson
|
77
|
+
- Simon Dahlbacka
|
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = ActiveRecordUpsert::VERSION
|
9
9
|
spec.authors = ["Jesper Josefsson"]
|
10
10
|
spec.email = ["jesper.josefsson@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/jesjos/active_record_upsert/"
|
11
12
|
|
12
|
-
spec.summary = %q{Real PostgreSQL upserts using ON CONFLICT for ActiveRecord}
|
13
|
+
spec.summary = %q{Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord}
|
13
14
|
|
14
15
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
16
|
spec.bindir = "exe"
|
@@ -24,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
24
25
|
spec.add_runtime_dependency 'activerecord-jdbcpostgresql-adapter', '> 0'
|
25
26
|
else
|
26
27
|
spec.platform = Gem::Platform::RUBY
|
27
|
-
spec.add_runtime_dependency 'pg', '
|
28
|
+
spec.add_runtime_dependency 'pg', '~> 0.18'
|
28
29
|
end
|
29
30
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.11"
|
@@ -3,7 +3,8 @@ module ActiveRecordUpsert
|
|
3
3
|
module PersistenceExtensions
|
4
4
|
|
5
5
|
def upsert
|
6
|
-
raise ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
6
|
+
raise ::ActiveRecord::ReadOnlyRecord, "#{self.class} is marked as readonly" if readonly?
|
7
|
+
raise ::ActiveRecord::RecordSavedError, "Can't upsert a record that has already been saved" if persisted?
|
7
8
|
values = run_callbacks(:save) {
|
8
9
|
run_callbacks(:create) {
|
9
10
|
_upsert_record
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_upsert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Jesper Josefsson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -158,7 +158,7 @@ files:
|
|
158
158
|
- lib/active_record_upsert/arel/on_conflict_do_update_manager.rb
|
159
159
|
- lib/active_record_upsert/arel/visitors/to_sql.rb
|
160
160
|
- lib/active_record_upsert/version.rb
|
161
|
-
homepage:
|
161
|
+
homepage: https://github.com/jesjos/active_record_upsert/
|
162
162
|
licenses: []
|
163
163
|
metadata: {}
|
164
164
|
post_install_message:
|
@@ -180,5 +180,5 @@ rubyforge_project:
|
|
180
180
|
rubygems_version: 2.4.8
|
181
181
|
signing_key:
|
182
182
|
specification_version: 4
|
183
|
-
summary: Real PostgreSQL upserts using ON CONFLICT for ActiveRecord
|
183
|
+
summary: Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord
|
184
184
|
test_files: []
|