baza 0.0.26 → 0.0.27
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/VERSION +1 -1
- data/baza.gemspec +3 -3
- data/lib/baza/db.rb +0 -19
- data/lib/baza/driver/pg/database.rb +12 -1
- data/spec/info_active_record_mysql2_travis.rb +1 -1
- data/spec/info_active_record_mysql_travis.rb +1 -1
- data/spec/info_mysql2_travis.rb +1 -1
- data/spec/info_mysql_travis.rb +1 -1
- data/spec/support/driver_databases_collection.rb +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb297db4bf6ce61024aa2d6c3eb6150ce3e3e001
|
4
|
+
data.tar.gz: 900c0cbe5f25dfbf0678bd061b708464ec2b2273
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cbc663078dfc995306e13182a7d03d4c20dd8e8ea199e9eabeb2ba557a5d281cce95c4099aefbf899cf239a145073f1e6a710fb4a44f636446cc05f1421f084
|
7
|
+
data.tar.gz: 53f651203f8a12dc35062b41bdb22a9f370ef813fe794cb1bb4e2cf25fae449a4dc5d9e87b6fb3bfa323141c3525826553e26f5acf391d1d58a78abe2c0b1f9e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.27
|
data/baza.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: baza 0.0.
|
5
|
+
# stub: baza 0.0.27 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "baza".freeze
|
9
|
-
s.version = "0.0.
|
9
|
+
s.version = "0.0.27"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Kasper Johansen".freeze]
|
14
|
-
s.date = "2017-
|
14
|
+
s.date = "2017-03-19"
|
15
15
|
s.description = "A database abstraction layer, model framework and database framework.".freeze
|
16
16
|
s.email = "kj@gfish.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
data/lib/baza/db.rb
CHANGED
@@ -348,25 +348,6 @@ class Baza::Db
|
|
348
348
|
ret
|
349
349
|
end
|
350
350
|
|
351
|
-
# Clones the connection, executes the given block and closes the connection again.
|
352
|
-
#
|
353
|
-
#===Examples
|
354
|
-
# db.cloned_conn do |conn|
|
355
|
-
# conn.q('SELCET * FROM users') do |data|
|
356
|
-
# print data[:name]
|
357
|
-
# end
|
358
|
-
# end
|
359
|
-
def cloned_conn(args = nil, &_block)
|
360
|
-
clone_conn_args = args[:clone_args] || {}
|
361
|
-
dbconn = clone_conn(clone_conn_args)
|
362
|
-
|
363
|
-
begin
|
364
|
-
yield(dbconn)
|
365
|
-
ensure
|
366
|
-
dbconn.close
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
351
|
# Yields a query-buffer and flushes at the end of the block given.
|
371
352
|
def q_buffer(args = {}, &block)
|
372
353
|
Baza::QueryBuffer.new(args.merge(db: self), &block)
|
@@ -5,7 +5,18 @@ class Baza::Driver::Pg::Database < Baza::Database
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def drop
|
8
|
-
|
8
|
+
other_db = @db.databases.list.find { |database| database.name != @db.current_database }
|
9
|
+
|
10
|
+
# Drop database through a cloned connection, because Postgres might bug up if dropping the current
|
11
|
+
@db.clone_conn(db: other_db.name) do |cloned_conn|
|
12
|
+
# Close existing connections to avoid 'is being accessed by other users' errors
|
13
|
+
cloned_conn.query("REVOKE CONNECT ON DATABASE #{@db.sep_database}#{@db.escape_database(name)}#{@db.sep_database} FROM public")
|
14
|
+
cloned_conn.query("SELECT pid, pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = #{@db.sep_val}#{@db.esc(name)}#{@db.sep_val} AND pid != pg_backend_pid()")
|
15
|
+
|
16
|
+
# Drop the database
|
17
|
+
cloned_conn.query("DROP DATABASE #{@db.sep_database}#{@db.escape_database(name)}#{@db.sep_database}")
|
18
|
+
end
|
19
|
+
|
9
20
|
self
|
10
21
|
end
|
11
22
|
|
data/spec/info_mysql2_travis.rb
CHANGED
data/spec/info_mysql_travis.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: baza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kasper Johansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: array_enumerator
|