baza 0.0.38 → 0.0.39

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -14
  3. data/lib/baza/database.rb +1 -1
  4. data/lib/baza/db.rb +5 -4
  5. data/lib/baza/driver/active_record/columns.rb +2 -2
  6. data/lib/baza/driver/active_record/commands.rb +2 -2
  7. data/lib/baza/driver/active_record/databases.rb +2 -2
  8. data/lib/baza/driver/active_record/foreign_keys.rb +13 -0
  9. data/lib/baza/driver/active_record/indexes.rb +2 -2
  10. data/lib/baza/driver/active_record/tables.rb +3 -3
  11. data/lib/baza/driver/active_record/users.rb +2 -2
  12. data/lib/baza/driver/active_record.rb +3 -1
  13. data/lib/baza/driver/mysql/columns.rb +1 -1
  14. data/lib/baza/driver/mysql/database.rb +11 -38
  15. data/lib/baza/driver/mysql/foreign_key.rb +2 -0
  16. data/lib/baza/driver/mysql/foreign_keys.rb +13 -0
  17. data/lib/baza/driver/mysql/sql/column.rb +3 -2
  18. data/lib/baza/driver/mysql/sql/create_table.rb +11 -0
  19. data/lib/baza/driver/mysql/table.rb +43 -4
  20. data/lib/baza/driver/mysql/tables.rb +22 -9
  21. data/lib/baza/driver/mysql2/foreign_keys.rb +2 -0
  22. data/lib/baza/driver/mysql2.rb +6 -5
  23. data/lib/baza/driver/mysql_java.rb +2 -2
  24. data/lib/baza/driver/pg/columns.rb +1 -1
  25. data/lib/baza/driver/pg/create_index_sql_creator.rb +2 -5
  26. data/lib/baza/driver/pg/database.rb +2 -2
  27. data/lib/baza/driver/pg/foreign_key.rb +2 -0
  28. data/lib/baza/driver/pg/foreign_keys.rb +13 -0
  29. data/lib/baza/driver/pg/result.rb +5 -1
  30. data/lib/baza/driver/pg/table.rb +43 -0
  31. data/lib/baza/driver/pg/tables.rb +20 -13
  32. data/lib/baza/driver/sqlite3/columns.rb +1 -1
  33. data/lib/baza/driver/sqlite3/foreign_key.rb +14 -0
  34. data/lib/baza/driver/sqlite3/foreign_keys.rb +11 -0
  35. data/lib/baza/driver/sqlite3/table.rb +41 -6
  36. data/lib/baza/driver/sqlite3/tables.rb +15 -14
  37. data/lib/baza/driver/sqlite3.rb +1 -1
  38. data/lib/baza/driver/sqlite3_java.rb +1 -1
  39. data/lib/baza/driver/sqlite3_rhodes.rb +1 -1
  40. data/lib/baza/dump.rb +3 -2
  41. data/lib/baza/foreign_key.rb +1 -1
  42. data/lib/baza/jdbc_driver.rb +1 -1
  43. data/lib/baza/mysql_base_driver.rb +1 -1
  44. data/lib/baza/query_buffer.rb +36 -6
  45. data/lib/baza/result_base.rb +2 -5
  46. data/lib/baza/tables.rb +1 -1
  47. metadata +26 -269
  48. data/.document +0 -5
  49. data/.github/dependabot.yml +0 -13
  50. data/.rspec +0 -1
  51. data/.rubocop.yml +0 -84
  52. data/.rubocop_todo.yml +0 -39
  53. data/.ruby-version +0 -1
  54. data/Gemfile +0 -32
  55. data/Gemfile.lock +0 -164
  56. data/VERSION +0 -1
  57. data/baza.gemspec +0 -264
  58. data/config/best_project_practice_rubocop.yml +0 -10
  59. data/config/best_project_practice_rubocop_todo.yml +0 -163
  60. data/peak_flow.yml +0 -31
  61. data/spec/active_record/models/user.rb +0 -3
  62. data/spec/baza/cloner_spec.rb +0 -10
  63. data/spec/baza/sql_queries/generic_insert_spec.rb +0 -26
  64. data/spec/baza/sql_queries/select_spec.rb +0 -38
  65. data/spec/drivers/active_record_mysql2_spec.rb +0 -22
  66. data/spec/drivers/active_record_mysql_spec.rb +0 -19
  67. data/spec/drivers/active_record_pg_spec.rb +0 -22
  68. data/spec/drivers/active_record_sqlite3_spec.rb +0 -18
  69. data/spec/drivers/mysql2_spec.rb +0 -19
  70. data/spec/drivers/mysql_spec.rb +0 -58
  71. data/spec/drivers/pg/columns_spec.rb +0 -45
  72. data/spec/drivers/pg/table_spec.rb +0 -20
  73. data/spec/drivers/pg_spec.rb +0 -20
  74. data/spec/drivers/sqlite3_spec.rb +0 -67
  75. data/spec/drivers/tiny_spec.rb +0 -27
  76. data/spec/info_active_record_example.rb +0 -35
  77. data/spec/info_active_record_mysql2_example.rb +0 -36
  78. data/spec/info_active_record_mysql2_peak_flow.rb +0 -36
  79. data/spec/info_active_record_mysql_example.rb +0 -37
  80. data/spec/info_active_record_mysql_peak_flow.rb +0 -37
  81. data/spec/info_active_record_pg_example.rb +0 -36
  82. data/spec/info_active_record_pg_peak_flow.rb +0 -36
  83. data/spec/info_active_record_sqlite3.rb +0 -29
  84. data/spec/info_mysql2_example.rb +0 -21
  85. data/spec/info_mysql2_peak_flow.rb +0 -21
  86. data/spec/info_mysql_example.rb +0 -21
  87. data/spec/info_mysql_peak_flow.rb +0 -21
  88. data/spec/info_pg_example.rb +0 -22
  89. data/spec/info_pg_peak_flow.rb +0 -22
  90. data/spec/info_sqlite3.rb +0 -19
  91. data/spec/spec_helper.rb +0 -18
  92. data/spec/support/driver_active_record_collection.rb +0 -62
  93. data/spec/support/driver_collection.rb +0 -396
  94. data/spec/support/driver_columns_collection.rb +0 -64
  95. data/spec/support/driver_databases_collection.rb +0 -48
  96. data/spec/support/driver_foreign_keys_collection.rb +0 -54
  97. data/spec/support/driver_importer_collection.rb +0 -38
  98. data/spec/support/driver_indexes_collection.rb +0 -66
  99. data/spec/support/driver_tables_collection.rb +0 -116
  100. data/spec/support/driver_users_collection.rb +0 -53
@@ -1,38 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::SqlQueries::Select do
4
- let(:constant) do
5
- const_name = "InfoPg"
6
- require StringCases.camel_to_snake(const_name)
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
- let(:db) { constant.new.db }
11
-
12
- before do
13
- db.tables[:test].drop if db.tables.exists?(:test)
14
-
15
- db.tables.create(
16
- "test",
17
- columns: [
18
- {name: "id", type: :int, autoincr: true, primarykey: true},
19
- {name: "text", type: :varchar},
20
- {name: "number", type: :int, default: 0},
21
- {name: "float", type: :float, default: 0.0},
22
- {name: "created_at", type: :datetime}
23
- ]
24
- )
25
-
26
- 1000.times do |count|
27
- db.insert("test", text: "Test #{count}", number: count, float: count)
28
- end
29
- end
30
-
31
- describe "#total_pages" do
32
- it "returns the correct amount of pages" do
33
- query = db.new_query.from("test").per_page(30)
34
-
35
- expect(query.total_pages).to eq 34
36
- end
37
- end
38
- end
@@ -1,22 +0,0 @@
1
- unless RUBY_PLATFORM == "java"
2
- require "spec_helper"
3
- Baza.load_driver("active_record")
4
-
5
- describe Baza::Driver::ActiveRecord do
6
- let(:constant) do
7
- const_name = "InfoActiveRecordMysql2"
8
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
9
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
10
- Baza.const_get(const_name)
11
- end
12
-
13
- it_behaves_like "a baza driver"
14
- it_should_behave_like "a baza tables driver"
15
- it_should_behave_like "a baza columns driver"
16
- it_should_behave_like "a baza foreign keys driver"
17
- it_should_behave_like "a baza indexes driver"
18
- it_should_behave_like "a baza users driver"
19
- it_should_behave_like "an active record driver"
20
- it_should_behave_like "a baza importer driver"
21
- end
22
- end
@@ -1,19 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::ActiveRecord, :mysql do
4
- let(:constant) do
5
- const_name = "InfoActiveRecordMysql"
6
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
-
11
- it_behaves_like "a baza driver"
12
- it_should_behave_like "a baza tables driver"
13
- it_should_behave_like "a baza columns driver"
14
- it_should_behave_like "a baza foreign keys driver"
15
- it_should_behave_like "a baza indexes driver"
16
- it_should_behave_like "a baza users driver"
17
- it_should_behave_like "an active record driver"
18
- it_should_behave_like "a baza importer driver"
19
- end
@@ -1,22 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless RUBY_PLATFORM == "java"
4
- Baza.load_driver("active_record")
5
-
6
- describe Baza::Driver::ActiveRecord do
7
- let(:constant) do
8
- const_name = "InfoActiveRecordPg"
9
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
10
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
11
- Baza.const_get(const_name)
12
- end
13
-
14
- it_behaves_like "a baza driver"
15
- it_should_behave_like "a baza tables driver"
16
- it_should_behave_like "a baza columns driver"
17
- it_should_behave_like "a baza foreign keys driver"
18
- it_should_behave_like "a baza indexes driver"
19
- it_should_behave_like "an active record driver"
20
- it_should_behave_like "a baza importer driver"
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require "spec_helper"
2
- require_relative "../../lib/baza/driver/active_record"
3
-
4
- describe Baza::Driver::ActiveRecord do
5
- let(:constant) do
6
- const_name = "InfoActiveRecordSqlite3"
7
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
8
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
9
- Baza.const_get(const_name)
10
- end
11
-
12
- it_behaves_like "a baza driver"
13
- it_should_behave_like "a baza tables driver"
14
- it_should_behave_like "a baza columns driver"
15
- it_should_behave_like "a baza indexes driver"
16
- it_should_behave_like "an active record driver"
17
- it_should_behave_like "a baza importer driver"
18
- end
@@ -1,19 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::Mysql2 do
4
- let(:constant) do
5
- const_name = "InfoMysql2"
6
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
-
11
- it_should_behave_like "a baza driver"
12
- it_should_behave_like "a baza databases driver"
13
- it_should_behave_like "a baza tables driver"
14
- it_should_behave_like "a baza columns driver"
15
- it_should_behave_like "a baza foreign keys driver"
16
- it_should_behave_like "a baza indexes driver"
17
- it_should_behave_like "a baza users driver"
18
- it_should_behave_like "a baza importer driver"
19
- end
@@ -1,58 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza.const_get(:Driver).const_get(:Mysql), :mysql do
4
- let(:constant) do
5
- const_name = "InfoMysql"
6
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
-
11
- it_should_behave_like "a baza driver"
12
- it_should_behave_like "a baza databases driver"
13
- it_should_behave_like "a baza tables driver"
14
- it_should_behave_like "a baza columns driver"
15
- it_should_behave_like "a baza foreign keys driver"
16
- it_should_behave_like "a baza indexes driver"
17
- it_should_behave_like "a baza users driver"
18
- it_should_behave_like "a baza importer driver"
19
-
20
- it "should dump to sqlite3" do
21
- require "info_sqlite3"
22
- require "info_mysql"
23
-
24
- driver1 = Baza::InfoMysql.new
25
- db1 = driver1.db
26
- driver1.before
27
-
28
- driver2 = Baza::InfoSqlite3.new
29
- db2 = driver2.db
30
- driver2.before
31
-
32
- begin
33
- db1.tables.create(:test_table, columns: [
34
- {name: :id, type: :int, autoincr: true, primarykey: true},
35
- {name: :name, type: :varchar, maxlength: 100}
36
- ])
37
- test_table = db1.tables[:test_table]
38
-
39
-
40
- db1.copy_to(db2)
41
-
42
- table_sqlite = db2.tables[:test_table]
43
- expect(table_sqlite.columns.length).to eq test_table.columns.length
44
-
45
- col_id_sqlite = table_sqlite.column(:id)
46
- expect(col_id_sqlite.type).to eq :int
47
- expect(col_id_sqlite.autoincr?).to eq true
48
- expect(col_id_sqlite.primarykey?).to eq true
49
-
50
- col_name_sqlite = table_sqlite.column(:name)
51
- expect(col_name_sqlite.type).to eq :varchar
52
- expect(col_name_sqlite.maxlength.to_i).to eq 100
53
- ensure
54
- driver1.after
55
- driver2.after
56
- end
57
- end
58
- end
@@ -1,45 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::Pg::Columns do
4
- let(:constant) do
5
- const_name = "InfoPg"
6
- require StringCases.camel_to_snake(const_name)
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
- let(:db) { constant.new.db }
11
-
12
- describe "#data_sql" do
13
- it "convert int(11) to integer" do
14
- result = db.columns.data_sql(
15
- name: "test",
16
- type: :int,
17
- maxlength: 11
18
- )
19
-
20
- expect(result).to eq '"test" integer'
21
- end
22
-
23
- it "converts int with auto increment to serial" do
24
- result = db.columns.data_sql(
25
- name: "test",
26
- type: :int,
27
- maxlength: 11,
28
- autoincr: true
29
- )
30
-
31
- expect(result).to eq '"test" serial'
32
- end
33
-
34
- it "converts tinyint to smallint" do
35
- result = db.columns.data_sql(
36
- name: "test",
37
- type: :tinyint,
38
- maxlength: 11,
39
- autoincr: true
40
- )
41
-
42
- expect(result).to eq '"test" smallint'
43
- end
44
- end
45
- end
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::Pg::Table do
4
- let(:constant) do
5
- const_name = "InfoPg"
6
- require StringCases.camel_to_snake(const_name)
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
- let(:driver) { constant.new }
11
- let(:db) { driver.db }
12
-
13
- describe "#native?" do
14
- it "returns true if the table is 'pg_stat_statements'-table" do
15
- test_table = Baza::Driver::Pg::Table.new(driver: driver, data: {table_name: "pg_stat_statements"})
16
-
17
- expect(test_table.native?).to eq true
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- require "spec_helper"
2
-
3
- unless RUBY_PLATFORM == "java"
4
- describe Baza.const_get(:Driver).const_get(:Pg) do
5
- let(:constant) do
6
- const_name = "InfoPg"
7
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
8
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
9
- Baza.const_get(const_name)
10
- end
11
-
12
- it_should_behave_like "a baza driver"
13
- it_should_behave_like "a baza databases driver"
14
- it_should_behave_like "a baza tables driver"
15
- it_should_behave_like "a baza columns driver"
16
- it_should_behave_like "a baza foreign keys driver"
17
- it_should_behave_like "a baza indexes driver"
18
- it_should_behave_like "a baza importer driver"
19
- end
20
- end
@@ -1,67 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::Sqlite3 do
4
- let(:constant) do
5
- const_name = "InfoSqlite3"
6
- require "#{File.dirname(__FILE__)}/../#{StringCases.camel_to_snake(const_name)}"
7
- raise "Constant was not defined: '#{const_name}'." unless Baza.const_defined?(const_name)
8
- Baza.const_get(const_name)
9
- end
10
-
11
- it_behaves_like "a baza driver"
12
- it_should_behave_like "a baza tables driver"
13
- it_should_behave_like "a baza columns driver"
14
- it_should_behave_like "a baza indexes driver"
15
- it_should_behave_like "a baza importer driver"
16
-
17
- it "should copy database structure and data" do
18
- require "info_sqlite3"
19
- db = Baza::InfoSqlite3.new.db
20
- db2 = Baza::InfoSqlite3.new.db
21
-
22
- db.tables.create(
23
- :test_table,
24
- columns: [
25
- {name: "id", type: :int, autoincr: true, primarykey: true},
26
- {name: "testname", type: :varchar, null: true}
27
- ],
28
- indexes: [
29
- "testname"
30
- ]
31
- )
32
-
33
- table1 = db.tables["test_table"]
34
- cols1 = table1.columns
35
-
36
- 100.times do |count|
37
- table1.insert(testname: "TestRow#{count}")
38
- end
39
-
40
- expect { db2.tables[:test_table] }.to raise_error(Baza::Errors::TableNotFound)
41
-
42
- db.copy_to(db2)
43
-
44
- table2 = db2.tables[:test_table]
45
-
46
- cols2 = table2.columns
47
- expect(cols2.length).to eql(cols1.length)
48
-
49
- expect(table2.rows_count).to eq table1.rows_count
50
-
51
- db.select(:test_table) do |row1|
52
- found = 0
53
- db2.select(:test_table, row1) do |row2|
54
- found += 1
55
-
56
- row1.each do |key, val|
57
- expect(row2[key]).to eql(val)
58
- end
59
- end
60
-
61
- expect(found).to eq 1
62
- end
63
-
64
- expect(table1.indexes.length).to eq 1
65
- expect(table2.indexes.length).to eq table1.indexes.length
66
- end
67
- end
@@ -1,27 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Baza::Driver::Tiny do
4
- describe "#quote_database" do
5
- it "quotes the given database name" do
6
- expect(Baza::Driver::Tiny.quote_database("test_database")).to eq "[test_database]"
7
- end
8
- end
9
-
10
- describe "#quote_column" do
11
- it "quotes the given column name" do
12
- expect(Baza::Driver::Tiny.quote_column("test_column")).to eq "[test_column]"
13
- end
14
- end
15
-
16
- describe "#quote_index" do
17
- it "quotes the given index name" do
18
- expect(Baza::Driver::Tiny.quote_index("test_index")).to eq "[test_index]"
19
- end
20
- end
21
-
22
- describe "#quote_table" do
23
- it "quotes the given table name" do
24
- expect(Baza::Driver::Tiny.quote_table("test_table")).to eq "[test_table]"
25
- end
26
- end
27
- end
@@ -1,35 +0,0 @@
1
- class Baza::InfoActiveRecord
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
-
7
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
8
- adapter: "mysql2",
9
- host: "localhost",
10
- database: "baza-test",
11
- username: "baza-test",
12
- password: "password"
13
- )
14
- @conn ||= @conn_pool.connection
15
-
16
- {pool: @conn_pool, conn: @conn}
17
- end
18
-
19
- def initialize
20
- data = Baza::InfoActiveRecord.connection
21
-
22
- @db = Baza::Db.new({
23
- type: :active_record,
24
- conn: data.fetch(:conn)
25
- }.merge(args))
26
- end
27
-
28
- def before
29
- @db.tables.list(&:drop)
30
- end
31
-
32
- def after
33
- @db.close
34
- end
35
- end
@@ -1,36 +0,0 @@
1
- class Baza::InfoActiveRecordMysql2
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "activerecord-jdbc-adapter" if RUBY_PLATFORM == "java"
7
-
8
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
9
- adapter: "mysql2",
10
- host: "localhost",
11
- database: "baza-test",
12
- username: "baza-test",
13
- password: "password"
14
- )
15
- @conn ||= @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordMysql2.connection
22
-
23
- @db = Baza::Db.new({
24
- type: :active_record,
25
- conn: data.fetch(:conn)
26
- }.merge(args))
27
- end
28
-
29
- def before
30
- @db.tables.list(&:drop)
31
- end
32
-
33
- def after
34
- @db.close
35
- end
36
- end
@@ -1,36 +0,0 @@
1
- class Baza::InfoActiveRecordMysql2
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "activerecord-jdbc-adapter" if RUBY_PLATFORM == "java"
7
-
8
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
9
- adapter: "mysql2",
10
- host: "mysql",
11
- database: "baza",
12
- username: "build",
13
- password: "password"
14
- )
15
- @conn = @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordMysql2.connection
22
-
23
- @db = Baza::Db.new({
24
- type: :active_record,
25
- conn: data.fetch(:conn)
26
- }.merge(args))
27
- end
28
-
29
- def before
30
- @db.tables.list(&:drop)
31
- end
32
-
33
- def after
34
- @db.close
35
- end
36
- end
@@ -1,37 +0,0 @@
1
- class Baza::InfoActiveRecordMysql
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "activerecord-jdbc-adapter" if RUBY_PLATFORM == "java"
7
-
8
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
9
- adapter: "mysql",
10
- host: "localhost",
11
- database: "baza-test",
12
- username: "baza-test",
13
- password: "password"
14
- )
15
- @conn ||= @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordMysql.connection
22
- data.fetch(:conn).reconnect!
23
-
24
- @db = Baza::Db.new({
25
- type: :active_record,
26
- conn: data.fetch(:conn)
27
- }.merge(args))
28
- end
29
-
30
- def before
31
- @db.tables.list(&:drop)
32
- end
33
-
34
- def after
35
- @db.close
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- class Baza::InfoActiveRecordMysql
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "activerecord-jdbc-adapter" if RUBY_PLATFORM == "java"
7
-
8
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
9
- adapter: "mysql",
10
- host: "mysql",
11
- database: "baza",
12
- username: "build",
13
- password: "password"
14
- )
15
- @conn ||= @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordMysql.connection
22
- data.fetch(:conn).reconnect!
23
-
24
- @db = Baza::Db.new({
25
- type: :active_record,
26
- conn: data.fetch(:conn)
27
- }.merge(args))
28
- end
29
-
30
- def before
31
- @db.tables.list(&:drop)
32
- end
33
-
34
- def after
35
- @db.close
36
- end
37
- end
@@ -1,36 +0,0 @@
1
- class Baza::InfoActiveRecordPg
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "pg"
7
-
8
- @conn_pool ||= ::ActiveRecord::Base.establish_connection(
9
- adapter: "postgresql",
10
- host: "localhost",
11
- database: "baza-test",
12
- username: "baza-test",
13
- password: "password"
14
- )
15
- @conn ||= @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordPg.connection
22
-
23
- @db = Baza::Db.new({
24
- type: :active_record,
25
- conn: data.fetch(:conn)
26
- }.merge(args))
27
- end
28
-
29
- def before
30
- @db.tables.list(&:drop)
31
- end
32
-
33
- def after
34
- @db.close
35
- end
36
- end
@@ -1,36 +0,0 @@
1
- class Baza::InfoActiveRecordPg
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
- require "pg"
7
-
8
- @conn_pool = ::ActiveRecord::Base.establish_connection(
9
- adapter: "postgresql",
10
- database: "baza",
11
- host: "postgres",
12
- username: "build",
13
- password: "password"
14
- )
15
- @conn = @conn_pool.connection
16
-
17
- {pool: @conn_pool, conn: @conn}
18
- end
19
-
20
- def initialize(args = {})
21
- data = Baza::InfoActiveRecordPg.connection
22
-
23
- @db = Baza::Db.new({
24
- type: :active_record,
25
- conn: data.fetch(:conn)
26
- }.merge(args))
27
- end
28
-
29
- def before
30
- @db.tables.list(&:drop)
31
- end
32
-
33
- def after
34
- @db.close
35
- end
36
- end
@@ -1,29 +0,0 @@
1
- class Baza::InfoActiveRecordSqlite3
2
- attr_reader :db
3
-
4
- def self.connection
5
- require "active_record"
6
-
7
- conn_pool = ::ActiveRecord::ConnectionAdapters::ConnectionHandler.new.establish_connection(
8
- adapter: "sqlite3",
9
- database: ":memory:"
10
- )
11
- conn = conn_pool.connection
12
-
13
- {pool: conn_pool, conn: conn}
14
- end
15
-
16
- def initialize(args = {})
17
- data = Baza::InfoActiveRecordSqlite3.connection
18
-
19
- @db = Baza::Db.new({
20
- type: :active_record,
21
- conn: data.fetch(:conn),
22
- index_append_table_name: true
23
- }.merge(args))
24
- end
25
-
26
- def before; end
27
-
28
- def after; end
29
- end