sequel_postgresql_triggers 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sequel_postgresql_triggers.rb +3 -3
- data/spec/sequel_postgresql_triggers_spec.rb +9 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c840eb70121de040c927fd25cf0611cf8c475bb
|
4
|
+
data.tar.gz: 39edf714024b57ace34c3aa0be20d10947a27133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5533d19fb6cdf0dbb96c4a09a25dddbb814a189026c8c0d95e674f6a2109180d8b69023399399666e745e47dae48633592bfb757c708eb7ed34868f00169f7e1
|
7
|
+
data.tar.gz: 211a34c135965d5585662b1e1fb8f201413443704404742453b2e27ff6ad186c92ce9a2b2525614a991f3da4f9daab866a41bac78b02653f51852986dcae82f4
|
@@ -126,11 +126,11 @@ module Sequel
|
|
126
126
|
sql = <<-SQL
|
127
127
|
BEGIN
|
128
128
|
IF (TG_OP = 'INSERT') THEN
|
129
|
-
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['NEW']} AND #{quote_identifier(column)} <> CURRENT_TIMESTAMP;
|
129
|
+
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['NEW']} AND ((#{quote_identifier(column)} <> CURRENT_TIMESTAMP) OR (#{quote_identifier(column)} IS NULL));
|
130
130
|
ELSIF (TG_OP = 'UPDATE') THEN
|
131
|
-
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['NEW']} AND #{quote_identifier(column)} <> CURRENT_TIMESTAMP;
|
131
|
+
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['NEW']} AND ((#{quote_identifier(column)} <> CURRENT_TIMESTAMP) OR (#{quote_identifier(column)} IS NULL));
|
132
132
|
ELSIF (TG_OP = 'DELETE') THEN
|
133
|
-
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['OLD']} AND #{quote_identifier(column)} <> CURRENT_TIMESTAMP;
|
133
|
+
UPDATE #{quote_schema_table(touch_table)} SET #{quote_identifier(column)} = CURRENT_TIMESTAMP WHERE #{cond['OLD']} AND ((#{quote_identifier(column)} <> CURRENT_TIMESTAMP) OR (#{quote_identifier(column)} IS NULL));
|
134
134
|
END IF;
|
135
135
|
RETURN NULL;
|
136
136
|
END;
|
@@ -220,5 +220,14 @@ describe "PostgreSQL Triggers" do
|
|
220
220
|
DB[:children].delete
|
221
221
|
DB[:parents].get(:changed_on).should > time
|
222
222
|
end
|
223
|
+
|
224
|
+
specify "Should update the timestamp on the related table if that timestamp is initially NULL" do
|
225
|
+
DB.pgt_touch(:children, :parents, :changed_on, :id1=>:parent_id1)
|
226
|
+
DB[:parents] << {:id1=>1, :changed_on=>nil}
|
227
|
+
DB[:children] << {:id=>1, :parent_id1=>1}
|
228
|
+
changed_on = DB[:parents].get(:changed_on)
|
229
|
+
changed_on.should_not == nil
|
230
|
+
changed_on.strftime('%F').should == Date.today.strftime('%F')
|
231
|
+
end
|
223
232
|
end
|
224
233
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_postgresql_triggers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description:
|
@@ -30,8 +30,8 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- README
|
34
33
|
- MIT-LICENSE
|
34
|
+
- README
|
35
35
|
- lib/sequel_postgresql_triggers.rb
|
36
36
|
- spec/sequel_postgresql_triggers_spec.rb
|
37
37
|
homepage: https://github.com/jeremyevans/sequel_postgresql_triggers
|
@@ -40,9 +40,9 @@ licenses:
|
|
40
40
|
metadata: {}
|
41
41
|
post_install_message:
|
42
42
|
rdoc_options:
|
43
|
-
- --inline-source
|
44
|
-
- --line-numbers
|
45
|
-
- --title
|
43
|
+
- "--inline-source"
|
44
|
+
- "--line-numbers"
|
45
|
+
- "--title"
|
46
46
|
- 'Sequel PostgreSQL Triggers: Database enforced timestamps, immutable columns, and
|
47
47
|
counter/sum caches'
|
48
48
|
- README
|
@@ -52,17 +52,17 @@ require_paths:
|
|
52
52
|
- lib
|
53
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
|
-
- -
|
55
|
+
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.0
|
65
|
+
rubygems_version: 2.2.0
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Database enforced timestamps, immutable columns, and counter/sum caches
|