activerecord-database_unsigned_columns 0.0.8 → 0.0.9
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.
@@ -0,0 +1,33 @@
|
|
1
|
+
# endocing: utf-8
|
2
|
+
module ActiveRecord
|
3
|
+
module DatabaseUnsignedColumns
|
4
|
+
module Adapters
|
5
|
+
|
6
|
+
module JdbcMysqlAdapter
|
7
|
+
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
puts "Module 'ActiveRecord:DatabaseUnsignedColumns::Adapters::JdbcMysqlAdapter included to '#{self.name}'"
|
12
|
+
alias_method_chain :modify_types, :unsigned
|
13
|
+
alias_method_chain :type_to_sql, :unsigned
|
14
|
+
# alias_method_chain :create_table, :mysql_options
|
15
|
+
end
|
16
|
+
|
17
|
+
def modify_types_with_unsigned(types)
|
18
|
+
types = modify_types_without_unsigned(types)
|
19
|
+
types[:primary_key] = "INT UNSIGNED DEFAULT NULL auto_increment PRIMARY KEY" if types.has_key? :primary_key
|
20
|
+
types
|
21
|
+
end
|
22
|
+
|
23
|
+
def type_to_sql_with_unsigned(type, limit = nil, precision = nil, scale = nil, unsigned = false)
|
24
|
+
sql = type_to_sql_without_unsigned(type, limit, precision, scale)
|
25
|
+
sql << ' UNSIGNED' if unsigned && (['integer', 'decimal', 'float', 'boolean'].include? type.to_s)
|
26
|
+
sql
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -15,9 +15,6 @@ module ActiveRecord
|
|
15
15
|
alias_method_chain :add_column_sql, :unsigned
|
16
16
|
alias_method_chain :type_to_sql, :unsigned
|
17
17
|
# alias_method_chain :create_table, :mysql_options
|
18
|
-
|
19
|
-
# Incluir patch a self::Column:
|
20
|
-
#"#{self.name}::Column".constantize.send :include, NumericTypeColumn::ActiveRecord::MysqlColumnPatch
|
21
18
|
end
|
22
19
|
|
23
20
|
=begin
|
@@ -26,21 +23,21 @@ module ActiveRecord
|
|
26
23
|
end
|
27
24
|
=end
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
def add_column_sql_with_unsigned(table_name, column_name, type, options = {})
|
32
|
-
is_unsigned_valid = (((options.has_key? :unsigned) && (options[:unsigned] == true)) && (['integer', 'decimal', 'float', 'boolean'].include? type.to_s))
|
33
|
-
add_column_sql = "ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale], is_unsigned_valid)}"
|
34
|
-
add_column_options!(add_column_sql, options)
|
35
|
-
add_column_position!(add_column_sql, options)
|
36
|
-
add_column_sql
|
37
|
-
end
|
26
|
+
protected
|
38
27
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
def add_column_sql_with_unsigned(table_name, column_name, type, options = {})
|
29
|
+
is_unsigned_valid = (((options.has_key? :unsigned) && (options[:unsigned] == true)) && (['integer', 'decimal', 'float', 'boolean'].include? type.to_s))
|
30
|
+
add_column_sql = "ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale], is_unsigned_valid)}"
|
31
|
+
add_column_options!(add_column_sql, options)
|
32
|
+
add_column_position!(add_column_sql, options)
|
33
|
+
add_column_sql
|
34
|
+
end
|
35
|
+
|
36
|
+
def type_to_sql_with_unsigned(type, limit = nil, precision = nil, scale = nil, unsigned = false)
|
37
|
+
sql = type_to_sql_without_unsigned(type, limit, precision, scale)
|
38
|
+
sql << ' UNSIGNED' if unsigned && (['integer', 'decimal', 'float', 'boolean'].include? type.to_s)
|
39
|
+
sql
|
40
|
+
end
|
44
41
|
|
45
42
|
end
|
46
43
|
|
@@ -17,15 +17,28 @@ module ActiveRecord
|
|
17
17
|
ActiveRecord::ConnectionAdapters::TableDefinition.send :include, ActiveRecord::DatabaseUnsignedColumns::Definitions::Table
|
18
18
|
|
19
19
|
# Agregar modulo a los adapters de BD:
|
20
|
-
require 'active_record/database_unsigned_columns/adapters/mysql_adapter'
|
21
20
|
[
|
22
|
-
"ActiveRecord::ConnectionAdapters::
|
23
|
-
"ActiveRecord::ConnectionAdapters::Mysql2Adapter",
|
24
|
-
"ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter", # Adapter para rgeo-mysql
|
25
|
-
"ArJdbc::MySQL" # Adapter para jRuby JDBC
|
21
|
+
"ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter",
|
22
|
+
#"ActiveRecord::ConnectionAdapters::Mysql2Adapter",
|
23
|
+
#"ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter", # Adapter para rgeo-mysql
|
24
|
+
#"ArJdbc::MySQL" # Adapter para jRuby JDBC
|
26
25
|
].each do |mysql_adapter_class|
|
27
26
|
adapter_class = mysql_adapter_class.safe_constantize
|
28
|
-
|
27
|
+
if adapter_class.present?
|
28
|
+
require 'active_record/database_unsigned_columns/adapters/mysql_adapter'
|
29
|
+
adapter_class.send :include, ActiveRecord::DatabaseUnsignedColumns::Adapters::MysqlAdapter
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Agregar modulo a los adapters de JDBC:
|
34
|
+
[
|
35
|
+
"ArJdbc::MySQL"
|
36
|
+
].each do |mysql_adapter_class|
|
37
|
+
adapter_class = mysql_adapter_class.safe_constantize
|
38
|
+
if adapter_class.present?
|
39
|
+
require 'active_record/database_unsigned_columns/adapters/jdbc_mysql_adapter'
|
40
|
+
adapter_class.send :include, ActiveRecord::DatabaseUnsignedColumns::Adapters::JdbcMysqlAdapter
|
41
|
+
end
|
29
42
|
end
|
30
43
|
|
31
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-database_unsigned_columns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
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: 2013-03-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.0.
|
37
|
+
version: 0.0.9
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.0.
|
45
|
+
version: 0.0.9
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: mysql2
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,6 +67,7 @@ executables: []
|
|
67
67
|
extensions: []
|
68
68
|
extra_rdoc_files: []
|
69
69
|
files:
|
70
|
+
- lib/active_record/database_unsigned_columns/adapters/jdbc_mysql_adapter.rb
|
70
71
|
- lib/active_record/database_unsigned_columns/adapters/mysql_adapter.rb
|
71
72
|
- lib/active_record/database_unsigned_columns/definitions/column.rb
|
72
73
|
- lib/active_record/database_unsigned_columns/definitions/table.rb
|