pg_saurus 2.4.2 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7f0e180c96a321a71e1aa1757983a687772b225
4
- data.tar.gz: 0a51ad8063f1f64470a1dbe30946d9dd915f5519
3
+ metadata.gz: 5433ba8f207d15cff07d3cd6c440c098152154fa
4
+ data.tar.gz: 82cd35bd54a2ff59cd79208b80a39a90a58003ba
5
5
  SHA512:
6
- metadata.gz: 2ee54173853996fac5017ead346c9c42cd991d717905abc1f1d5c8c44d2d1b2b3f0e13d80d8f16ca198a312d63f57ddcdf3f8f48bc2ad6ac9292126606407805
7
- data.tar.gz: 9ce8e72c2e41bf90bc5e17a435f2f007a1d039e6682fd23bcfd629bb9387cbf53b477a827a8e7b583b9afc9a47057b18f3104326ad6faf58ca6219e8519814b5
6
+ metadata.gz: 2c38ecb6c9e1e7af4d1eae3fa6ebf8ad024279525b2f63b75e91983ff72bb521917564f2bbd762071250c769bf88e13c9ac9c07e86bee284ffe18383e8724eee
7
+ data.tar.gz: eb9a89878a34a398ce99f6648362bfd12835e1c82869f73ca001b19f8bc916ccca84b453e8d32ad18ac876701d43e461df3af4b1dfba326a91bd2273f91cddad
@@ -28,5 +28,6 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter
28
28
  included do
29
29
  alias_method_chain :tables, :non_public_schema_tables
30
30
  alias_method_chain :add_index, :concurrently
31
+ alias_method_chain :rename_table, :schema_option
31
32
  end
32
33
  end
@@ -14,10 +14,8 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
14
14
  p.proname AS "Name",
15
15
  pg_catalog.pg_get_function_result(p.oid) AS "Returning",
16
16
  CASE
17
- WHEN p.proisagg THEN 'agg'
18
- WHEN p.proiswindow THEN 'window'
19
- WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype
20
- THEN 'trigger'
17
+ WHEN p.proiswindow THEN 'window'
18
+ WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
21
19
  ELSE 'normal'
22
20
  END AS "Type",
23
21
  p.oid AS "Oid"
@@ -26,6 +24,7 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::FunctionMethods
26
24
  WHERE pg_catalog.pg_function_is_visible(p.oid)
27
25
  AND n.nspname <> 'pg_catalog'
28
26
  AND n.nspname <> 'information_schema'
27
+ AND p.proisagg <> TRUE
29
28
  ORDER BY 1, 2, 3, 4;
30
29
  SQL
31
30
  res.inject([]) do |buffer, row|
@@ -55,4 +55,34 @@ module PgSaurus::ConnectionAdapters::PostgreSQLAdapter::SchemaMethods
55
55
 
56
56
  public_tables + non_public_tables
57
57
  end
58
+
59
+ # Provide :schema option to +rename_table+ method.
60
+ def rename_table_with_schema_option(table_name, new_name, options = {})
61
+ schema_name = options[:schema]
62
+ if schema_name
63
+ in_schema schema_name do
64
+ rename_table_without_schema_option(table_name, new_name)
65
+ end
66
+ else
67
+ rename_table_without_schema_option(table_name, new_name)
68
+ end
69
+ end
70
+
71
+ # Execute operations in the context of the schema
72
+ def in_schema(schema_name)
73
+ search_path = current_schema_search_path
74
+ begin
75
+ execute("SET search_path TO '%s'" % schema_name)
76
+ yield
77
+ ensure
78
+ execute("SET search_path TO #{search_path};")
79
+ end
80
+ end
81
+
82
+ # Reads the current schema search path (it may have been altered
83
+ # from the initial value used when creating the connection)
84
+ def current_schema_search_path
85
+ select_value("SHOW search_path;")
86
+ end
87
+
58
88
  end
@@ -1,4 +1,4 @@
1
1
  module PgSaurus
2
2
  # Version of pg_saurus gem.
3
- VERSION = "2.4.2"
3
+ VERSION = "2.5.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: 2.4.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Potapov Sergey