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 +4 -4
- data/.travis.yml +26 -4
- data/README.md +1 -0
- data/lib/schema_plus/functions/active_record/connection_adapters/postgresql_adapter.rb +21 -9
- data/lib/schema_plus/functions/version.rb +1 -1
- data/schema_dev.yml +2 -0
- data/schema_plus_functions.gemspec +1 -1
- metadata +5 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ddb7cc035fe6b3c6eb8c978dac3eee75e0a5d05777e98276f3ed5ee72c28fe
|
4
|
+
data.tar.gz: d82144c01af082317627651336579ed61012787d22886e516c23fc18d85c55e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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|
|
data/schema_dev.yml
CHANGED
@@ -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.
|
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.
|
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:
|
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.
|
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.
|
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.
|
178
|
+
rubygems_version: 3.0.8
|
185
179
|
signing_key:
|
186
180
|
specification_version: 4
|
187
181
|
summary: Adds support for functions in ActiveRecord
|