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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 15e9903b9842c231693bf971405eee288676a0f1
4
- data.tar.gz: 285cc1660fb2b723b17f7b2ca33235a66ee25779
3
+ metadata.gz: cb297db4bf6ce61024aa2d6c3eb6150ce3e3e001
4
+ data.tar.gz: 900c0cbe5f25dfbf0678bd061b708464ec2b2273
5
5
  SHA512:
6
- metadata.gz: d89f9dd25564cab7e27b25b5f06669c896bfb6e1e8c1b78765c8c017b6050709f8e7c49f5378310198658423f754c16afc716378c5755407e65d613b5052b0bf
7
- data.tar.gz: aa2c56601b530a92e32cda1f5592a1c9cb59df765124054064769c3d9637cf3349d4248a78d0919a7eb9b6656653f0902dee72c2763bd60e90bc51d2e8c5f22b
6
+ metadata.gz: 3cbc663078dfc995306e13182a7d03d4c20dd8e8ea199e9eabeb2ba557a5d281cce95c4099aefbf899cf239a145073f1e6a710fb4a44f636446cc05f1421f084
7
+ data.tar.gz: 53f651203f8a12dc35062b41bdb22a9f370ef813fe794cb1bb4e2cf25fae449a4dc5d9e87b6fb3bfa323141c3525826553e26f5acf391d1d58a78abe2c0b1f9e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.26
1
+ 0.0.27
@@ -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.26 ruby lib
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.26"
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-02-15"
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 = [
@@ -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
- @db.query("DROP DATABASE #{@db.sep_database}#{@db.escape_database(name)}#{@db.sep_database}")
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
 
@@ -9,7 +9,7 @@ class Baza::InfoActiveRecordMysql2
9
9
  adapter: "mysql2",
10
10
  host: "localhost",
11
11
  database: "baza",
12
- username: "travis"
12
+ username: "build"
13
13
  )
14
14
  @conn = @conn_pool.connection
15
15
 
@@ -9,7 +9,7 @@ class Baza::InfoActiveRecordMysql
9
9
  adapter: "mysql",
10
10
  host: "localhost",
11
11
  database: "baza",
12
- username: "travis"
12
+ username: "build"
13
13
  )
14
14
  @conn ||= @conn_pool.connection
15
15
 
@@ -5,7 +5,7 @@ class Baza::InfoMysql2
5
5
  @db = Baza::Db.new({
6
6
  type: :mysql2,
7
7
  host: "localhost",
8
- user: "travis",
8
+ user: "build",
9
9
  db: "baza"
10
10
  }.merge(args))
11
11
  end
@@ -5,7 +5,7 @@ class Baza::InfoMysql
5
5
  @db = Baza::Db.new({
6
6
  type: :mysql,
7
7
  host: "localhost",
8
- user: "travis",
8
+ user: "build",
9
9
  db: "baza"
10
10
  }.merge(args))
11
11
  end
@@ -30,7 +30,6 @@ shared_examples_for "a baza databases driver" do
30
30
 
31
31
  it "creates tables" do
32
32
  if test_database.table_exists?("test")
33
- puts "DROPPING TEST TABLE"
34
33
  test_database.table("test").drop
35
34
  end
36
35
 
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.26
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-02-15 00:00:00.000000000 Z
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: array_enumerator