db_memoize 0.3.8 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/db_memoize/value.rb +17 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 520170b67792fdb3910895e3c510d6085cbd8666a306d357fdbd61236981c958
|
4
|
+
data.tar.gz: 921d0f58c8757bfc145132e95495f444d8d10cabc3fef247ae945faecc84e883
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 356ede40ddf8a75be14043d01fa83fad462c6df3adc0c28db8a18a866276fdbd7b51c9ad8aef7e6236215f6f623fdbdde5575f987bb46807ddbe425e81e1a12e
|
7
|
+
data.tar.gz: 4c386fbe295073209a55ebac0ff4e03ac97037810fa7b42d7690ce7c4d05f92727887f00e7a9f2045e865b157ad7026607a6899d305d57381437f583c9304e3e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.9
|
data/lib/db_memoize/value.rb
CHANGED
@@ -81,17 +81,34 @@ module DbMemoize
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
ALL_COLUMNS = [
|
85
|
+
:val_string,
|
86
|
+
:val_integer,
|
87
|
+
:val_float,
|
88
|
+
:val_time,
|
89
|
+
:val_object,
|
90
|
+
:val_boolean,
|
91
|
+
:val_nil
|
92
|
+
].freeze
|
93
|
+
|
84
94
|
def self.simple_sql_create_value(column, entity_table_name:, entity_id:, method_name:, value:)
|
95
|
+
other_columns = ALL_COLUMNS - [column]
|
96
|
+
default_updates = other_columns.map { |c| "#{c}=NULL" }
|
97
|
+
|
85
98
|
sql = <<~SQL.freeze
|
86
99
|
INSERT INTO #{table_name}
|
87
100
|
(entity_table_name, entity_id, method_name, #{column}, created_at)
|
88
101
|
VALUES($1,$2,$3,$4,NOW())
|
102
|
+
ON CONFLICT (entity_id, entity_table_name, method_name)
|
103
|
+
DO UPDATE
|
104
|
+
SET #{default_updates.join(', ')}, #{column}=$4, created_at=NOW()
|
89
105
|
SQL
|
90
106
|
|
91
107
|
SQL.ask sql, entity_table_name, entity_id, method_name, value
|
92
108
|
end
|
93
109
|
|
94
110
|
def self.ar_create_value(column, entity_table_name:, entity_id:, method_name:, value:)
|
111
|
+
# [TODO] this code is not resolving conflicts on the unique index.
|
95
112
|
data = {
|
96
113
|
:entity_table_name => entity_table_name,
|
97
114
|
:entity_id => entity_id,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db_memoize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johannes-kostas goetzinger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple-sql
|