umbrellio-sequel-plugins 0.3.1.69 → 0.3.1.77

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
- SHA1:
3
- metadata.gz: 70852475f6cb8cdfb7523276d0477d121e9d0151
4
- data.tar.gz: a2748b365400fb0f7f81cb2fe5a32df81718c6ee
2
+ SHA256:
3
+ metadata.gz: 4f45fa7dda328379013d3df5e1d54c0972744408576028bfee1ef4e7b5ce0a83
4
+ data.tar.gz: e3265443bc9044e398e5eb15b793be942c32298b2969de0ad42c0b6afa95d256
5
5
  SHA512:
6
- metadata.gz: 1ce6cdfa71094d71107491a75b5ced6ab79a31b765856159cefd95ed091205e1a735e3caa13824b29888dc534ccde36f8bc50dc4219ebfd6288ed61046fb49a3
7
- data.tar.gz: 999662fce1882b2ce76abf9dfacff89f7ad509b67808806bd9ee31cd3f01d67f0a338a2801379e992b2a0275489640baa4a8ec5628937592d8ae48454a4dee86
6
+ metadata.gz: 4160f5dac702415ad606d361d6e88af80e1129551f941e9a780ec66f01c3f06834b9050fe308a5d4b0a561c3da466696d8b319d85a3136581e71dca82e2499b8
7
+ data.tar.gz: 1d7ccd55314a601c1b09932e036b50e99fd67399918fece58d5a3d6da3ea75a827fc3df0f872490ae42f927ccf1fd82b51163476fa926d87bb2229562a4e55e7
data/.gitignore CHANGED
@@ -11,3 +11,5 @@
11
11
  .rspec_status
12
12
 
13
13
  Gemfile.lock
14
+
15
+ log
@@ -11,13 +11,14 @@ module Sequel::Plugins::Upsert
11
11
  # @return [Sequel::Dataset] dataset
12
12
  def upsert_dataset(target: primary_key)
13
13
  cols = columns - Array(primary_key)
14
+
14
15
  update_spec = cols.map { |x| [x, Sequel[:excluded][x]] }
15
- where_spec = cols.map { |x| [Sequel[table_name][x], Sequel[:excluded][x]] }
16
+ where_spec = cols.map { |x| Sequel::Plugins::Upsert.distinct_expr(table_name, x) }.reduce(:|)
16
17
 
17
18
  dataset.insert_conflict(
18
19
  target: target,
19
20
  update: update_spec,
20
- update_where: Sequel.~(where_spec),
21
+ update_where: where_spec,
21
22
  )
22
23
  end
23
24
 
@@ -57,4 +58,8 @@ module Sequel::Plugins::Upsert
57
58
  @upsert_model ||= Sequel::Model(table_name)
58
59
  end
59
60
  end
61
+
62
+ def self.distinct_expr(table_name, col)
63
+ Sequel.lit("? IS DISTINCT FROM ?", Sequel[table_name][col], Sequel[:excluded][col])
64
+ end
60
65
  end
data/log/.keep ADDED
File without changes
data/utils/database.rb CHANGED
@@ -1,7 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ::DB ||= Sequel.connect(ENV["DB_URL"] || "postgres://localhost/sequel_plugins")
3
+ require "logger"
4
+
5
+ DB = Sequel.connect(ENV["DB_URL"] || "postgres://localhost/sequel_plugins")
6
+ DB.logger = Logger.new("log/db.log")
7
+
4
8
  Sequel::Model.db = DB
9
+
5
10
  DB.extension :pg_array
6
11
  DB.extension :pg_json
7
12
  DB.extension :pg_range
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1.69
4
+ version: 0.3.1.77
5
5
  platform: ruby
6
6
  authors:
7
7
  - nulldef
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-03 00:00:00.000000000 Z
11
+ date: 2019-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -185,6 +185,7 @@ files:
185
185
  - lib/tasks/sequel/undo.rake
186
186
  - lib/umbrellio-sequel-plugins.rb
187
187
  - lib/umbrellio_sequel_plugins.rb
188
+ - log/.keep
188
189
  - umbrellio-sequel-plugins.gemspec
189
190
  - utils/database.rb
190
191
  homepage: https://github.com/umbrellio/umbrellio-sequel-plugins
@@ -207,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
208
  version: '0'
208
209
  requirements: []
209
210
  rubyforge_project:
210
- rubygems_version: 2.6.14.4
211
+ rubygems_version: 2.7.7
211
212
  signing_key:
212
213
  specification_version: 4
213
214
  summary: Sequel plugins