activerecord5-redshift-adapter 1.0 → 1.0.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
  SHA1:
3
- metadata.gz: 55b959184045064e88bb252f7187099071c8880a
4
- data.tar.gz: 3e5501d98546343c70c3f0f3faecdc83e1127a9b
3
+ metadata.gz: 5d005f91339d55e76d7049742031c13f01e2d6c5
4
+ data.tar.gz: 921290bab163086925bb525c8fc46969449bbdb9
5
5
  SHA512:
6
- metadata.gz: 31f426b79e9f0f535fe3d675ea33c3ab855211fa68fd60ebb8fe9d38d8c43dd0221b016fb23976ef3b278e4b0e75bef2b60a85a43cf512f13f350450d1485c3b
7
- data.tar.gz: 0f820063d56b1a63f2ed71d3f19435ae542968729bd8df7bc6110ccc9c6e14c913ab1ab448917427e3e2a8728f565285df3b27898e389ca82a565c5bf789994f
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
- arel, binds = binds_from_relation arel, binds
49
- sql = to_sql(arel, binds)
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
- arel, binds = binds_from_relation arel, []
57
- sql = to_sql(arel, binds)
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 PGresult object on success
130
- # or raising a PGError exception otherwise.
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
- PGconn.quote_ident(name.to_s)
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
- PGconn.quote_ident(name)
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
- PGconn.quote_ident(schema) << SEPARATOR << PGconn.quote_ident(identifier)
22
+ PG::Connection.quote_ident(schema) << SEPARATOR << PG::Connection.quote_ident(identifier)
23
23
  else
24
- PGconn.quote_ident(identifier)
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 PGconn.connect.
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 PGconn object,
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 == PGconn::CONNECTION_OK
180
- rescue PGError
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 PGError
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(PGresult::PG_DIAG_SQLSTATE)
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 = PGconn.connect(@connection_parameters)
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: '1.0'
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: 2017-06-01 00:00:00.000000000 Z
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.2.2
87
+ rubygems_version: 2.5.1
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Amazon Redshift adapter for ActiveRecord