pg_conn 0.56.1 → 0.57.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
  SHA256:
3
- metadata.gz: 26dbcd85db043fdf28c698606f7f35450d77bf0cbafb63324d62297724a4698f
4
- data.tar.gz: 59444453e3ca2b4c6244d356696264f7caef6f20038549edc33ad085e9339f08
3
+ metadata.gz: 76fdcf256d3aad348c24f37835e191c54c79b2b50a18cb188a4f1617012bd98c
4
+ data.tar.gz: ff82f8edad653121fde93d3742ea5cec1b23d9959a9c01550331a465e4eaa9d3
5
5
  SHA512:
6
- metadata.gz: 5fddf126010d3cd13cefbbb8bf1a94402cee13987c967e17e346b32db9c02044c1e035ddd0f69d0c2a1fd91cdfedf8e0cbbf8da556c1c1588c6bb8bb5e28092c
7
- data.tar.gz: aa082a3881474398e3c17c19bd219801f65596470b69d7046217d43093a511c06ef436e5f13189a602d97ca3ab3657d68582c4a53338f38b5f05810f126921d7
6
+ metadata.gz: 0ba5bb473f0483b9df83d657b061f57b8afd43f69372e81f02e88564b0eaa5af3aa0924e2500294f5ff9f77b798fef9000be924c383d50d8bc3c3e8f6261f69f
7
+ data.tar.gz: 127c0070c97925da62ee3dbc2251da49c7185fb07ac39f96bc4a80f6b477a7e438bcee5e8c07402a6b8e4beb781d3059bdf1f01ddaa80a4944dd6e160417face
@@ -72,26 +72,31 @@ module PgConn
72
72
  # schema is recreated afterwards unless :public is false. Uses the current
73
73
  # database if @database is nil
74
74
  #
75
+ # :include lists schemas to drop, the default is every schema. :exclude
76
+ # lists schemas to keep, the default is to drop all schemas
77
+ #
75
78
  # Note that the database can have active users logged in while the database
76
79
  # is emptied. TODO Explain what happens if the users have active
77
80
  # transactions. Should the be terminated?
78
81
  #
79
- def empty!(database = nil, public: true, exclude: [])
82
+ def empty!(database = nil, public: true, include: [], exclude: [])
80
83
  local = !database.nil?
81
84
  begin
82
85
  conn = local ? PgConn.new(database) : self.conn
83
86
  schemas =
84
87
  conn
85
88
  .values("select nspname from pg_namespace where nspowner != 10 or nspname = 'public'")
86
- .select { |schema| !exclude.include?(schema) }
87
- .join(", ")
88
- conn.exec "drop schema #{schemas} cascade"
89
-
90
- # FIXME FIXME FIXME SECURITY Why grant 'create' to public?
91
- conn.exec %(
92
- create schema public authorization postgres;
93
- grant usage, create on schema public to public
94
- ) if public
89
+ .select { |schema| include.empty? || include.include?(schema) }
90
+ .reject { |schema| exclude.include?(schema) }
91
+ conn.exec "drop schema #{schemas.join(", ")} cascade"
92
+
93
+ if public && schemas.include?("public")
94
+ # FIXME FIXME FIXME SECURITY Why grant 'create' to public?
95
+ conn.exec %(
96
+ create schema public authorization postgres;
97
+ grant usage, create on schema public to public
98
+ )
99
+ end
95
100
  ensure
96
101
  conn&.terminate if local
97
102
  end
@@ -1,3 +1,3 @@
1
1
  module PgConn
2
- VERSION = "0.56.1"
2
+ VERSION = "0.57.0"
3
3
  end
data/lib/pg_conn.rb CHANGED
@@ -157,7 +157,7 @@ module PgConn
157
157
 
158
158
  # Name of database
159
159
  def name() @pg_connection.db end
160
- alias_method :database, :name # Obsolete FIXME Is it?
160
+ alias_method :database, :name # Obsolete FIXME Is it? No
161
161
 
162
162
  # Database manipulation methods: #exist?, #create, #drop, #list
163
163
  attr_reader :rdbms
@@ -1291,6 +1291,7 @@ module PgConn
1291
1291
  def commit() pop_transaction(fail: false) end
1292
1292
  def rollback() pop_transaction(commit: false, fail: false) end
1293
1293
 
1294
+ # FIXME: Columns with the same name are collapsed
1294
1295
  def dump(*query)
1295
1296
  records = self.records(*query)
1296
1297
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_conn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.56.1
4
+ version: 0.57.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen