pg_saurus 4.0.2 → 4.3.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: 20e72495c2fa2ffdc422bfeefac5c196c888685cf98ed513dc94da2608476572
4
- data.tar.gz: '0366790a931f6ebb4283f80d1112588de221d3844968eaedeeb059c4443124ec'
3
+ metadata.gz: d0658a18dcaee8fd3acbe9334daf053e0a22568157b53d1b182add67970dd799
4
+ data.tar.gz: 87468b4dca614127ebdea002e67d92e610c3d0057ede82dc4d6a18dd90d60c18
5
5
  SHA512:
6
- metadata.gz: 149f1cd2738b90d36cc52900af989fed800064b28242e0de3aadb50eff7c3316c240d2696f01de3c6b14d395e2202a68427bb8ff6ab76b673f29f15c8f1cd78a
7
- data.tar.gz: 489cda1e93255d713f7fa6c479b738c436ec74fb7591358d7a02c6e3acd0693adcf0e6d63630000299a46ae375f65fd48c2e841cff757eed29cc74e03a664202
6
+ metadata.gz: f9305018ca8cf965346683abcf7296a3459f2d81d9887829c75f3eb26aa3a0f5341af4c58b0c0459e9fb679481bf3c778f94ba981c8676d0c52dfe36d84f1802
7
+ data.tar.gz: 41a869cf2aa17cde12b29f684ec39c9d89862c11c9dd1f909d39cbaa3ae29163f634d1ec5070d27c60bb7cc4281ba0e1b30da8bffb81b09538a847260d2463a2
@@ -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|
@@ -95,7 +95,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TriggerMethods
95
95
 
96
96
  # Parse the condition from the trigger definition.
97
97
  def parse_condition(trigger_definition)
98
- trigger_definition[/WHEN[\s](.*?)[\s]EXECUTE[\s]PROCEDURE/m, 1]
98
+ trigger_definition[/WHEN[\s](.*?)[\s]EXECUTE[\s](FUNCTION|PROCEDURE)/m, 1]
99
99
  end
100
100
  private :parse_condition
101
101
 
@@ -107,7 +107,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::TriggerMethods
107
107
 
108
108
  # Parse the procedure name from the trigger definition.
109
109
  def parse_proc_name(trigger_definition)
110
- trigger_definition[/EXECUTE[\s]PROCEDURE[\s](.*?)$/m,1]
110
+ trigger_definition[/EXECUTE[\s](FUNCTION|PROCEDURE)[\s](.*?)$/m, 2]
111
111
  end
112
112
  private :parse_proc_name
113
113
 
@@ -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
 
@@ -1,4 +1,4 @@
1
1
  module PgSaurus
2
2
  # Version of pg_saurus gem.
3
- VERSION = "4.0.2"
3
+ VERSION = "4.3.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.2
4
+ version: 4.3.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-11-16 00:00:00.000000000 Z
16
+ date: 2021-09-22 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,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
299
  - !ruby/object:Gem::Version
288
300
  version: '0'
289
301
  requirements: []
290
- rubyforge_project:
291
- rubygems_version: 2.7.9
292
- signing_key:
302
+ rubygems_version: 3.0.9
303
+ signing_key:
293
304
  specification_version: 4
294
305
  summary: ActiveRecord extensions for PostgreSQL.
295
306
  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'