active_record_upsert 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ea38395a34ac563cfd8115846c310970a85a4f5
4
- data.tar.gz: 1ed0d73191b13a214e82a855fdf50da8c1d1d03d
3
+ metadata.gz: fdb375cbcf07846e95058205f81ffbf09fc2e1b0
4
+ data.tar.gz: d6056b35652b183e771a14694e2b20c009d1b4d7
5
5
  SHA512:
6
- metadata.gz: 93a316ed4a487e6156a97c91b1184bbe7211a1a6c3087a415c0bbeb4438ecd38ad8fcb5387a508aeafd498805f43e450746004b67668c8966f226b701092b434
7
- data.tar.gz: 773c2edf9eaae7a2e9ce5aea7e55fd0b5b272b98ce4765a85bd6938bde7a330515f09110ca4a9df819ef09728a23c7c14e6782748ae303604a51ffb36ca8b57a
6
+ metadata.gz: c0bba59eda8cec0d58f8856629f7f2b9ff2d89f106558150a4262c8dd15585ebadb5275e318e3345205b579b7b1c3c9601cffc5f06b8b867aa130c7ea42edacf
7
+ data.tar.gz: bae1fee3ff3b0896ac2e4220ac58cd56f83eb351e2b0bfec3b117362147dc525baaf3f1c71046ec7fb0de8b159d4d387d27fb9568d0d1a31882febd980f2820b
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /spec/dummy/log/*.log
data/.travis.yml CHANGED
@@ -1,5 +1,16 @@
1
+ sudo: required
2
+ dist: trusty
1
3
  language: ruby
4
+ env:
5
+ - DATABASE_URL="postgresql://postgres@localhost/upsert_test"
2
6
  rvm:
3
- - jruby-9.0.5.0
4
- - 2.3.0
5
- before_install: gem install bundler -v 1.11.2
7
+ - 2.3.1
8
+ before_script:
9
+ - createdb --echo -U postgres upsert_test
10
+ - psql -U postgres upsert_test < spec/dummy/db/structure.sql
11
+
12
+ before_install: gem install bundler -v 1.13.3
13
+
14
+ addons:
15
+ postgresql: "9.5"
16
+
data/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ FROM quay.io/travisci/travis-ruby
2
+ RUN apt-add-repository ppa:brightbox/ruby-ng
3
+ RUN apt-get update
4
+ RUN apt-get install ruby2.3 ruby2.3-dev
5
+ RUN ruby --version
6
+
7
+ ENV BUNDLE_GEMFILE=/app/Gemfile.docker
8
+ RUN gem install nokogiri
9
+ RUN gem install bundler
10
+ COPY Gemfile* *.gemspec /app/
11
+ RUN mkdir -p /app/lib/active_record_upsert
12
+ COPY lib/active_record_upsert/version.rb /app/lib/active_record_upsert/
13
+ WORKDIR /app
14
+ RUN bundle install
15
+ COPY . /app
16
+ CMD bin/run_docker_test.sh
17
+
18
+
data/Gemfile CHANGED
@@ -3,12 +3,3 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in active_record_upsert.gemspec
4
4
  gemspec
5
5
 
6
- gem 'activerecord-jdbc-adapter',
7
- github: 'jensnockert/activerecord-jdbc-adapter',
8
- branch: 'activerecord-50',
9
- platform: :jruby
10
-
11
- gem 'activerecord-jdbcpostgresql-adapter',
12
- github: 'jensnockert/activerecord-jdbc-adapter',
13
- branch: 'activerecord-50',
14
- platform: :jruby
data/Gemfile.docker ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in active_record_upsert.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/active_record_upsert.svg)](https://badge.fury.io/rb/active_record_upsert)
1
2
  [![Build Status](https://travis-ci.org/jesjos/active_record_upsert.svg?branch=master)](https://travis-ci.org/jesjos/active_record_upsert)
2
3
  [![Code Climate](https://codeclimate.com/github/jesjos/active_record_upsert/badges/gpa.svg)](https://codeclimate.com/github/jesjos/active_record_upsert)
4
+ [![Dependency Status](https://gemnasium.com/badges/github.com/jesjos/active_record_upsert.svg)](https://gemnasium.com/github.com/jesjos/active_record_upsert)
3
5
 
4
6
  # ActiveRecordUpsert
5
7
 
@@ -16,7 +18,8 @@ Real upsert for PostgreSQL 9.5+ and Rails 5 / ActiveRecord 5. Uses [ON CONFLICT
16
18
  - PostgreSQL 9.5+
17
19
  - ActiveRecord ~> 5
18
20
  - For MRI: pg
19
- - For JRuby: You need to use a fork of `activerecord-jdbcpostgresql-adapter`
21
+
22
+ - For JRuby: No support
20
23
 
21
24
  ## Installation
22
25
 
@@ -26,20 +29,6 @@ Add this line to your application's Gemfile:
26
29
  gem 'active_record_upsert'
27
30
  ```
28
31
 
29
- If you use JRuby, also add the following:
30
-
31
- ```ruby
32
- gem 'activerecord-jdbc-adapter',
33
- github: 'jensnockert/activerecord-jdbc-adapter',
34
- branch: 'activerecord-50',
35
- platform: :jruby
36
-
37
- gem 'activerecord-jdbcpostgresql-adapter',
38
- github: 'jensnockert/activerecord-jdbc-adapter',
39
- branch: 'activerecord-50',
40
- platform: :jruby
41
- ```
42
-
43
32
  And then execute:
44
33
 
45
34
  $ bundle
data/Rakefile CHANGED
@@ -1,6 +1,25 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'active_record'
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task :setup_and_run_spec do |rake_task|
7
+ puts "<:#{rake_task.name}> Ensuring database is prepared..."
8
+
9
+ # Configure Rails Environment
10
+ ENV['RAILS_ENV'] = 'test'
11
+ ENV['DATABASE_URL'] ||= 'postgresql://localhost/upsert_test'
12
+ require 'active_record/connection_adapters/postgresql_adapter'
13
+
14
+ require File.expand_path('../spec/dummy/config/environment.rb', __FILE__)
15
+
16
+ include ActiveRecord::Tasks
17
+ DatabaseTasks.db_dir = 'spec/dummy/db'
18
+ DatabaseTasks.drop_current
19
+ DatabaseTasks.create_current
20
+ DatabaseTasks.migrate
21
+
22
+ Rake::Task['spec'].invoke
23
+ end
24
+
25
+ task default: :setup_and_run_spec
@@ -6,8 +6,8 @@ require 'active_record_upsert/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "active_record_upsert"
8
8
  spec.version = ActiveRecordUpsert::VERSION
9
- spec.authors = ["Jesper Josefsson"]
10
- spec.email = ["jesper.josefsson@gmail.com"]
9
+ spec.authors = ["Jesper Josefsson", "Olle Jonsson"]
10
+ spec.email = ["jesper.josefsson@gmail.com", "olle.jonsson@gmail.com"]
11
11
  spec.homepage = "https://github.com/jesjos/active_record_upsert/"
12
12
 
13
13
  spec.summary = %q{Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord}
@@ -17,20 +17,16 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_runtime_dependency "activerecord", "~> 5.0.0.beta2"
20
+ spec.add_runtime_dependency 'activerecord', '~> 5.0.0.beta4'
21
21
  spec.add_runtime_dependency "arel", "~>7.0"
22
22
 
23
- if defined?(JRUBY_VERSION)
24
- spec.platform = 'java'
25
- spec.add_runtime_dependency 'activerecord-jdbcpostgresql-adapter', '> 0'
26
- else
27
- spec.platform = Gem::Platform::RUBY
28
- spec.add_runtime_dependency 'pg', '~> 0.18'
29
- end
23
+ spec.platform = Gem::Platform::RUBY
24
+ spec.add_runtime_dependency 'pg', '~> 0.18'
30
25
 
31
26
  spec.add_development_dependency "bundler", "~> 1.11"
32
27
  spec.add_development_dependency "rake", "~> 10.0"
33
28
  spec.add_development_dependency "rspec", "~> 3.0"
34
29
  spec.add_development_dependency "pry", "> 0"
35
- spec.add_development_dependency "database_cleaner", "~> 1.5.1"
30
+ spec.add_development_dependency "database_cleaner", "~> 1.5.3"
31
+ spec.add_development_dependency 'rails', '~> 5.0.0.beta4'
36
32
  end
data/bin/release ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+ OUR_RUBY=2.2.3
4
+
5
+ rvm $OUR_RUBY do bundle check
6
+ rvm $OUR_RUBY do bundle exec rake release
7
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ pushd spec/dummy
3
+ RAILS_ENV=test rails db:migrate
4
+ popd
5
+ RAILS_ENV=test bundle exec rspec
data/bin/run_rails.sh ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ pushd spec/dummy
3
+ RAILS_ENV=test bundle exec rails $@
4
+ popd
@@ -0,0 +1,14 @@
1
+ version: '2'
2
+ services:
3
+ db:
4
+ image: postgres:9.5
5
+ ports:
6
+ - "5432:5432"
7
+ app:
8
+ environment:
9
+ - DATABASE_URL=postgresql://postgres@db/active_record_upsert_test
10
+ build: .
11
+ depends_on:
12
+ - db
13
+ links:
14
+ - db
@@ -6,19 +6,7 @@ module ActiveRecordUpsert
6
6
  def exec_upsert(_sql, _name, _binds, _pk)
7
7
  raise NotImplementedError
8
8
  end
9
-
10
- def upsert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
11
- sql, binds, pk, _sequence_name = sql_for_upsert(to_sql(arel, binds), pk, id_value, sequence_name, binds)
12
- exec_upsert(sql, name, binds, pk)
13
- end
14
-
15
- def sql_for_upsert(sql, pk, id_value, sequence_name, binds)
16
- [sql, binds, pk, sequence_name]
17
- end
18
9
  end
19
-
20
- # ::ActiveRecord::ConnectionAdapters::DatabaseStatements.include(DatabaseStatementsExtensions)
21
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(DatabaseStatementsExtensions)
22
10
  end
23
11
  end
24
12
  end
@@ -3,17 +3,20 @@ module ActiveRecordUpsert
3
3
  module ConnectionAdapters
4
4
  module Postgresql
5
5
  module DatabaseStatementsExtensions
6
+ def upsert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
7
+ sql, binds, pk, _sequence_name = sql_for_upsert(to_sql(arel, binds), pk, id_value, sequence_name, binds)
8
+ exec_upsert(sql, name, binds, pk)
9
+ end
10
+
6
11
  def sql_for_upsert(sql, pk, id_value, sequence_name, binds)
7
12
  sql = "#{sql} RETURNING *"
8
- super
13
+ [sql, binds, pk, sequence_name]
9
14
  end
10
15
 
11
16
  def exec_upsert(sql, name, binds, pk)
12
17
  exec_query(sql, name, binds)
13
18
  end
14
19
  end
15
-
16
- ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(DatabaseStatementsExtensions)
17
20
  end
18
21
  end
19
22
  end
@@ -1,5 +1,3 @@
1
- require 'active_record/connection_adapters/postgresql_adapter'
2
-
3
1
  Dir.glob(File.join(__dir__, 'active_record/**/*.rb')) do |f|
4
2
  require f
5
3
  end
@@ -13,4 +11,8 @@ end
13
11
  ::ActiveRecord::Base.prepend(ActiveRecordUpsert::ActiveRecord::TimestampExtensions)
14
12
  ::ActiveRecord::Base.prepend(ActiveRecordUpsert::ActiveRecord::TransactionsExtensions)
15
13
 
14
+ #::ActiveRecord::ConnectionAdapters::DatabaseStatements.include(ActiveRecordUpsert::ActiveRecord::ConnectionAdapters::Abstract::DatabaseStatementsExtensions)
15
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(ActiveRecordUpsert::ActiveRecord::ConnectionAdapters::Abstract::DatabaseStatementsExtensions)
16
+ ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(ActiveRecordUpsert::ActiveRecord::ConnectionAdapters::Postgresql::DatabaseStatementsExtensions)
17
+
16
18
  ::ActiveRecord::Relation.include(ActiveRecordUpsert::ActiveRecord::RelationExtensions)
@@ -1,3 +1,3 @@
1
1
  module ActiveRecordUpsert
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_upsert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Josefsson
8
+ - Olle Jonsson
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2016-04-13 00:00:00.000000000 Z
12
+ date: 2016-10-14 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activerecord
@@ -16,14 +17,14 @@ dependencies:
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta2
20
+ version: 5.0.0.beta4
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: 5.0.0.beta2
27
+ version: 5.0.0.beta4
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: arel
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -114,17 +115,32 @@ dependencies:
114
115
  requirements:
115
116
  - - "~>"
116
117
  - !ruby/object:Gem::Version
117
- version: 1.5.1
118
+ version: 1.5.3
118
119
  type: :development
119
120
  prerelease: false
120
121
  version_requirements: !ruby/object:Gem::Requirement
121
122
  requirements:
122
123
  - - "~>"
123
124
  - !ruby/object:Gem::Version
124
- version: 1.5.1
125
+ version: 1.5.3
126
+ - !ruby/object:Gem::Dependency
127
+ name: rails
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: 5.0.0.beta4
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: 5.0.0.beta4
125
140
  description:
126
141
  email:
127
142
  - jesper.josefsson@gmail.com
143
+ - olle.jonsson@gmail.com
128
144
  executables: []
129
145
  extensions: []
130
146
  extra_rdoc_files: []
@@ -132,12 +148,18 @@ files:
132
148
  - ".gitignore"
133
149
  - ".rspec"
134
150
  - ".travis.yml"
151
+ - Dockerfile
135
152
  - Gemfile
153
+ - Gemfile.docker
136
154
  - README.md
137
155
  - Rakefile
138
156
  - active_record_upsert.gemspec
139
157
  - bin/console
158
+ - bin/release
159
+ - bin/run_docker_test.sh
160
+ - bin/run_rails.sh
140
161
  - bin/setup
162
+ - docker-compose.yml
141
163
  - lib/active_record_upsert.rb
142
164
  - lib/active_record_upsert/active_record.rb
143
165
  - lib/active_record_upsert/active_record/connection_adapters/abstract/database_statements.rb
@@ -178,9 +200,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
200
  version: '0'
179
201
  requirements: []
180
202
  rubyforge_project:
181
- rubygems_version: 2.5.1
203
+ rubygems_version: 2.4.5.1
182
204
  signing_key:
183
205
  specification_version: 4
184
206
  summary: Real PostgreSQL 9.5+ upserts using ON CONFLICT for ActiveRecord
185
207
  test_files: []
186
- has_rdoc: