scenic 1.1.0 → 1.1.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 +4 -4
- data/NEWS.md +9 -0
- data/README.md +8 -5
- data/lib/scenic/adapters/postgres.rb +9 -5
- data/lib/scenic/version.rb +1 -1
- data/spec/scenic/adapters/postgres_spec.rb +8 -4
- 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: b88bfc7421d9fff9dabb78192437422bff78a008
|
4
|
+
data.tar.gz: 707fd7687db5ad21240ee8d3f0b8eafa16db4b01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
**
|
154
|
+
**Why do I get an error when querying a view-backed model with `find`, `last`, or `first`?**
|
155
155
|
|
156
|
-
|
157
|
-
|
158
|
-
|
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 = :
|
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
|
31
|
-
#
|
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(
|
38
|
-
@
|
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 :
|
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
|
data/lib/scenic/version.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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.
|
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
|