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 +4 -4
- data/lib/pg_conn/rdbms_methods.rb +15 -10
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76fdcf256d3aad348c24f37835e191c54c79b2b50a18cb188a4f1617012bd98c
|
|
4
|
+
data.tar.gz: ff82f8edad653121fde93d3742ea5cec1b23d9959a9c01550331a465e4eaa9d3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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|
|
|
87
|
-
.
|
|
88
|
-
conn.exec "drop schema #{schemas} cascade"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
data/lib/pg_conn/version.rb
CHANGED
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
|
|