scenic 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d42b1d2b3e1f8fd304e1f6ba852a0cc54b6727b6
4
- data.tar.gz: 3a84ebfd4b1a34ad03a68f232961c6381107cd74
3
+ metadata.gz: b88bfc7421d9fff9dabb78192437422bff78a008
4
+ data.tar.gz: 707fd7687db5ad21240ee8d3f0b8eafa16db4b01
5
5
  SHA512:
6
- metadata.gz: e67ff566304f93fd0c70a6c4968d2551ea9a82c3111f9f8a95f4b1dbc4e43a3f7233d9b71fc0551b8ffd806f78c5967bbd43d7b0a3783a80cc1da68b99edd041
7
- data.tar.gz: 8b19e9f8e3e93142a57c15ec0f191abeab1278395bb6a09fc9face3908e8039a58cc1704d32cbecb834f966f355a6b98256ed8d2ba0727e4209efe6c83cb52e9
6
+ metadata.gz: d1dc5196a72602f964093cbbd1b2976de5d31d73f887e8d21b8938262b6b15cffdc8e536073a482cb988da653d022be850f052727bc62d932738676d4ca42a4a
7
+ data.tar.gz: 0ef40094617d1adde567078bc066887afb92ae3102925358450a05bd3a4beafd05f7d116929ccbcc25577337bdcdb437abf92cd5bd4a9855ef2b47f0daf28333
data/NEWS.md CHANGED
@@ -5,6 +5,15 @@ changelog, see the [CHANGELOG] for each version via the version links.
5
5
 
6
6
  [CHANGELOG]: https://github.com/thoughtbot/scenic/commits/master
7
7
 
8
+ ## [1.1.1] - January 29, 2016
9
+
10
+ ### Fixed
11
+ - Some schema operations were failing with a `PG::ConnectionBad: connection is
12
+ closed` error. This has been fixed by ensuring we grab a fresh connection for
13
+ all operations.
14
+
15
+ [1.1.1]: https://github.com/thoughtbot/scenic/compare/v1.1.0...v1.1.1
16
+
8
17
  ## [1.1.0] - January 8, 2016
9
18
 
10
19
  ### Added
data/README.md CHANGED
@@ -151,15 +151,18 @@ end
151
151
 
152
152
  ## FAQs
153
153
 
154
- **When I query a view-backed model with `find` I get an error. What gives?**
154
+ **Why do I get an error when querying a view-backed model with `find`, `last`, or `first`?**
155
155
 
156
- Your view cannot have a primary key, but ActiveRecord's `find` method expects to
157
- query based on one. You can use `find_by!` or you can explicitly set the primary
158
- key column on your model like so:
156
+ ActiveRecord's `find` method expects to query based on your model's primary key,
157
+ but views do not have primary keys. Additionally, the `first` and `last` methods
158
+ will produce queries that attempt to sort based on the primary key.
159
+
160
+ You can get around these issues by setting the primary key column on your Rails
161
+ model like so:
159
162
 
160
163
  ```ruby
161
164
  class People < ActiveRecord::Base
162
- self.primary_key = :id
165
+ self.primary_key = :my_unique_identifier_field
163
166
  end
164
167
  ```
165
168
 
@@ -27,15 +27,15 @@ module Scenic
27
27
  # {Scenic.configure} is not required, but the example below shows how one
28
28
  # would explicitly set it.
29
29
  #
30
- # @param connection The database connection the adapter should use. This
31
- # defaults to `ActiveRecord::Base.connection`
30
+ # @param [#connection] connectable An object that returns the connection
31
+ # for Scenic to use. Defaults to `ActiveRecord::Base`.
32
32
  #
33
33
  # @example
34
34
  # Scenic.configure do |config|
35
35
  # config.adapter = Scenic::Adapters::Postgres.new
36
36
  # end
37
- def initialize(connection = ActiveRecord::Base.connection)
38
- @connection = Connection.new(connection)
37
+ def initialize(connectable = ActiveRecord::Base)
38
+ @connectable = connectable
39
39
  end
40
40
 
41
41
  # Returns an array of views in the database.
@@ -183,9 +183,13 @@ module Scenic
183
183
 
184
184
  private
185
185
 
186
- attr_reader :connection
186
+ attr_reader :connectable
187
187
  delegate :execute, :quote_table_name, to: :connection
188
188
 
189
+ def connection
190
+ Connection.new(connectable.connection)
191
+ end
192
+
189
193
  def raise_unless_materialized_views_supported
190
194
  unless connection.supports_materialized_views?
191
195
  raise MaterializedViewsNotSupportedError
@@ -1,3 +1,3 @@
1
1
  module Scenic
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -29,7 +29,8 @@ module Scenic
29
29
 
30
30
  it "raises an exception if the version of PostgreSQL is too old" do
31
31
  connection = double("Connection", supports_materialized_views?: false)
32
- adapter = Postgres.new(connection)
32
+ connectable = double("Connectable", connection: connection)
33
+ adapter = Postgres.new(connectable)
33
34
  err = Scenic::Adapters::Postgres::MaterializedViewsNotSupportedError
34
35
 
35
36
  expect { adapter.create_materialized_view("greetings", "select 1") }
@@ -63,7 +64,8 @@ module Scenic
63
64
 
64
65
  it "raises an exception if the version of PostgreSQL is too old" do
65
66
  connection = double("Connection", supports_materialized_views?: false)
66
- adapter = Postgres.new(connection)
67
+ connectable = double("Connectable", connection: connection)
68
+ adapter = Postgres.new(connectable)
67
69
  err = Scenic::Adapters::Postgres::MaterializedViewsNotSupportedError
68
70
 
69
71
  expect { adapter.drop_materialized_view("greetings") }
@@ -74,7 +76,8 @@ module Scenic
74
76
  describe "#refresh_materialized_view" do
75
77
  it "raises an exception if the version of PostgreSQL is too old" do
76
78
  connection = double("Connection", supports_materialized_views?: false)
77
- adapter = Postgres.new(connection)
79
+ connectable = double("Connectable", connection: connection)
80
+ adapter = Postgres.new(connectable)
78
81
  err = Scenic::Adapters::Postgres::MaterializedViewsNotSupportedError
79
82
 
80
83
  expect { adapter.refresh_materialized_view(:tests) }
@@ -93,7 +96,8 @@ module Scenic
93
96
 
94
97
  it "raises an exception if the version of PostgreSQL is too old" do
95
98
  connection = double("Connection", postgresql_version: 90300)
96
- adapter = Postgres.new(connection)
99
+ connectable = double("Connectable", connection: connection)
100
+ adapter = Postgres.new(connectable)
97
101
  e = Scenic::Adapters::Postgres::ConcurrentRefreshesNotSupportedError
98
102
 
99
103
  expect {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scenic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Prior
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-20 00:00:00.000000000 Z
12
+ date: 2016-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -282,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
282
  version: '0'
283
283
  requirements: []
284
284
  rubyforge_project:
285
- rubygems_version: 2.5.1
285
+ rubygems_version: 2.4.8
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: Support for database views in Rails migrations