schema_plus_functions 0.1.0 → 0.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: '09790e6271a884bb4cf768a7f75a25ef2cce002b91b9c2bc066f6992ea340cb0'
4
- data.tar.gz: f87cde834a3236137bbcc1aa0be6f417c186c8d505ef0c6ed421c68fe4224c70
3
+ metadata.gz: 97ddb7cc035fe6b3c6eb8c978dac3eee75e0a5d05777e98276f3ed5ee72c28fe
4
+ data.tar.gz: d82144c01af082317627651336579ed61012787d22886e516c23fc18d85c55e8
5
5
  SHA512:
6
- metadata.gz: 61e40e645fb97bc23908992339eefe32fd99574f6846e4d7cc5d27ab064e9eca14faacb1445901d3e91757a61a27e1ee1a5d34d99ad3e85cf1bf2e3503fdcb60
7
- data.tar.gz: e355ac3b4266adbff2f1d97690e725818d124a8a1f00c9976df23c35a862a51c7df7c72482c4d1be3c456d7fade5f7b742ed7a84c4b01a15d25a5bbab568c9b4
6
+ metadata.gz: 627ccbf5e98a0ac319af3570c6cb6a251ab2b84d619741dd4cf7baa549d66204880a6647bb702f5ea1470b74c01becfb0765b9ede185897399f47004f6f0ed4f
7
+ data.tar.gz: 7a2eb4a75d6cc1167028a83ec49854176846531e8039c59995e2c62d388b0dab1d5f3e2658e72f694aef6149ed19406c18a8b7f8dde76cec3e1a68ac166eb4bb
data/.travis.yml CHANGED
@@ -3,14 +3,36 @@
3
3
  # Please do not edit this file; any changes will be overwritten next time
4
4
  # schema_dev gets run.
5
5
  ---
6
- sudo: false
7
6
  rvm:
8
7
  - 2.3.1
9
8
  gemfile:
10
9
  - gemfiles/activerecord-5.2/Gemfile.postgresql
11
- env: POSTGRESQL_DB_USER=postgres
12
- addons:
13
- postgresql: '9.4'
14
10
  before_script: bundle exec rake create_databases
15
11
  after_script: bundle exec rake drop_databases
16
12
  script: bundle exec rake travis
13
+ jobs:
14
+ include:
15
+ - addons:
16
+ postgresql: '9.6'
17
+ env: POSTGRESQL_DB_USER=postgres
18
+ - addons:
19
+ postgresql: '10'
20
+ apt:
21
+ packages:
22
+ - postgresql-10
23
+ - postgresql-client-10
24
+ env: POSTGRESQL_DB_USER=postgres
25
+ - addons:
26
+ postgresql: '11'
27
+ apt:
28
+ packages:
29
+ - postgresql-11
30
+ - postgresql-client-11
31
+ env: POSTGRESQL_DB_USER=travis PGPORT=5433
32
+ - addons:
33
+ postgresql: '12'
34
+ apt:
35
+ packages:
36
+ - postgresql-12
37
+ - postgresql-client-12
38
+ env: POSTGRESQL_DB_USER=travis PGPORT=5433
data/README.md CHANGED
@@ -91,6 +91,7 @@ SchemaPlus::Functions is tested on:
91
91
 
92
92
  ## History
93
93
 
94
+ * 0.2.0 - Add suppot for PostgreSQL 11+
94
95
  * 0.1.0 - Initial release
95
96
 
96
97
  ## Development & Testing
@@ -9,18 +9,30 @@ module SchemaPlus::Functions
9
9
  super(function_name, clean_params, options)
10
10
  end
11
11
 
12
+ def postgresql_version_at_least?(env, required)
13
+ @postgresql_version ||= begin
14
+ env.connection.select_value("SHOW server_version").match(/(\d+\.\d+)/)[1]
15
+ end
16
+ Gem::Version.new(@postgresql_version) >= Gem::Version.new(required)
17
+ end
18
+
12
19
  def functions(name = nil) #:nodoc:
13
20
  SchemaMonkey::Middleware::Schema::Functions.start(connection: self, query_name: name, functions: []) do |env|
21
+ is_agg_column = if postgresql_version_at_least?(env, '11.0')
22
+ "prokind = 'a'"
23
+ else
24
+ "proisagg"
25
+ end
14
26
  sql = <<-SQL
15
- SELECT P.proname as function_name, pg_get_function_identity_arguments(P.oid), proisagg as is_agg
16
- FROM pg_proc P
17
- WHERE
18
- pronamespace IN (SELECT oid FROM pg_namespace WHERE nspname = ANY (current_schemas(false)))
19
- AND NOT EXISTS (SELECT 1 FROM pg_depend WHERE classid = 'pg_proc'::regclass
20
- AND objid = p.oid AND deptype = 'i')
21
- AND NOT EXISTS (SELECT 1 FROM pg_depend WHERE classid = 'pg_proc'::regclass
22
- AND objid = p.oid AND refclassid = 'pg_extension'::regclass AND deptype = 'e')
23
- ORDER BY 1,2
27
+ SELECT P.proname as function_name, pg_get_function_identity_arguments(P.oid), #{is_agg_column} as is_agg
28
+ FROM pg_proc P
29
+ WHERE
30
+ pronamespace IN (SELECT oid FROM pg_namespace WHERE nspname = ANY (current_schemas(false)))
31
+ AND NOT EXISTS (SELECT 1 FROM pg_depend WHERE classid = 'pg_proc'::regclass
32
+ AND objid = p.oid AND deptype = 'i')
33
+ AND NOT EXISTS (SELECT 1 FROM pg_depend WHERE classid = 'pg_proc'::regclass
34
+ AND objid = p.oid AND refclassid = 'pg_extension'::regclass AND deptype = 'e')
35
+ ORDER BY 1,2
24
36
  SQL
25
37
 
26
38
  env.functions += env.connection.query(sql, env.query_name).map do |row|
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SchemaPlus
4
4
  module Functions
5
- VERSION = "0.1.0"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
data/schema_dev.yml CHANGED
@@ -4,3 +4,5 @@ activerecord:
4
4
  - 5.2
5
5
  db:
6
6
  - postgresql
7
+ dbversions:
8
+ postgresql: ['9.6','10', '11', '12']
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  gem.add_development_dependency "bundler"
26
26
  gem.add_development_dependency "rake", "~> 10.0"
27
27
  gem.add_development_dependency "rspec", "~> 3.0"
28
- gem.add_development_dependency "schema_dev", "~> 3.11", ">= 3.11.1"
28
+ gem.add_development_dependency "schema_dev", "~> 3.12"
29
29
  gem.add_development_dependency "simplecov"
30
30
  gem.add_development_dependency "simplecov-gem-profile"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_functions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edward Rudd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -92,20 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '3.11'
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: 3.11.1
95
+ version: '3.12'
99
96
  type: :development
100
97
  prerelease: false
101
98
  version_requirements: !ruby/object:Gem::Requirement
102
99
  requirements:
103
100
  - - "~>"
104
101
  - !ruby/object:Gem::Version
105
- version: '3.11'
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: 3.11.1
102
+ version: '3.12'
109
103
  - !ruby/object:Gem::Dependency
110
104
  name: simplecov
111
105
  requirement: !ruby/object:Gem::Requirement
@@ -181,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
175
  - !ruby/object:Gem::Version
182
176
  version: '0'
183
177
  requirements: []
184
- rubygems_version: 3.0.6
178
+ rubygems_version: 3.0.8
185
179
  signing_key:
186
180
  specification_version: 4
187
181
  summary: Adds support for functions in ActiveRecord