spectacles 0.5.1 → 0.5.2

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: 2e52e394df12083b7bf0f9c1a11d7bd0c289cf31
4
- data.tar.gz: f9e492ffaf04763f7b0426a5f02e4bb3a411f3af
3
+ metadata.gz: 6bff68ef734659627597aa1deae49e6357b55a1a
4
+ data.tar.gz: 9562fb0f911b796007471e34520a8c29a960e943
5
5
  SHA512:
6
- metadata.gz: 639f04580f920782af8dea089d4e2d174c23283c3c808813e0ed0950b1b86ac28483c398e22f07dd1030ac5b0342d4de13502fd0258d8bbd02df94ee0cd149e2
7
- data.tar.gz: 54591a3d0620f44d364adcac8d21eac4075ba0382e9780acbaa5db30e2f4e5499b9673fa11420ddb4ff457951119883c071ff075d27e1358db7a4a59a55858b9
6
+ metadata.gz: 4195cc3601e942d02ef38564c16b7ac0bacfff12ea6559165b4b673b90cfb230679a9a88bc9db941260d4f8c28d422912ece536a97b71c760783d0f0f977cfc2
7
+ data.tar.gz: 51e088f02be3e2a436956339d340376fefb379e4a3164a7c07b24f94a484c39a1d89d9b09016e6ede1a853619bd7d8362d7388243bb49a4a6d0a1862a75c0589
@@ -4,7 +4,7 @@ module Spectacles
4
4
  module SchemaStatements
5
5
  module PostgreSQLAdapter
6
6
  include Spectacles::SchemaStatements::AbstractAdapter
7
-
7
+
8
8
  def views(name = nil) #:nodoc:
9
9
  q = <<-SQL
10
10
  SELECT table_name, table_type
@@ -12,22 +12,23 @@ module Spectacles
12
12
  WHERE table_schema IN (#{schemas})
13
13
  AND table_type = 'VIEW'
14
14
  SQL
15
-
15
+
16
16
  execute(q, name).map { |row| row['table_name'] }
17
17
  end
18
18
 
19
19
  def view_build_query(view, name = nil)
20
20
  q = <<-SQL
21
21
  SELECT view_definition
22
- FROM information_schema.views
22
+ FROM information_schema.views
23
23
  WHERE table_catalog = (SELECT catalog_name FROM information_schema.information_schema_catalog_name)
24
24
  AND table_schema IN (#{schemas})
25
25
  AND table_name = '#{view}'
26
26
  SQL
27
-
28
- select_value(q, name) or raise "No view called #{view} found"
27
+
28
+ view_sql = select_value(q, name) or raise "No view called #{view} found"
29
+ view_sql.gsub("\"", "\\\"")
29
30
  end
30
-
31
+
31
32
  private
32
33
  def schemas
33
34
  schema_search_path.split(/,/).map { |p| quote(p) }.join(',')
@@ -1,3 +1,3 @@
1
1
  module Spectacles
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -14,4 +14,16 @@ describe "Spectacles::SchemaStatements::PostgreSQLAdapter" do
14
14
 
15
15
  it_behaves_like "an adapter", "PostgreSQLAdapter"
16
16
  it_behaves_like "a view model"
17
+
18
+ describe "#view_build_query" do
19
+ test_base = Class.new do
20
+ extend Spectacles::SchemaStatements::PostgreSQLAdapter
21
+ def self.schema_search_path; ""; end
22
+ def self.select_value(_, _); "\"products\""; end;
23
+ end
24
+
25
+ it "should escape double-quotes returned by Postgres" do
26
+ test_base.view_build_query(:new_product_users).must_match(/\\"/)
27
+ end
28
+ end
17
29
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spectacles
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hutchison, Brandon Dewitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 3.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 3.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Spectacles adds database view functionality to ActiveRecord. Current
@@ -74,7 +74,7 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - Gemfile
79
79
  - LICENSE
80
80
  - Rakefile
@@ -117,17 +117,17 @@ require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '>='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.1.11
130
+ rubygems_version: 2.4.3
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Spectacles (derived from RailsSQLViews) adds database view functionality