hobo_fields 1.3.0.RC2 → 1.3.0.RC3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/generators/hobo/migration/migrator.rb +3 -1
- data/lib/hobo_fields/model/index_spec.rb +11 -1
- data/lib/hobo_fields/model.rb +5 -1
- data/lib/hobo_fields/types/text.rb +1 -1
- data/lib/hobo_fields.rb +1 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.0.
|
1
|
+
1.3.0.RC3
|
@@ -130,7 +130,7 @@ module Generators
|
|
130
130
|
all_models = table_model_classes
|
131
131
|
hobo_models = all_models.select { |m| m.try.include_in_migration && m.name.underscore.not_in?(ignore_model_names) }
|
132
132
|
non_hobo_models = all_models - hobo_models
|
133
|
-
db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.*.table_name
|
133
|
+
db_tables = connection.tables - Migrator.ignore_tables.*.to_s - non_hobo_models.reject { |t| t.try.hobo_shim? }.*.table_name
|
134
134
|
[hobo_models, db_tables]
|
135
135
|
end
|
136
136
|
|
@@ -391,6 +391,8 @@ module Generators
|
|
391
391
|
def drop_index(table, name)
|
392
392
|
# see https://hobo.lighthouseapp.com/projects/8324/tickets/566
|
393
393
|
# for why the rescue exists
|
394
|
+
max_length = connection.index_name_length
|
395
|
+
name = name[0,max_length] if name.length > max_length
|
394
396
|
"remove_index :#{table}, :name => :#{name} rescue ActiveRecord::StatementInvalid"
|
395
397
|
end
|
396
398
|
|
@@ -28,7 +28,17 @@ module HoboFields
|
|
28
28
|
def to_add_statement(new_table_name)
|
29
29
|
r = "add_index :#{new_table_name}, #{fields.*.to_sym.inspect}"
|
30
30
|
r += ", :unique => true" if unique
|
31
|
-
|
31
|
+
if default_name?
|
32
|
+
check_name = @model.connection.index_name(self.table, :column => self.fields)
|
33
|
+
else
|
34
|
+
check_name = name
|
35
|
+
end
|
36
|
+
if check_name.length > @model.connection.index_name_length
|
37
|
+
r += ", :name => '#{name[0,@model.connection.index_name_length]}'"
|
38
|
+
$stderr.puts("WARNING: index name #{check_name} too long, trimming")
|
39
|
+
else
|
40
|
+
r += ", :name => '#{name}'" unless default_name?
|
41
|
+
end
|
32
42
|
r
|
33
43
|
end
|
34
44
|
|
data/lib/hobo_fields/model.rb
CHANGED
@@ -170,7 +170,11 @@ module HoboFields
|
|
170
170
|
|
171
171
|
def self.add_index_for_field(name, args, options)
|
172
172
|
to_name = options.delete(:index)
|
173
|
-
|
173
|
+
unless to_name
|
174
|
+
# passing :unique => true doesn't do anything without an index
|
175
|
+
Rails.logger.error('ERROR: passing :unique => true without :index => true does nothing. Use :unique instead.') if options[:unique]
|
176
|
+
return
|
177
|
+
end
|
174
178
|
index_opts = {}
|
175
179
|
index_opts[:unique] = :unique.in?(args) || options.delete(:unique)
|
176
180
|
# support :index => true declaration
|
@@ -6,7 +6,7 @@ module HoboFields
|
|
6
6
|
COLUMN_TYPE = :text
|
7
7
|
|
8
8
|
def to_html(xmldoctype = true)
|
9
|
-
ERB::Util.html_escape(self).gsub("\n", "<br#{xmldoctype ? ' /' : ''}>\n")
|
9
|
+
ERB::Util.html_escape(self).gsub("\n", "<br#{xmldoctype ? ' /' : ''}>\n").html_safe
|
10
10
|
end
|
11
11
|
|
12
12
|
HoboFields.register_type(:text, self)
|
data/lib/hobo_fields.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: hobo_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: 6
|
5
|
-
version: 1.3.0.
|
5
|
+
version: 1.3.0.RC3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tom Locke
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-25 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - "="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 1.3.0.
|
24
|
+
version: 1.3.0.RC3
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
requirements: []
|
133
133
|
|
134
134
|
rubyforge_project: hobo
|
135
|
-
rubygems_version: 1.
|
135
|
+
rubygems_version: 1.6.2
|
136
136
|
signing_key:
|
137
137
|
specification_version: 3
|
138
138
|
summary: Rich field types and migration generator for Rails
|