pg_saurus 4.0.1 → 4.2.0

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
  SHA256:
3
- metadata.gz: d4621e5c56482cf923810bd206b2449469102f56a92a55acf002d004c5664675
4
- data.tar.gz: 8c5b2e568586c128e7d0a248ef6cdd2b8c1f67e8e02e888fa4f2eee5bcd8adde
3
+ metadata.gz: cc48a831f1ab97b0f56ef559766c5284a92eed10583bd02d31729d7554225016
4
+ data.tar.gz: 9798c1dd0e4caf1b8407f5c2041ffd52d727375bdfa4c03996ee542419164972
5
5
  SHA512:
6
- metadata.gz: f9d730184e0b65c57e7a894abf10d26e2553e5b627d92ed211a9b93a7e3e1e163eb95ef3429ea837509e0d1caa5607efc29655446411b51111f90dddd7d7be59
7
- data.tar.gz: 5256f3a310c2a8d5586477ee0a0f45c208a02b60ab0720632f26bcaf9b0fa428b546fa6b9ff825b2b8fc2d1e872e5939eefbda75036d93f3486b4485d3dbcbc7
6
+ metadata.gz: 0e3bc30b1a68e2cfee33264c903b0d34815eb6c9c26692bd85b8157c01a24f9152f3615af2ea25c4b389b02dc4c9f1553cb9fdd05e34cf221a2efc491c945532
7
+ data.tar.gz: 26fdd30c2a66cd61f18622febd46ceaa4b8d394afcfe66df6161377bf964f03617e8383f7fbcb03526d4fdd27882045270bc19f0d54362cd3c187bc0564563fb
@@ -29,7 +29,7 @@ module ActiveRecord
29
29
  WHERE schemaname = ANY (ARRAY['public'])
30
30
  SQL
31
31
  end
32
-
32
+
33
33
  # Returns an array of indexes for the given table.
34
34
  #
35
35
  # == Patch 1:
@@ -173,6 +173,7 @@ module ActiveRecord
173
173
  statements << index_options if index_options.present?
174
174
 
175
175
  sql = statements.join(' ')
176
+
176
177
  execute(sql)
177
178
  end
178
179
 
@@ -250,7 +251,7 @@ module ActiveRecord
250
251
  column_name, operator_name = split_column_name(name)
251
252
 
252
253
  result_name = if column_name =~ FUNCTIONAL_INDEX_REGEXP
253
- _name = "#{$1}(#{$2}#{quote_column_name($3)})"
254
+ _name = column_name.gsub(/\b#{$3}\b/, quote_column_name($3))
254
255
  _name += " #{operator_name}"
255
256
  _name
256
257
  else
@@ -112,8 +112,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::ExtensionMethods
112
112
  # @return [Hash{String => Hash{Symbol => String}}] A list of loaded extensions with their options
113
113
  def pg_extensions
114
114
  # Check postgresql version to not break on Postgresql < 9.1 during schema dump
115
- pg_version_str = select_value('SELECT version()')
116
- return {} unless pg_version_str =~ /^PostgreSQL (\d+\.\d+.\d+)/ && ($1 >= '9.1')
115
+ return {} if (::PgSaurus::Engine.pg_server_version <=> [9, 1]) < 0
117
116
 
118
117
  sql = <<-SQL
119
118
  SELECT pge.extname AS ext_name, pgn.nspname AS schema_name, pge.extversion AS ext_version
@@ -11,12 +11,13 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
11
11
 
12
12
  # Return a list of defined DB functions. Ignore function definitions that can't be parsed.
13
13
  def functions
14
+ pg_major = ::PgSaurus::Engine.pg_server_version[0]
14
15
  res = select_all <<-SQL
15
16
  SELECT n.nspname AS "Schema",
16
17
  p.proname AS "Name",
17
18
  pg_catalog.pg_get_function_result(p.oid) AS "Returning",
18
19
  CASE
19
- WHEN p.proiswindow THEN 'window'
20
+ WHEN #{pg_major >= 11 ? "p.prokind = 'w'" : "p.proiswindow"} THEN 'window'
20
21
  WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
21
22
  ELSE 'normal'
22
23
  END AS "Type",
@@ -26,7 +27,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
26
27
  WHERE pg_catalog.pg_function_is_visible(p.oid)
27
28
  AND n.nspname <> 'pg_catalog'
28
29
  AND n.nspname <> 'information_schema'
29
- AND p.proisagg <> TRUE
30
+ AND #{pg_major >= 11 ? "p.prokind <> 'a'" : "p.proisagg <> TRUE"}
30
31
  ORDER BY 1, 2, 3, 4;
31
32
  SQL
32
33
  res.inject([]) do |buffer, row|
@@ -2,6 +2,16 @@ module PgSaurus
2
2
  # :nodoc:
3
3
  class Engine < Rails::Engine
4
4
 
5
+ # Postgres server version.
6
+ #
7
+ # @return [Array<Integer>]
8
+ def self.pg_server_version
9
+ @pg_server_version ||=
10
+ ::ActiveRecord::Base.connection.
11
+ select_value('SHOW SERVER_VERSION').
12
+ split('.')[0..1].map(&:to_i)
13
+ end
14
+
5
15
  initializer "pg_saurus" do
6
16
  ActiveSupport.on_load(:active_record) do
7
17
  # load monkey patches
@@ -15,8 +15,8 @@ module PgSaurus::SchemaDumper::ExtensionMethods
15
15
  extensions = @connection.pg_extensions
16
16
  commands = extensions.map do |extension_name, options|
17
17
  result = [%Q|create_extension "#{extension_name}"|]
18
- result << %Q|:schema_name => "#{options[:schema_name]}"| unless options[:schema_name] == 'public'
19
- result << %Q|:version => "#{options[:version]}"|
18
+ result << %Q|schema_name: "#{options[:schema_name]}"| unless options[:schema_name] == 'public'
19
+ result << %Q|version: "#{options[:version]}"|
20
20
  result.join(', ')
21
21
  end
22
22
 
@@ -19,8 +19,10 @@ module PgSaurus
19
19
  #
20
20
  # @return [void]
21
21
  def create_schema_if_not_exists(schema_name)
22
- sql = %{CREATE SCHEMA IF NOT EXISTS "#{schema_name}"}
23
- connection.execute sql
22
+ unless schemas.include?(schema_name.to_s)
23
+ sql = %{CREATE SCHEMA "#{schema_name}"}
24
+ connection.execute sql
25
+ end
24
26
  end
25
27
 
26
28
  # Ensure schema does not exists.
@@ -1,4 +1,4 @@
1
1
  module PgSaurus
2
2
  # Version of pg_saurus gem.
3
- VERSION = "4.0.1"
3
+ VERSION = "4.2.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_saurus
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Potapov Sergey
@@ -10,10 +10,10 @@ authors:
10
10
  - Matt Dressel
11
11
  - Bruce Burdick
12
12
  - HornsAndHooves
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-10-26 00:00:00.000000000 Z
16
+ date: 2021-09-02 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: pg
@@ -29,6 +29,20 @@ dependencies:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
31
  version: '0'
32
+ - !ruby/object:Gem::Dependency
33
+ name: psych
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '3'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - "~>"
44
+ - !ruby/object:Gem::Version
45
+ version: '3'
32
46
  - !ruby/object:Gem::Dependency
33
47
  name: railties
34
48
  requirement: !ruby/object:Gem::Requirement
@@ -205,14 +219,12 @@ email:
205
219
  - cryo28@gmail.com
206
220
  - matt.dressel@gmail.com
207
221
  - rubygems.org@bruceburdick.com
208
- executables:
209
- - rails
222
+ executables: []
210
223
  extensions: []
211
224
  extra_rdoc_files:
212
225
  - README.markdown
213
226
  files:
214
227
  - README.markdown
215
- - bin/rails
216
228
  - lib/colorized_text.rb
217
229
  - lib/core_ext/active_record/connection_adapters/postgresql/column.rb
218
230
  - lib/core_ext/active_record/connection_adapters/postgresql/schema_statements.rb
@@ -272,7 +284,7 @@ homepage: https://github.com/HornsAndHooves/pg_saurus
272
284
  licenses:
273
285
  - MIT
274
286
  metadata: {}
275
- post_install_message:
287
+ post_install_message:
276
288
  rdoc_options: []
277
289
  require_paths:
278
290
  - lib
@@ -287,9 +299,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
299
  - !ruby/object:Gem::Version
288
300
  version: '0'
289
301
  requirements: []
290
- rubyforge_project:
302
+ rubyforge_project:
291
303
  rubygems_version: 2.7.9
292
- signing_key:
304
+ signing_key:
293
305
  specification_version: 4
294
306
  summary: ActiveRecord extensions for PostgreSQL.
295
307
  test_files: []
data/bin/rails DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/pg_saurus/engine', __dir__)
7
- APP_PATH = File.expand_path('../test/dummy/config/application', __dir__)
8
-
9
- # Set up gems listed in the Gemfile.
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
-
13
- require 'rails/all'
14
- require 'rails/engine/commands'