better_record 0.13.0 → 0.13.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21977d959c121c40a33fba8d9ce2672e542c591c9140c56e1f8252441eb82260
4
- data.tar.gz: 758ad406a6f5527c615fb79f3f0a7d273962a05808ac13d504d21bb7e063cab3
3
+ metadata.gz: 26ce3d168b954c9b73c86f86910bf9a2e39bbe9ccfef04a424f63aa8406998af
4
+ data.tar.gz: 78df16dd5a0a432d50faa188adfb9fc069ed12f5d05a26ae0d5c242b291ad0d9
5
5
  SHA512:
6
- metadata.gz: 8cb7081304de5466efcb5717a4a20baec1591bdc68ef92566cfd00ac426b880f93b1b142d458f40e2f8f8f1ede9b098629681ff4a1d5db87ca27c77a41433966
7
- data.tar.gz: 151b00bf0f2fcf80ec0b36d794b95c823442bef76d842b49c94f6c162d35abfab3abc0bffb54c6cd7bbdb93beacb9949966ddf6f19e8ecade041bf81b57ab995
6
+ metadata.gz: 7ae0b4f8df3038a0e1f84712b9b9d9765768af2cc4774165c80e912cf4c3f1fdca2fee20dcbf939620b8ea6261bccedde5d73ced320e0000190cf2a6b738b19d
7
+ data.tar.gz: 0e1845dbd6c18909038615f851f51ebaa64b3d3def80fad6209b4c69aada3d5c15a33e88a8fcf943f2a7545b04f0b33959c0eeb7fb54d500855012a6525f89e1
@@ -33,7 +33,7 @@ module BetterRecord
33
33
  end
34
34
 
35
35
  def self.user_type
36
- self.user ? BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class) : 'NULL'
36
+ self.user ? "'#{BetterRecord::PolymorphicOverride.polymorphic_value(self.user.class)}'" : 'NULL'
37
37
  end
38
38
 
39
39
  def self.user_id
@@ -98,25 +98,32 @@ module BetterRecord
98
98
 
99
99
  def transaction(*args)
100
100
  super(*args) do
101
- ActiveRecord::Base.connection.execute <<-SQL
102
- CREATE TEMP TABLE IF NOT EXISTS
103
- "_app_user" (user_id integer, user_type text, ip_address inet);
104
-
105
- UPDATE
106
- _app_user
107
- SET
108
- user_id=#{current_user_id},
109
- user_type='#{current_user_type}',
110
- ip_address=#{current_user_ip};
111
-
112
- INSERT INTO
113
- _app_user (user_id, user_type, ip_address)
114
- SELECT
115
- #{current_user_id},
116
- '#{current_user_type}',
117
- #{current_user_ip}
118
- WHERE NOT EXISTS (SELECT * FROM _app_user);
119
- SQL
101
+ if BetterRecord::Current.user
102
+ ActiveRecord::Base.connection.execute <<-SQL
103
+ CREATE TEMP TABLE IF NOT EXISTS
104
+ "_app_user" (user_id integer, user_type text, ip_address inet);
105
+
106
+ UPDATE
107
+ _app_user
108
+ SET
109
+ user_id=#{current_user_id},
110
+ user_type=#{current_user_type},
111
+ ip_address=#{current_user_ip};
112
+
113
+ INSERT INTO
114
+ _app_user (user_id, user_type, ip_address)
115
+ SELECT
116
+ #{current_user_id},
117
+ #{current_user_type},
118
+ #{current_user_ip}
119
+ WHERE NOT EXISTS (SELECT * FROM _app_user);
120
+ SQL
121
+ else
122
+ ActiveRecord::Base.connection.execute <<-SQL
123
+ CREATE TEMP TABLE IF NOT EXISTS
124
+ "_app_user" (user_id integer, user_type text, ip_address inet);
125
+ SQL
126
+ end
120
127
 
121
128
  yield
122
129
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BetterRecord
4
- VERSION = '0.13.0'
4
+ VERSION = '0.13.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley