numeric_type_column 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -0
- data/lib/numeric_type_column/active_record/{base_extension.rb → base_patch.rb} +3 -3
- data/lib/numeric_type_column/active_record/{belongs_to_polymorphic_association_extension.rb → belongs_to_polymorphic_association_patch.rb} +4 -4
- data/lib/numeric_type_column/active_record/{column_definition_extension.rb → column_definition_patch.rb} +4 -4
- data/lib/numeric_type_column/active_record/mysql_adapter_patch.rb +102 -0
- data/lib/numeric_type_column/active_record/schema_dumper_patch.rb +102 -0
- data/lib/numeric_type_column/active_record/{table_definition_extension.rb → table_definition_patch.rb} +3 -3
- data/lib/numeric_type_column/active_record.rb +8 -5
- data/lib/numeric_type_column/railtie.rb +11 -5
- data/lib/numeric_type_column/version.rb +1 -1
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/unsigned_columns_tests.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/unsigned_columns_tests.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/unsigned_columns_tests_controller.rb +83 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/unsigned_columns_tests_helper.rb +2 -0
- data/test/dummy/app/models/unsigned_columns_test.rb +4 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/unsigned_columns_tests/_form.html.erb +37 -0
- data/test/dummy/app/views/unsigned_columns_tests/edit.html.erb +6 -0
- data/test/dummy/app/views/unsigned_columns_tests/index.html.erb +31 -0
- data/test/dummy/app/views/unsigned_columns_tests/new.html.erb +5 -0
- data/test/dummy/app/views/unsigned_columns_tests/show.html.erb +30 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +30 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/mayhem.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/migrate/20121024034824_create_unsigned_columns_tests.rb +40 -0
- data/test/dummy/db/migrate/20121024090232_create_join_table_test.rb +19 -0
- data/test/dummy/db/schema.rb +38 -0
- data/test/dummy/db/seeds.rb +20 -0
- data/test/dummy/log/mayhem.log +1513 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/unsigned_columns_tests.yml +15 -0
- data/test/dummy/test/functional/unsigned_columns_tests_controller_test.rb +49 -0
- data/test/dummy/test/unit/helpers/unsigned_columns_tests_helper_test.rb +4 -0
- data/test/dummy/test/unit/unsigned_columns_test_test.rb +7 -0
- data/test/numeric_type_column_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +130 -10
- data/lib/numeric_type_column/active_record/abstract_mysql_adapter_extension.rb +0 -69
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
integer_unsigned_column: 1
|
5
|
+
decimal_unsigned_column: 9.99
|
6
|
+
unsigned_float_column: 1.5
|
7
|
+
boolean_unsigned_column: false
|
8
|
+
references_unsigned_column:
|
9
|
+
|
10
|
+
two:
|
11
|
+
integer_unsigned_column: 1
|
12
|
+
decimal_unsigned_column: 9.99
|
13
|
+
unsigned_float_column: 1.5
|
14
|
+
boolean_unsigned_column: false
|
15
|
+
references_unsigned_column:
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class UnsignedColumnsTestsControllerTest < ActionController::TestCase
|
4
|
+
setup do
|
5
|
+
@unsigned_columns_test = unsigned_columns_tests(:one)
|
6
|
+
end
|
7
|
+
|
8
|
+
test "should get index" do
|
9
|
+
get :index
|
10
|
+
assert_response :success
|
11
|
+
assert_not_nil assigns(:unsigned_columns_tests)
|
12
|
+
end
|
13
|
+
|
14
|
+
test "should get new" do
|
15
|
+
get :new
|
16
|
+
assert_response :success
|
17
|
+
end
|
18
|
+
|
19
|
+
test "should create unsigned_columns_test" do
|
20
|
+
assert_difference('UnsignedColumnsTest.count') do
|
21
|
+
post :create, unsigned_columns_test: { boolean_unsigned_column: @unsigned_columns_test.boolean_unsigned_column, decimal_unsigned_column: @unsigned_columns_test.decimal_unsigned_column, integer_unsigned_column: @unsigned_columns_test.integer_unsigned_column, unsigned_float_column: @unsigned_columns_test.unsigned_float_column }
|
22
|
+
end
|
23
|
+
|
24
|
+
assert_redirected_to unsigned_columns_test_path(assigns(:unsigned_columns_test))
|
25
|
+
end
|
26
|
+
|
27
|
+
test "should show unsigned_columns_test" do
|
28
|
+
get :show, id: @unsigned_columns_test
|
29
|
+
assert_response :success
|
30
|
+
end
|
31
|
+
|
32
|
+
test "should get edit" do
|
33
|
+
get :edit, id: @unsigned_columns_test
|
34
|
+
assert_response :success
|
35
|
+
end
|
36
|
+
|
37
|
+
test "should update unsigned_columns_test" do
|
38
|
+
put :update, id: @unsigned_columns_test, unsigned_columns_test: { boolean_unsigned_column: @unsigned_columns_test.boolean_unsigned_column, decimal_unsigned_column: @unsigned_columns_test.decimal_unsigned_column, integer_unsigned_column: @unsigned_columns_test.integer_unsigned_column, unsigned_float_column: @unsigned_columns_test.unsigned_float_column }
|
39
|
+
assert_redirected_to unsigned_columns_test_path(assigns(:unsigned_columns_test))
|
40
|
+
end
|
41
|
+
|
42
|
+
test "should destroy unsigned_columns_test" do
|
43
|
+
assert_difference('UnsignedColumnsTest.count', -1) do
|
44
|
+
delete :destroy, id: @unsigned_columns_test
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_redirected_to unsigned_columns_tests_path
|
48
|
+
end
|
49
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: numeric_type_column
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-
|
12
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 3.2.
|
21
|
+
version: 3.2.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,23 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 3.2.
|
29
|
+
version: 3.2.8
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.2.8
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.8
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: sqlite3
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,11 +84,12 @@ executables: []
|
|
68
84
|
extensions: []
|
69
85
|
extra_rdoc_files: []
|
70
86
|
files:
|
71
|
-
- lib/numeric_type_column/active_record/
|
72
|
-
- lib/numeric_type_column/active_record/
|
73
|
-
- lib/numeric_type_column/active_record/
|
74
|
-
- lib/numeric_type_column/active_record/
|
75
|
-
- lib/numeric_type_column/active_record/
|
87
|
+
- lib/numeric_type_column/active_record/base_patch.rb
|
88
|
+
- lib/numeric_type_column/active_record/belongs_to_polymorphic_association_patch.rb
|
89
|
+
- lib/numeric_type_column/active_record/column_definition_patch.rb
|
90
|
+
- lib/numeric_type_column/active_record/mysql_adapter_patch.rb
|
91
|
+
- lib/numeric_type_column/active_record/schema_dumper_patch.rb
|
92
|
+
- lib/numeric_type_column/active_record/table_definition_patch.rb
|
76
93
|
- lib/numeric_type_column/active_record.rb
|
77
94
|
- lib/numeric_type_column/railtie.rb
|
78
95
|
- lib/numeric_type_column/version.rb
|
@@ -80,6 +97,57 @@ files:
|
|
80
97
|
- MIT-LICENSE
|
81
98
|
- Rakefile
|
82
99
|
- README.md
|
100
|
+
- test/dummy/app/assets/javascripts/application.js
|
101
|
+
- test/dummy/app/assets/javascripts/unsigned_columns_tests.js
|
102
|
+
- test/dummy/app/assets/stylesheets/application.css
|
103
|
+
- test/dummy/app/assets/stylesheets/scaffold.css
|
104
|
+
- test/dummy/app/assets/stylesheets/unsigned_columns_tests.css
|
105
|
+
- test/dummy/app/controllers/application_controller.rb
|
106
|
+
- test/dummy/app/controllers/unsigned_columns_tests_controller.rb
|
107
|
+
- test/dummy/app/helpers/application_helper.rb
|
108
|
+
- test/dummy/app/helpers/unsigned_columns_tests_helper.rb
|
109
|
+
- test/dummy/app/models/unsigned_columns_test.rb
|
110
|
+
- test/dummy/app/views/layouts/application.html.erb
|
111
|
+
- test/dummy/app/views/unsigned_columns_tests/_form.html.erb
|
112
|
+
- test/dummy/app/views/unsigned_columns_tests/edit.html.erb
|
113
|
+
- test/dummy/app/views/unsigned_columns_tests/index.html.erb
|
114
|
+
- test/dummy/app/views/unsigned_columns_tests/new.html.erb
|
115
|
+
- test/dummy/app/views/unsigned_columns_tests/show.html.erb
|
116
|
+
- test/dummy/config/application.rb
|
117
|
+
- test/dummy/config/boot.rb
|
118
|
+
- test/dummy/config/database.yml
|
119
|
+
- test/dummy/config/environment.rb
|
120
|
+
- test/dummy/config/environments/development.rb
|
121
|
+
- test/dummy/config/environments/mayhem.rb
|
122
|
+
- test/dummy/config/environments/production.rb
|
123
|
+
- test/dummy/config/environments/test.rb
|
124
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
125
|
+
- test/dummy/config/initializers/inflections.rb
|
126
|
+
- test/dummy/config/initializers/mime_types.rb
|
127
|
+
- test/dummy/config/initializers/secret_token.rb
|
128
|
+
- test/dummy/config/initializers/session_store.rb
|
129
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
130
|
+
- test/dummy/config/locales/en.yml
|
131
|
+
- test/dummy/config/routes.rb
|
132
|
+
- test/dummy/config.ru
|
133
|
+
- test/dummy/db/migrate/20121024034824_create_unsigned_columns_tests.rb
|
134
|
+
- test/dummy/db/migrate/20121024090232_create_join_table_test.rb
|
135
|
+
- test/dummy/db/schema.rb
|
136
|
+
- test/dummy/db/seeds.rb
|
137
|
+
- test/dummy/log/mayhem.log
|
138
|
+
- test/dummy/public/404.html
|
139
|
+
- test/dummy/public/422.html
|
140
|
+
- test/dummy/public/500.html
|
141
|
+
- test/dummy/public/favicon.ico
|
142
|
+
- test/dummy/Rakefile
|
143
|
+
- test/dummy/README.rdoc
|
144
|
+
- test/dummy/script/rails
|
145
|
+
- test/dummy/test/fixtures/unsigned_columns_tests.yml
|
146
|
+
- test/dummy/test/functional/unsigned_columns_tests_controller_test.rb
|
147
|
+
- test/dummy/test/unit/helpers/unsigned_columns_tests_helper_test.rb
|
148
|
+
- test/dummy/test/unit/unsigned_columns_test_test.rb
|
149
|
+
- test/numeric_type_column_test.rb
|
150
|
+
- test/test_helper.rb
|
83
151
|
homepage: http://apphouse.naranya.net
|
84
152
|
licenses: []
|
85
153
|
post_install_message:
|
@@ -105,4 +173,56 @@ signing_key:
|
|
105
173
|
specification_version: 3
|
106
174
|
summary: A collection of patches to Rails ActiveRecord that supports numeric type
|
107
175
|
columns.
|
108
|
-
test_files:
|
176
|
+
test_files:
|
177
|
+
- test/dummy/app/assets/javascripts/application.js
|
178
|
+
- test/dummy/app/assets/javascripts/unsigned_columns_tests.js
|
179
|
+
- test/dummy/app/assets/stylesheets/application.css
|
180
|
+
- test/dummy/app/assets/stylesheets/scaffold.css
|
181
|
+
- test/dummy/app/assets/stylesheets/unsigned_columns_tests.css
|
182
|
+
- test/dummy/app/controllers/application_controller.rb
|
183
|
+
- test/dummy/app/controllers/unsigned_columns_tests_controller.rb
|
184
|
+
- test/dummy/app/helpers/application_helper.rb
|
185
|
+
- test/dummy/app/helpers/unsigned_columns_tests_helper.rb
|
186
|
+
- test/dummy/app/models/unsigned_columns_test.rb
|
187
|
+
- test/dummy/app/views/layouts/application.html.erb
|
188
|
+
- test/dummy/app/views/unsigned_columns_tests/_form.html.erb
|
189
|
+
- test/dummy/app/views/unsigned_columns_tests/edit.html.erb
|
190
|
+
- test/dummy/app/views/unsigned_columns_tests/index.html.erb
|
191
|
+
- test/dummy/app/views/unsigned_columns_tests/new.html.erb
|
192
|
+
- test/dummy/app/views/unsigned_columns_tests/show.html.erb
|
193
|
+
- test/dummy/config/application.rb
|
194
|
+
- test/dummy/config/boot.rb
|
195
|
+
- test/dummy/config/database.yml
|
196
|
+
- test/dummy/config/environment.rb
|
197
|
+
- test/dummy/config/environments/development.rb
|
198
|
+
- test/dummy/config/environments/mayhem.rb
|
199
|
+
- test/dummy/config/environments/production.rb
|
200
|
+
- test/dummy/config/environments/test.rb
|
201
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
202
|
+
- test/dummy/config/initializers/inflections.rb
|
203
|
+
- test/dummy/config/initializers/mime_types.rb
|
204
|
+
- test/dummy/config/initializers/secret_token.rb
|
205
|
+
- test/dummy/config/initializers/session_store.rb
|
206
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
207
|
+
- test/dummy/config/locales/en.yml
|
208
|
+
- test/dummy/config/routes.rb
|
209
|
+
- test/dummy/config.ru
|
210
|
+
- test/dummy/db/migrate/20121024034824_create_unsigned_columns_tests.rb
|
211
|
+
- test/dummy/db/migrate/20121024090232_create_join_table_test.rb
|
212
|
+
- test/dummy/db/schema.rb
|
213
|
+
- test/dummy/db/seeds.rb
|
214
|
+
- test/dummy/log/mayhem.log
|
215
|
+
- test/dummy/public/404.html
|
216
|
+
- test/dummy/public/422.html
|
217
|
+
- test/dummy/public/500.html
|
218
|
+
- test/dummy/public/favicon.ico
|
219
|
+
- test/dummy/Rakefile
|
220
|
+
- test/dummy/README.rdoc
|
221
|
+
- test/dummy/script/rails
|
222
|
+
- test/dummy/test/fixtures/unsigned_columns_tests.yml
|
223
|
+
- test/dummy/test/functional/unsigned_columns_tests_controller_test.rb
|
224
|
+
- test/dummy/test/unit/helpers/unsigned_columns_tests_helper_test.rb
|
225
|
+
- test/dummy/test/unit/unsigned_columns_test_test.rb
|
226
|
+
- test/numeric_type_column_test.rb
|
227
|
+
- test/test_helper.rb
|
228
|
+
has_rdoc:
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module NumericTypeColumn
|
4
|
-
|
5
|
-
module ActiveRecord
|
6
|
-
|
7
|
-
module AbstractMysqlAdapterExtension
|
8
|
-
|
9
|
-
def self.included(base)
|
10
|
-
#puts "NumericTypeColumn::ActiveRecord::AbstractMysqlAdapterExtension included to #{base.name}!"
|
11
|
-
base::NATIVE_DATABASE_TYPES[:primary_key] = 'INT UNSIGNED DEFAULT NULL auto_increment PRIMARY KEY'
|
12
|
-
base.send :alias_method_chain, :add_column_sql, :unsigned
|
13
|
-
base.send :alias_method_chain, :type_to_sql, :unsigned
|
14
|
-
base.send :alias_method_chain, :add_column_options!, :comment
|
15
|
-
#base.send :alias_method_chain, :create_table, :mysql_options
|
16
|
-
end
|
17
|
-
|
18
|
-
=begin
|
19
|
-
|
20
|
-
class Column < ConnectionAdapters::Column # :nodoc:
|
21
|
-
attr_reader :unsigned
|
22
|
-
|
23
|
-
def initialize_with_unsigned(name, default, sql_type = nil, null = true)
|
24
|
-
initialize_without_unsigned(name, default, sql_type, null)
|
25
|
-
@unsigned = extract_unsigned(sql_type)
|
26
|
-
end
|
27
|
-
alias_method_chain :initialize, :unsigned
|
28
|
-
|
29
|
-
def extract_unsigned(sql_type)
|
30
|
-
false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
=end
|
34
|
-
=begin
|
35
|
-
def create_table_with_mysql_options(table_name, options = {}) #:nodoc:
|
36
|
-
puts "NumericTypeColumn::ActiveRecord::AbstractMysqlAdapterExtension: create_table(table_name: #{table_name}, options: #{options})"
|
37
|
-
create_table_without_mysql_options(table_name, options.reverse_merge(options: options[:mysql_options] ? options[:mysql_options] : "ENGINE=InnoDB"))
|
38
|
-
end
|
39
|
-
=end
|
40
|
-
protected
|
41
|
-
|
42
|
-
def add_column_sql_with_unsigned(table_name, column_name, type, options = {})
|
43
|
-
#puts "NumericTypeColumn::ActiveRecord::AbstractMysqlAdapterExtension: add_column_sql_with_unsigned(table_name: #{table_name}, column_name: #{column_name}, type: #{type}, options: #{options})"
|
44
|
-
is_unsigned_valid = (((options.has_key? :unsigned) && (options[:unsigned] == true)) && (['integer', 'boolean'].include? type.to_s))
|
45
|
-
add_column_sql = "ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale], is_unsigned_valid)}"
|
46
|
-
add_column_options!(add_column_sql, options)
|
47
|
-
add_column_position!(add_column_sql, options)
|
48
|
-
add_column_sql
|
49
|
-
end
|
50
|
-
|
51
|
-
def type_to_sql_with_unsigned(type, limit = nil, precision = nil, scale = nil, unsigned = false)
|
52
|
-
#puts "NumericTypeColumn::ActiveRecord::AbstractMysqlAdapterExtension: type_to_sql_with_unsigned(type: #{type}, limit: #{limit}, precision: #{precision}, scale: #{scale}, unsigned: #{unsigned})..."
|
53
|
-
sql = type_to_sql_without_unsigned(type, limit, precision, scale)
|
54
|
-
sql << ' UNSIGNED' if unsigned && (['integer', 'boolean'].include? type.to_s)
|
55
|
-
sql
|
56
|
-
end
|
57
|
-
|
58
|
-
def add_column_options_with_comment!(sql, options = {})
|
59
|
-
#puts "NumericTypeColumn::ActiveRecord::AbstractMysqlAdapterExtension: add_column_options_with_comment!(sql: #{sql}, options: #{})"
|
60
|
-
add_column_options_without_comment!(sql, options)
|
61
|
-
sql << " COMMENT '#{options[:comment]}'" if options[:comment]
|
62
|
-
sql
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|