global_uid 1.3.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/global_uid.gemspec CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'global_uid'
16
- s.version = '1.3.1'
17
- s.date = '2012-10-24'
16
+ s.version = '1.4.0'
17
+ s.date = '2013-04-01'
18
18
  s.rubyforge_project = 'global_uid'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -28,6 +28,8 @@ module GlobalUid
28
28
  type = options[:uid_type] || "bigint(21) UNSIGNED"
29
29
  start_id = options[:start_id] || 1
30
30
 
31
+ engine_stmt = global_uid_options[:storage_engine] ? "ENGINE=#{global_uid_options[:storage_engine]}" : ""
32
+
31
33
  # TODO it would be nice to be able to set the engine or something to not be MySQL specific
32
34
  with_connections do |connection|
33
35
  connection.execute("CREATE TABLE IF NOT EXISTS `#{id_table_name}` (
@@ -35,7 +37,7 @@ module GlobalUid
35
37
  `stub` char(1) NOT NULL DEFAULT '',
36
38
  PRIMARY KEY (`id`),
37
39
  UNIQUE KEY `stub` (`stub`)
38
- )")
40
+ ) #{engine_stmt}")
39
41
 
40
42
  # prime the pump on each server
41
43
  connection.execute("INSERT IGNORE INTO `#{id_table_name}` VALUES(#{start_id}, 'a')")
@@ -110,6 +110,7 @@ class GlobalUIDTest < ActiveSupport::TestCase
110
110
  context "with global-uid enabled" do
111
111
  setup do
112
112
  GlobalUid::Base.global_uid_options[:disabled] = false
113
+ GlobalUid::Base.global_uid_options[:storage_engine] = "InnoDB"
113
114
  CreateWithNoParams.up
114
115
  @create_table = show_create_sql(WithGlobalUID, "with_global_uids").split("\n")
115
116
  end
@@ -127,6 +128,14 @@ class GlobalUIDTest < ActiveSupport::TestCase
127
128
  end
128
129
  end
129
130
 
131
+ should "create tables with the given storage_engine" do
132
+ GlobalUid::Base.with_connections do |cx|
133
+ foo = cx.select_all("show create table with_global_uids_ids")
134
+ assert_match /ENGINE=InnoDB/, foo.first.values.join
135
+ end
136
+
137
+ end
138
+
130
139
  should "tear off the auto_increment part of the primary key from the created table" do
131
140
  id_line = @create_table.grep(/\`id\` int/i).first
132
141
  assert_no_match /auto_increment/i, id_line
data/test/test_helper.rb CHANGED
@@ -9,6 +9,7 @@ require "active_record"
9
9
  require "active_support"
10
10
  require "active_support/test_case"
11
11
  require "shoulda"
12
+ require "mocha"
12
13
  require "global_uid"
13
14
 
14
15
  GlobalUid::Base.global_uid_options = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: global_uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2013-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord