activerecord5-redshift-adapter 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/redshift/database_statements.rb +21 -6
- data/lib/active_record/connection_adapters/redshift/quoting.rb +2 -2
- data/lib/active_record/connection_adapters/redshift/utils.rb +2 -2
- data/lib/active_record/connection_adapters/redshift_adapter.rb +7 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d005f91339d55e76d7049742031c13f01e2d6c5
|
4
|
+
data.tar.gz: 921290bab163086925bb525c8fc46969449bbdb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e487fc2579684324dd31c71f0abf79cc396ec643ab2e5732e27400bd5cc23383a4f203886209f9315b84384183f5f1c696e2bc76801050e54878b4879d1da63
|
7
|
+
data.tar.gz: 4745a50021f467e6ffd585a321f872ac4cba0acb2df54473cf829e339679eb439ed14d09f61a6cff2bf41682c7122f23c8ff76b1b6f203512521abc05694a443
|
@@ -45,16 +45,31 @@ module ActiveRecord
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def select_value(arel, name = nil, binds = [])
|
48
|
-
|
49
|
-
|
48
|
+
# In Rails 5.2, arel_from_relation replaced binds_from_relation,
|
49
|
+
# so we see which method exists to get the variables
|
50
|
+
if respond_to?(:arel_from_relation, true)
|
51
|
+
arel = arel_from_relation(arel)
|
52
|
+
sql, binds = to_sql(arel, binds)
|
53
|
+
else
|
54
|
+
arel, binds = binds_from_relation arel, binds
|
55
|
+
sql = to_sql(arel, binds)
|
56
|
+
end
|
50
57
|
execute_and_clear(sql, name, binds) do |result|
|
51
58
|
result.getvalue(0, 0) if result.ntuples > 0 && result.nfields > 0
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
55
62
|
def select_values(arel, name = nil)
|
56
|
-
|
57
|
-
|
63
|
+
# In Rails 5.2, arel_from_relation replaced binds_from_relation,
|
64
|
+
# so we see which method exists to get the variables
|
65
|
+
if respond_to?(:arel_from_relation, true)
|
66
|
+
arel = arel_from_relation(arel)
|
67
|
+
sql, binds = to_sql(arel, [])
|
68
|
+
else
|
69
|
+
arel, binds = binds_from_relation arel, []
|
70
|
+
sql = to_sql(arel, binds)
|
71
|
+
end
|
72
|
+
|
58
73
|
execute_and_clear(sql, name, binds) do |result|
|
59
74
|
if result.nfields > 0
|
60
75
|
result.column_values(0)
|
@@ -126,8 +141,8 @@ module ActiveRecord
|
|
126
141
|
end
|
127
142
|
end
|
128
143
|
|
129
|
-
# Executes an SQL statement, returning a
|
130
|
-
# or raising a
|
144
|
+
# Executes an SQL statement, returning a PG::Result object on success
|
145
|
+
# or raising a PG::Error exception otherwise.
|
131
146
|
def execute(sql, name = nil)
|
132
147
|
log(sql, name) do
|
133
148
|
@connection.async_exec(sql)
|
@@ -37,12 +37,12 @@ module ActiveRecord
|
|
37
37
|
|
38
38
|
# Quotes column names for use in SQL queries.
|
39
39
|
def quote_column_name(name) #:nodoc:
|
40
|
-
|
40
|
+
PG::Connection.quote_ident(name.to_s)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Quotes schema names for use in SQL queries.
|
44
44
|
def quote_schema_name(name)
|
45
|
-
|
45
|
+
PG::Connection.quote_ident(name)
|
46
46
|
end
|
47
47
|
|
48
48
|
# Quote date/time values for use in SQL input.
|
@@ -19,9 +19,9 @@ module ActiveRecord
|
|
19
19
|
|
20
20
|
def quoted
|
21
21
|
if schema
|
22
|
-
|
22
|
+
PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
|
23
23
|
else
|
24
|
-
|
24
|
+
PG::Connection.quote_ident(identifier)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -34,10 +34,10 @@ module ActiveRecord
|
|
34
34
|
conn_params[:user] = conn_params.delete(:username) if conn_params[:username]
|
35
35
|
conn_params[:dbname] = conn_params.delete(:database) if conn_params[:database]
|
36
36
|
|
37
|
-
# Forward only valid config params to
|
37
|
+
# Forward only valid config params to PG::Connection.connect.
|
38
38
|
conn_params.keep_if { |k, _| RS_VALID_CONN_PARAMS.include?(k) }
|
39
39
|
|
40
|
-
# The postgres drivers don't allow the creation of an unconnected
|
40
|
+
# The postgres drivers don't allow the creation of an unconnected PG::Connection object,
|
41
41
|
# so just pass a nil connection object for the time being.
|
42
42
|
ConnectionAdapters::RedshiftAdapter.new(nil, logger, conn_params, config)
|
43
43
|
end
|
@@ -176,8 +176,8 @@ module ActiveRecord
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def connection_active?
|
179
|
-
@connection.status ==
|
180
|
-
rescue
|
179
|
+
@connection.status == PG::Connection::CONNECTION_OK
|
180
|
+
rescue PG::Error
|
181
181
|
false
|
182
182
|
end
|
183
183
|
end
|
@@ -218,7 +218,7 @@ module ActiveRecord
|
|
218
218
|
def active?
|
219
219
|
@connection.query 'SELECT 1'
|
220
220
|
true
|
221
|
-
rescue
|
221
|
+
rescue PG::Error
|
222
222
|
false
|
223
223
|
end
|
224
224
|
|
@@ -522,7 +522,7 @@ module ActiveRecord
|
|
522
522
|
# FEATURE_NOT_SUPPORTED. Check here for more details:
|
523
523
|
# http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob;f=src/backend/utils/cache/plancache.c#l573
|
524
524
|
begin
|
525
|
-
code = pgerror.result.result_error_field(
|
525
|
+
code = pgerror.result.result_error_field(PG::Result::PG_DIAG_SQLSTATE)
|
526
526
|
rescue
|
527
527
|
raise e
|
528
528
|
end
|
@@ -561,7 +561,7 @@ module ActiveRecord
|
|
561
561
|
# Connects to a PostgreSQL server and sets up the adapter depending on the
|
562
562
|
# connected server's characteristics.
|
563
563
|
def connect
|
564
|
-
@connection =
|
564
|
+
@connection = PG::Connection.connect(@connection_parameters)
|
565
565
|
|
566
566
|
configure_connection
|
567
567
|
rescue ::PG::Error => error
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord5-redshift-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nancy Foen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: pg
|
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
86
|
rubyforge_project:
|
87
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.5.1
|
88
88
|
signing_key:
|
89
89
|
specification_version: 4
|
90
90
|
summary: Amazon Redshift adapter for ActiveRecord
|