smart_field_constraints 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,13 @@
1
+ *SVN*
2
+
3
+ *0.0.1* (May 5th, 2008)
4
+
5
+ * Initial public release
6
+
7
+ * Add documentation
8
+
9
+ * Remove maxlength attribute for textare tags since it's not valid html
10
+
11
+ * Don't set the size based on the smart maxlength
12
+
13
+ * Don't expect columns to exist for every attribute
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007-2008 Aaron Pfeifer
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,60 @@
1
+ = smart_field_constraints
2
+
3
+ +smart_field_constraints+ intelligently applies a maxlength attribute for text
4
+ fields based on column constraints and validations.
5
+
6
+ == Resources
7
+
8
+ Wiki
9
+
10
+ * http://wiki.pluginaweek.org/Smart_field_constraints
11
+
12
+ API
13
+
14
+ * http://api.pluginaweek.org/smart_field_constraints
15
+
16
+ Development
17
+
18
+ * http://dev.pluginaweek.org/browser/trunk/smart_field_constraints
19
+
20
+ Source
21
+
22
+ * http://svn.pluginaweek.org/trunk/smart_field_constraints
23
+
24
+ == Description
25
+
26
+ HTML input field restrictions within forms can often help with both validation
27
+ and improving the user experience. Normally, adding the +maxlength+ configuration
28
+ option for input fields is not DRY and duplicates data already available in the
29
+ model or database. This plugin helps make this automatic.
30
+
31
+ +smart_field_cosntraints+ looks in two places for determining the maxlength value
32
+ for an input field:
33
+ * Model validates_length_of validations
34
+ * Database column definitions (limits specifically)
35
+
36
+ Model validations will always take preference over database column definitions.
37
+
38
+ == Usage
39
+
40
+ There's nothing that you need to change to be able to use this plugin. It'll
41
+ just start automatically adding the +maxlength+ values it finds based on the
42
+ information described above (unless you define that option yourself).
43
+
44
+ === Example
45
+
46
+ Model:
47
+ class User < ActiveRecord::Base
48
+ validates_length_of :login, :maximum => 12
49
+ end
50
+
51
+ View:
52
+ text_field(:user, :login)
53
+
54
+ HTML:
55
+ <input id="user_login" maxlength="12" name="user[login]" size="30" type="text" />
56
+
57
+ == Testing
58
+
59
+ Before you can run any tests, the following gem must be installed:
60
+ * plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ require 'rake/testtask'
2
+ require 'rake/rdoctask'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/contrib/sshpublisher'
5
+
6
+ PKG_NAME = 'smart_field_constraints'
7
+ PKG_VERSION = '0.0.1'
8
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
9
+ RUBY_FORGE_PROJECT = 'pluginaweek'
10
+
11
+ desc 'Default: run unit tests.'
12
+ task :default => :test
13
+
14
+ desc 'Test the smart_field_constraints plugin.'
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.libs << 'lib'
17
+ t.pattern = 'test/**/*_test.rb'
18
+ t.verbose = true
19
+ end
20
+
21
+ desc 'Generate documentation for the smart_field_constraints plugin.'
22
+ Rake::RDocTask.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_dir = 'rdoc'
24
+ rdoc.title = 'SmartFieldConstraints'
25
+ rdoc.options << '--line-numbers' << '--inline-source'
26
+ rdoc.rdoc_files.include('README')
27
+ rdoc.rdoc_files.include('lib/**/*.rb')
28
+ end
29
+
30
+ spec = Gem::Specification.new do |s|
31
+ s.name = PKG_NAME
32
+ s.version = PKG_VERSION
33
+ s.platform = Gem::Platform::RUBY
34
+ s.summary = 'Intelligently applies a maxlength attribute for text fields based on column constraints and validations'
35
+
36
+ s.files = FileList['{lib,test}/**/*'].to_a + %w(CHANGELOG init.rb LICENSE Rakefile README)
37
+ s.require_path = 'lib'
38
+ s.autorequire = 'smart_field_constraints'
39
+ s.has_rdoc = true
40
+ s.test_files = Dir['test/**/*_test.rb']
41
+
42
+ s.author = 'Aaron Pfeifer'
43
+ s.email = 'aaron@pluginaweek.org'
44
+ s.homepage = 'http://www.pluginaweek.org'
45
+ end
46
+
47
+ Rake::GemPackageTask.new(spec) do |p|
48
+ p.gem_spec = spec
49
+ p.need_tar = true
50
+ p.need_zip = true
51
+ end
52
+
53
+ desc 'Publish the beta gem'
54
+ task :pgem => [:package] do
55
+ Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{PKG_FILE_NAME}.gem").upload
56
+ end
57
+
58
+ desc 'Publish the API documentation'
59
+ task :pdoc => [:rdoc] do
60
+ Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{PKG_NAME}", 'rdoc').upload
61
+ end
62
+
63
+ desc 'Publish the API docs and gem'
64
+ task :publish => [:pdoc, :release]
65
+
66
+ desc 'Publish the release files to RubyForge.'
67
+ task :release => [:gem, :package] do
68
+ require 'rubyforge'
69
+
70
+ ruby_forge = RubyForge.new
71
+ ruby_forge.login
72
+
73
+ %w( gem tgz zip ).each do |ext|
74
+ file = "pkg/#{PKG_FILE_NAME}.#{ext}"
75
+ puts "Releasing #{File.basename(file)}..."
76
+
77
+ ruby_forge.add_release(RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, file)
78
+ end
79
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'smart_field_constraints'
@@ -0,0 +1,40 @@
1
+ module PluginAWeek #:nodoc:
2
+ module SmartFieldConstraints
3
+ module Extensions #:nodoc:
4
+ # Automatically applies maximum length for an input field if it can be determined
5
+ module InstanceTag
6
+ def self.included(base) #:nodoc:
7
+ base.class_eval do
8
+ alias_method_chain :to_input_field_tag, :smart_constraints
9
+ end
10
+ end
11
+
12
+ # Applies constraints for the given field
13
+ def to_input_field_tag_with_smart_constraints(field_type, options = {})
14
+ options.stringify_keys!
15
+
16
+ # Only check password and text fields
17
+ if %w(password text).include?(field_type) && !options['maxlength'] && object
18
+ # Look for the attribute's maximum length from tracked validations or
19
+ # the column's definition
20
+ max_length = object.class.smart_length_constraints[method_name] || (column = object.class.columns_hash[method_name]) && column.limit
21
+
22
+ if max_length
23
+ # If the size isn't specified, use the caller's maxlength of the default value.
24
+ # This must be done here, otherwise it'll use the maxlength value that
25
+ # we apply here
26
+ options['size'] ||= options['maxlength'] || ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS['size']
27
+ options['maxlength'] = max_length
28
+ end
29
+ end
30
+
31
+ to_input_field_tag_without_smart_constraints(field_type, options)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ ActionView::Helpers::InstanceTag.class_eval do
39
+ include PluginAWeek::SmartFieldConstraints::Extensions::InstanceTag
40
+ end
@@ -0,0 +1,64 @@
1
+ module PluginAWeek #:nodoc:
2
+ module SmartFieldConstraints
3
+ module Extensions #:nodoc:
4
+ # Tracks validations on the length of fields so that they can be used when
5
+ # generate form tags for those fields
6
+ module Validations
7
+ def self.included(base) #:nodoc:
8
+ base.class_eval do
9
+ extend PluginAWeek::SmartFieldConstraints::Extensions::Validations::ClassMethods
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def self.extended(base) #:nodoc:
15
+ base.class_eval do
16
+ class_inheritable_hash :smart_length_constraints
17
+ self.smart_length_constraints = {}
18
+ end
19
+
20
+ class << base
21
+ alias_method_chain :validates_length_of, :smart_constraints
22
+ end
23
+ end
24
+
25
+ # Tracks what the maximum value that's allowed for all of the attributes
26
+ # being validated
27
+ def validates_length_of_with_smart_constraints(*attrs)
28
+ options = attrs.last
29
+ if options.is_a?(Hash)
30
+ # Extract the option restricting the length
31
+ options = options.symbolize_keys
32
+ range_options = ActiveRecord::Validations::ClassMethods::ALL_RANGE_OPTIONS & options.keys
33
+ option = range_options.first
34
+ option_value = options[range_options.first]
35
+
36
+ # Find the max value from ranges or specific maximums
37
+ max_length = nil
38
+ case option
39
+ when :within, :in
40
+ max_length = option_value.end
41
+ when :maximum, :is
42
+ max_length = option_value
43
+ end
44
+
45
+ if max_length
46
+ # Store the maximum value for each attribute so that it can be referenced later
47
+ attrs.each do |attr|
48
+ self.smart_length_constraints ||= {}
49
+ self.smart_length_constraints[attr.to_s] = max_length
50
+ end
51
+ end
52
+ end
53
+
54
+ validates_length_of_without_smart_constraints(*attrs)
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+
62
+ ActiveRecord::Base.class_eval do
63
+ include PluginAWeek::SmartFieldConstraints::Extensions::Validations
64
+ end
@@ -0,0 +1,2 @@
1
+ require 'smart_field_constraints/extensions/form_helper'
2
+ require 'smart_field_constraints/extensions/validations'
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :users do |t|
4
+ t.string :login, :limit => 12
5
+ t.string :password, :limit => 16
6
+ t.text :biography
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :users
12
+ end
13
+ end
@@ -0,0 +1,580 @@
1
+ # Logfile created on Sat May 03 16:37:19 -0400 2008 SQL (0.000456)  SELECT name
2
+ FROM sqlite_master
3
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
4
+ 
5
+ SQL (0.000235) select sqlite_version(*)
6
+ SQL (0.000308) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
7
+ SQL (0.000229) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
8
+ SQL (0.000212)  SELECT name
9
+ FROM sqlite_master
10
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
11
+ 
12
+ SQL (0.000141) SELECT version FROM schema_migrations
13
+ Migrating to CreateUsers (1)
14
+ SQL (0.000093) SELECT version FROM schema_migrations
15
+ SQL (0.000400) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
16
+ SQL (0.000124) INSERT INTO schema_migrations (version) VALUES ('1')
17
+ SQL (0.000457)  SELECT name
18
+ FROM sqlite_master
19
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
20
+ 
21
+ SQL (0.000258) select sqlite_version(*)
22
+ SQL (0.000310) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
23
+ SQL (0.000221) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
24
+ SQL (0.000211)  SELECT name
25
+ FROM sqlite_master
26
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
27
+ 
28
+ SQL (0.000159) SELECT version FROM schema_migrations
29
+ Migrating to CreateUsers (1)
30
+ SQL (0.000138) SELECT version FROM schema_migrations
31
+ SQL (0.000404) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
32
+ SQL (0.000126) INSERT INTO schema_migrations (version) VALUES ('1')
33
+ SQL (0.000456)  SELECT name
34
+ FROM sqlite_master
35
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
36
+ 
37
+ SQL (0.000232) select sqlite_version(*)
38
+ SQL (0.000308) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
39
+ SQL (0.000224) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
40
+ SQL (0.000207)  SELECT name
41
+ FROM sqlite_master
42
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
43
+ 
44
+ SQL (0.000151) SELECT version FROM schema_migrations
45
+ Migrating to CreateUsers (1)
46
+ SQL (0.000095) SELECT version FROM schema_migrations
47
+ SQL (0.001146) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
48
+ SQL (0.000134) INSERT INTO schema_migrations (version) VALUES ('1')
49
+ SQL (0.000376)  SELECT name
50
+ FROM sqlite_master
51
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
52
+ 
53
+ SQL (0.000450)  SELECT name
54
+ FROM sqlite_master
55
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
56
+ 
57
+ SQL (0.000233) select sqlite_version(*)
58
+ SQL (0.000310) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
59
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
60
+ SQL (0.000207)  SELECT name
61
+ FROM sqlite_master
62
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
63
+ 
64
+ SQL (0.000131) SELECT version FROM schema_migrations
65
+ Migrating to CreateUsers (1)
66
+ SQL (0.000093) SELECT version FROM schema_migrations
67
+ SQL (0.000391) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
68
+ SQL (0.000137) INSERT INTO schema_migrations (version) VALUES ('1')
69
+ SQL (0.000488)  SELECT name
70
+ FROM sqlite_master
71
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
72
+ 
73
+ SQL (0.000325) select sqlite_version(*)
74
+ SQL (0.000391) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
75
+ SQL (0.000255) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
76
+ SQL (0.000233)  SELECT name
77
+ FROM sqlite_master
78
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
79
+ 
80
+ SQL (0.000137) SELECT version FROM schema_migrations
81
+ Migrating to CreateUsers (1)
82
+ SQL (0.000093) SELECT version FROM schema_migrations
83
+ SQL (0.000414) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
84
+ SQL (0.000121) INSERT INTO schema_migrations (version) VALUES ('1')
85
+ SQL (0.000453)  SELECT name
86
+ FROM sqlite_master
87
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
88
+ 
89
+ SQL (0.000239) select sqlite_version(*)
90
+ SQL (0.000314) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
91
+ SQL (0.000223) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
92
+ SQL (0.000214)  SELECT name
93
+ FROM sqlite_master
94
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
95
+ 
96
+ SQL (0.000138) SELECT version FROM schema_migrations
97
+ Migrating to CreateUsers (1)
98
+ SQL (0.000093) SELECT version FROM schema_migrations
99
+ SQL (0.000388) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
100
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
101
+ SQL (0.000456)  SELECT name
102
+ FROM sqlite_master
103
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
104
+ 
105
+ SQL (0.000228) select sqlite_version(*)
106
+ SQL (0.000311) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
107
+ SQL (0.000233) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
108
+ SQL (0.000214)  SELECT name
109
+ FROM sqlite_master
110
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
111
+ 
112
+ SQL (0.000130) SELECT version FROM schema_migrations
113
+ Migrating to CreateUsers (1)
114
+ SQL (0.000093) SELECT version FROM schema_migrations
115
+ SQL (0.000402) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
116
+ SQL (0.000127) INSERT INTO schema_migrations (version) VALUES ('1')
117
+ SQL (0.000473)  SELECT name
118
+ FROM sqlite_master
119
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
120
+ 
121
+ SQL (0.000261) select sqlite_version(*)
122
+ SQL (0.000309) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
123
+ SQL (0.000246) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
124
+ SQL (0.000210)  SELECT name
125
+ FROM sqlite_master
126
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
127
+ 
128
+ SQL (0.000142) SELECT version FROM schema_migrations
129
+ Migrating to CreateUsers (1)
130
+ SQL (0.000092) SELECT version FROM schema_migrations
131
+ SQL (0.000395) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
132
+ SQL (0.000125) INSERT INTO schema_migrations (version) VALUES ('1')
133
+ SQL (0.000469)  SELECT name
134
+ FROM sqlite_master
135
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
136
+ 
137
+ SQL (0.000258) select sqlite_version(*)
138
+ SQL (0.000313) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
139
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
140
+ SQL (0.000231)  SELECT name
141
+ FROM sqlite_master
142
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
143
+ 
144
+ SQL (0.000127) SELECT version FROM schema_migrations
145
+ Migrating to CreateUsers (1)
146
+ SQL (0.000095) SELECT version FROM schema_migrations
147
+ SQL (0.000462) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
148
+ SQL (0.000143) INSERT INTO schema_migrations (version) VALUES ('1')
149
+ SQL (0.000474)  SELECT name
150
+ FROM sqlite_master
151
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
152
+ 
153
+ SQL (0.001692) select sqlite_version(*)
154
+ SQL (0.000411) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
155
+ SQL (0.000271) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
156
+ SQL (0.000246)  SELECT name
157
+ FROM sqlite_master
158
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
159
+ 
160
+ SQL (0.000166) SELECT version FROM schema_migrations
161
+ Migrating to CreateUsers (1)
162
+ SQL (0.000110) SELECT version FROM schema_migrations
163
+ SQL (0.000423) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
164
+ SQL (0.000202) INSERT INTO schema_migrations (version) VALUES ('1')
165
+ SQL (0.000455)  SELECT name
166
+ FROM sqlite_master
167
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
168
+ 
169
+ SQL (0.000243) select sqlite_version(*)
170
+ SQL (0.000312) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
171
+ SQL (0.000248) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
172
+ SQL (0.000229)  SELECT name
173
+ FROM sqlite_master
174
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
175
+ 
176
+ SQL (0.000133) SELECT version FROM schema_migrations
177
+ Migrating to CreateUsers (1)
178
+ SQL (0.000093) SELECT version FROM schema_migrations
179
+ SQL (0.000412) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
180
+ SQL (0.000128) INSERT INTO schema_migrations (version) VALUES ('1')
181
+ SQL (0.000446)  SELECT name
182
+ FROM sqlite_master
183
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
184
+ 
185
+ SQL (0.000230) select sqlite_version(*)
186
+ SQL (0.000305) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
187
+ SQL (0.000246) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
188
+ SQL (0.000213)  SELECT name
189
+ FROM sqlite_master
190
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
191
+ 
192
+ SQL (0.000152) SELECT version FROM schema_migrations
193
+ Migrating to CreateUsers (1)
194
+ SQL (0.000124) SELECT version FROM schema_migrations
195
+ SQL (0.000438) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
196
+ SQL (0.000127) INSERT INTO schema_migrations (version) VALUES ('1')
197
+ SQL (0.000460)  SELECT name
198
+ FROM sqlite_master
199
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
200
+ 
201
+ SQL (0.000408) select sqlite_version(*)
202
+ SQL (0.000346) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
203
+ SQL (0.000225) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
204
+ SQL (0.000217)  SELECT name
205
+ FROM sqlite_master
206
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
207
+ 
208
+ SQL (0.000135) SELECT version FROM schema_migrations
209
+ Migrating to CreateUsers (1)
210
+ SQL (0.000092) SELECT version FROM schema_migrations
211
+ SQL (0.000391) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
212
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
213
+ SQL (0.000472)  SELECT name
214
+ FROM sqlite_master
215
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
216
+ 
217
+ SQL (0.000225) select sqlite_version(*)
218
+ SQL (0.000419) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
219
+ SQL (0.000225) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
220
+ SQL (0.000212)  SELECT name
221
+ FROM sqlite_master
222
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
223
+ 
224
+ SQL (0.000134) SELECT version FROM schema_migrations
225
+ Migrating to CreateUsers (1)
226
+ SQL (0.000092) SELECT version FROM schema_migrations
227
+ SQL (0.000424) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
228
+ SQL (0.000125) INSERT INTO schema_migrations (version) VALUES ('1')
229
+ SQL (0.000449)  SELECT name
230
+ FROM sqlite_master
231
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
232
+ 
233
+ SQL (0.000228) select sqlite_version(*)
234
+ SQL (0.000307) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
235
+ SQL (0.000227) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
236
+ SQL (0.000217)  SELECT name
237
+ FROM sqlite_master
238
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
239
+ 
240
+ SQL (0.000159) SELECT version FROM schema_migrations
241
+ Migrating to CreateUsers (1)
242
+ SQL (0.000094) SELECT version FROM schema_migrations
243
+ SQL (0.000430) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
244
+ SQL (0.000384) INSERT INTO schema_migrations (version) VALUES ('1')
245
+ SQL (0.000459)  SELECT name
246
+ FROM sqlite_master
247
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
248
+ 
249
+ SQL (0.000229) select sqlite_version(*)
250
+ SQL (0.000308) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
251
+ SQL (0.000224) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
252
+ SQL (0.000209)  SELECT name
253
+ FROM sqlite_master
254
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
255
+ 
256
+ SQL (0.000129) SELECT version FROM schema_migrations
257
+ Migrating to CreateUsers (1)
258
+ SQL (0.000092) SELECT version FROM schema_migrations
259
+ SQL (0.000392) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "name" varchar(255) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
260
+ SQL (0.000135) INSERT INTO schema_migrations (version) VALUES ('1')
261
+ SQL (0.000453)  SELECT name
262
+ FROM sqlite_master
263
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
264
+ 
265
+ SQL (0.000227) select sqlite_version(*)
266
+ SQL (0.000307) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
267
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
268
+ SQL (0.000207)  SELECT name
269
+ FROM sqlite_master
270
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
271
+ 
272
+ SQL (0.000151) SELECT version FROM schema_migrations
273
+ Migrating to CreateUsers (1)
274
+ SQL (0.000093) SELECT version FROM schema_migrations
275
+ SQL (0.000390) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
276
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
277
+ SQL (0.000473)  SELECT name
278
+ FROM sqlite_master
279
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
280
+ 
281
+ SQL (0.000228) select sqlite_version(*)
282
+ SQL (0.000319) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
283
+ SQL (0.000227) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
284
+ SQL (0.000213)  SELECT name
285
+ FROM sqlite_master
286
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
287
+ 
288
+ SQL (0.000152) SELECT version FROM schema_migrations
289
+ Migrating to CreateUsers (1)
290
+ SQL (0.000092) SELECT version FROM schema_migrations
291
+ SQL (0.000386) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
292
+ SQL (0.000121) INSERT INTO schema_migrations (version) VALUES ('1')
293
+ SQL (0.000454)  SELECT name
294
+ FROM sqlite_master
295
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
296
+ 
297
+ SQL (0.000225) select sqlite_version(*)
298
+ SQL (0.000303) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
299
+ SQL (0.000220) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
300
+ SQL (0.000209)  SELECT name
301
+ FROM sqlite_master
302
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
303
+ 
304
+ SQL (0.000148) SELECT version FROM schema_migrations
305
+ Migrating to CreateUsers (1)
306
+ SQL (0.000094) SELECT version FROM schema_migrations
307
+ SQL (0.000438) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
308
+ SQL (0.000170) INSERT INTO schema_migrations (version) VALUES ('1')
309
+ SQL (0.000449)  SELECT name
310
+ FROM sqlite_master
311
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
312
+ 
313
+ SQL (0.000235) select sqlite_version(*)
314
+ SQL (0.000315) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
315
+ SQL (0.000223) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
316
+ SQL (0.000210)  SELECT name
317
+ FROM sqlite_master
318
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
319
+ 
320
+ SQL (0.000154) SELECT version FROM schema_migrations
321
+ Migrating to CreateUsers (1)
322
+ SQL (0.000105) SELECT version FROM schema_migrations
323
+ SQL (0.000407) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
324
+ SQL (0.000123) INSERT INTO schema_migrations (version) VALUES ('1')
325
+ SQL (0.000485)  SELECT name
326
+ FROM sqlite_master
327
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
328
+ 
329
+ SQL (0.000264) select sqlite_version(*)
330
+ SQL (0.000312) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
331
+ SQL (0.000572) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
332
+ SQL (0.000237)  SELECT name
333
+ FROM sqlite_master
334
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
335
+ 
336
+ SQL (0.000130) SELECT version FROM schema_migrations
337
+ Migrating to CreateUsers (1)
338
+ SQL (0.000094) SELECT version FROM schema_migrations
339
+ SQL (0.000382) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
340
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
341
+ SQL (0.000452)  SELECT name
342
+ FROM sqlite_master
343
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
344
+ 
345
+ SQL (0.000229) select sqlite_version(*)
346
+ SQL (0.000307) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
347
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
348
+ SQL (0.000208)  SELECT name
349
+ FROM sqlite_master
350
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
351
+ 
352
+ SQL (0.000154) SELECT version FROM schema_migrations
353
+ Migrating to CreateUsers (1)
354
+ SQL (0.000093) SELECT version FROM schema_migrations
355
+ SQL (0.000387) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
356
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
357
+ SQL (0.000454)  SELECT name
358
+ FROM sqlite_master
359
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
360
+ 
361
+ SQL (0.000230) select sqlite_version(*)
362
+ SQL (0.000329) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
363
+ SQL (0.000225) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
364
+ SQL (0.000225)  SELECT name
365
+ FROM sqlite_master
366
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
367
+ 
368
+ SQL (0.000155) SELECT version FROM schema_migrations
369
+ Migrating to CreateUsers (1)
370
+ SQL (0.000104) SELECT version FROM schema_migrations
371
+ SQL (0.000411) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
372
+ SQL (0.000123) INSERT INTO schema_migrations (version) VALUES ('1')
373
+ SQL (0.000464)  SELECT name
374
+ FROM sqlite_master
375
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
376
+ 
377
+ SQL (0.000247) select sqlite_version(*)
378
+ SQL (0.000322) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
379
+ SQL (0.000253) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
380
+ SQL (0.000215)  SELECT name
381
+ FROM sqlite_master
382
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
383
+ 
384
+ SQL (0.000160) SELECT version FROM schema_migrations
385
+ Migrating to CreateUsers (1)
386
+ SQL (0.000095) SELECT version FROM schema_migrations
387
+ SQL (0.000395) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
388
+ SQL (0.000134) INSERT INTO schema_migrations (version) VALUES ('1')
389
+ SQL (0.000476)  SELECT name
390
+ FROM sqlite_master
391
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
392
+ 
393
+ SQL (0.000230) select sqlite_version(*)
394
+ SQL (0.000309) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
395
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
396
+ SQL (0.000210)  SELECT name
397
+ FROM sqlite_master
398
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
399
+ 
400
+ SQL (0.000150) SELECT version FROM schema_migrations
401
+ Migrating to CreateUsers (1)
402
+ SQL (0.000092) SELECT version FROM schema_migrations
403
+ SQL (0.000394) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
404
+ SQL (0.000121) INSERT INTO schema_migrations (version) VALUES ('1')
405
+ SQL (0.000457)  SELECT name
406
+ FROM sqlite_master
407
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
408
+ 
409
+ SQL (0.000235) select sqlite_version(*)
410
+ SQL (0.000309) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
411
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
412
+ SQL (0.000210)  SELECT name
413
+ FROM sqlite_master
414
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
415
+ 
416
+ SQL (0.000132) SELECT version FROM schema_migrations
417
+ Migrating to CreateUsers (1)
418
+ SQL (0.000092) SELECT version FROM schema_migrations
419
+ SQL (0.000381) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
420
+ SQL (0.000123) INSERT INTO schema_migrations (version) VALUES ('1')
421
+ SQL (0.000462)  SELECT name
422
+ FROM sqlite_master
423
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
424
+ 
425
+ SQL (0.000238) select sqlite_version(*)
426
+ SQL (0.000315) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
427
+ SQL (0.000224) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
428
+ SQL (0.000302)  SELECT name
429
+ FROM sqlite_master
430
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
431
+ 
432
+ SQL (0.000163) SELECT version FROM schema_migrations
433
+ Migrating to CreateUsers (1)
434
+ SQL (0.000094) SELECT version FROM schema_migrations
435
+ SQL (0.000395) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
436
+ SQL (0.000145) INSERT INTO schema_migrations (version) VALUES ('1')
437
+ SQL (0.000464)  SELECT name
438
+ FROM sqlite_master
439
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
440
+ 
441
+ SQL (0.000258) select sqlite_version(*)
442
+ SQL (0.000309) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
443
+ SQL (0.000223) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
444
+ SQL (0.000301)  SELECT name
445
+ FROM sqlite_master
446
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
447
+ 
448
+ SQL (0.000168) SELECT version FROM schema_migrations
449
+ Migrating to CreateUsers (1)
450
+ SQL (0.000114) SELECT version FROM schema_migrations
451
+ SQL (0.000440) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
452
+ SQL (0.000140) INSERT INTO schema_migrations (version) VALUES ('1')
453
+ SQL (0.000466)  SELECT name
454
+ FROM sqlite_master
455
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
456
+ 
457
+ SQL (0.000257) select sqlite_version(*)
458
+ SQL (0.000309) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
459
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
460
+ SQL (0.000233)  SELECT name
461
+ FROM sqlite_master
462
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
463
+ 
464
+ SQL (0.000230) SELECT version FROM schema_migrations
465
+ Migrating to CreateUsers (1)
466
+ SQL (0.000109) SELECT version FROM schema_migrations
467
+ SQL (0.000387) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
468
+ SQL (0.000122) INSERT INTO schema_migrations (version) VALUES ('1')
469
+ SQL (0.000454)  SELECT name
470
+ FROM sqlite_master
471
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
472
+ 
473
+ SQL (0.000224) select sqlite_version(*)
474
+ SQL (0.000307) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
475
+ SQL (0.000221) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
476
+ SQL (0.000207)  SELECT name
477
+ FROM sqlite_master
478
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
479
+ 
480
+ SQL (0.000135) SELECT version FROM schema_migrations
481
+ Migrating to CreateUsers (1)
482
+ SQL (0.000093) SELECT version FROM schema_migrations
483
+ SQL (0.000383) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
484
+ SQL (0.000124) INSERT INTO schema_migrations (version) VALUES ('1')
485
+ SQL (0.000485)  SELECT name
486
+ FROM sqlite_master
487
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
488
+ 
489
+ SQL (0.000234) select sqlite_version(*)
490
+ SQL (0.000312) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
491
+ SQL (0.000222) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
492
+ SQL (0.000210)  SELECT name
493
+ FROM sqlite_master
494
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
495
+ 
496
+ SQL (0.000144) SELECT version FROM schema_migrations
497
+ Migrating to CreateUsers (1)
498
+ SQL (0.000094) SELECT version FROM schema_migrations
499
+ SQL (0.000404) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
500
+ SQL (0.000137) INSERT INTO schema_migrations (version) VALUES ('1')
501
+ SQL (0.000458)  SELECT name
502
+ FROM sqlite_master
503
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
504
+ 
505
+ SQL (0.000236) select sqlite_version(*)
506
+ SQL (0.000311) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
507
+ SQL (0.000221) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
508
+ SQL (0.000215)  SELECT name
509
+ FROM sqlite_master
510
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
511
+ 
512
+ SQL (0.000131) SELECT version FROM schema_migrations
513
+ Migrating to CreateUsers (1)
514
+ SQL (0.000094) SELECT version FROM schema_migrations
515
+ SQL (0.000377) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
516
+ SQL (0.000124) INSERT INTO schema_migrations (version) VALUES ('1')
517
+ SQL (0.000458)  SELECT name
518
+ FROM sqlite_master
519
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
520
+ 
521
+ SQL (0.000259) select sqlite_version(*)
522
+ SQL (0.000386) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
523
+ SQL (0.000230) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
524
+ SQL (0.001433)  SELECT name
525
+ FROM sqlite_master
526
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
527
+ 
528
+ SQL (0.000158) SELECT version FROM schema_migrations
529
+ Migrating to CreateUsers (1)
530
+ SQL (0.000113) SELECT version FROM schema_migrations
531
+ SQL (0.000410) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
532
+ SQL (0.000132) INSERT INTO schema_migrations (version) VALUES ('1')
533
+ SQL (0.000465)  SELECT name
534
+ FROM sqlite_master
535
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
536
+ 
537
+ SQL (0.000248) select sqlite_version(*)
538
+ SQL (0.000323) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
539
+ SQL (0.000225) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
540
+ SQL (0.000221)  SELECT name
541
+ FROM sqlite_master
542
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
543
+ 
544
+ SQL (0.000174) SELECT version FROM schema_migrations
545
+ Migrating to CreateUsers (1)
546
+ SQL (0.000098) SELECT version FROM schema_migrations
547
+ SQL (0.000397) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
548
+ SQL (0.000126) INSERT INTO schema_migrations (version) VALUES ('1')
549
+ SQL (0.000453)  SELECT name
550
+ FROM sqlite_master
551
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
552
+ 
553
+ SQL (0.000231) select sqlite_version(*)
554
+ SQL (0.000310) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
555
+ SQL (0.000223) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
556
+ SQL (0.000210)  SELECT name
557
+ FROM sqlite_master
558
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
559
+ 
560
+ SQL (0.000137) SELECT version FROM schema_migrations
561
+ Migrating to CreateUsers (1)
562
+ SQL (0.000094) SELECT version FROM schema_migrations
563
+ SQL (0.000392) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
564
+ SQL (0.000135) INSERT INTO schema_migrations (version) VALUES ('1')
565
+ SQL (0.000406)  SELECT name
566
+ FROM sqlite_master
567
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
568
+ 
569
+ SQL (0.000263) select sqlite_version(*)
570
+ SQL (0.000310) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
571
+ SQL (0.000225) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
572
+ SQL (0.000218)  SELECT name
573
+ FROM sqlite_master
574
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
575
+ 
576
+ SQL (0.000158) SELECT version FROM schema_migrations
577
+ Migrating to CreateUsers (1)
578
+ SQL (0.000098) SELECT version FROM schema_migrations
579
+ SQL (0.000437) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "login" varchar(12) DEFAULT NULL NULL, "password" varchar(16) DEFAULT NULL NULL, "biography" text DEFAULT NULL NULL) 
580
+ SQL (0.000131) INSERT INTO schema_migrations (version) VALUES ('1')
@@ -0,0 +1,7 @@
1
+ # Load the plugin testing framework
2
+ $:.unshift("#{File.dirname(__FILE__)}/../../plugin_test_helper/lib")
3
+ require 'rubygems'
4
+ require 'plugin_test_helper'
5
+
6
+ # Run the migrations
7
+ ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
@@ -0,0 +1,89 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class FormHelperWithoutConstraintsTest < Test::Unit::TestCase
4
+ include ActionView::Helpers::TagHelper
5
+ include ActionView::Helpers::FormHelper
6
+
7
+ def setup
8
+ @user = User.new
9
+ end
10
+
11
+ def test_should_not_add_maxlength_for_text_field
12
+ assert_equal '<input id="user_biography" name="user[biography]" size="30" type="text" />', text_field(:user, :biography)
13
+ end
14
+
15
+ def test_should_not_add_maxlength_for_password_field
16
+ assert_equal '<input id="user_biography" name="user[biography]" size="30" type="password" />', password_field(:user, :biography)
17
+ end
18
+ end
19
+
20
+ class FormHelperWithValidationConstraintsTest < Test::Unit::TestCase
21
+ include ActionView::Helpers::TagHelper
22
+ include ActionView::Helpers::FormHelper
23
+
24
+ def setup
25
+ User.validates_length_of :biography, :maximum => 120
26
+ User.validates_length_of :password, :maximum => 14
27
+
28
+ @user = User.new
29
+ end
30
+
31
+ def test_should_not_add_maxlength_for_text_area
32
+ assert_equal '<textarea cols="40" id="user_biography" name="user[biography]" rows="20"></textarea>', text_area(:user, :biography)
33
+ end
34
+
35
+ def test_should_not_add_maxlength_for_hidden_field
36
+ assert_equal '<input id="user_password" name="user[password]" type="hidden" />', hidden_field(:user, :password)
37
+ end
38
+
39
+ def test_should_add_maxlength_for_password_field
40
+ assert_equal '<input id="user_password" maxlength="14" name="user[password]" size="30" type="password" />', password_field(:user, :password)
41
+ end
42
+
43
+ def test_should_add_maxlength_for_text_field
44
+ assert_equal '<input id="user_biography" maxlength="120" name="user[biography]" size="30" type="text" />', text_field(:user, :biography)
45
+ end
46
+
47
+ def test_should_allow_maxlength_to_be_overridden
48
+ assert_equal '<input id="user_biography" maxlength="100" name="user[biography]" size="100" type="text" />', text_field(:user, :biography, :maxlength => 100)
49
+ end
50
+
51
+ def teardown
52
+ User.class_eval do
53
+ ActiveRecord::Validations::VALIDATIONS.each do |validation|
54
+ instance_variable_set("@#{validation}_callbacks", nil)
55
+ end
56
+ end
57
+
58
+ User.smart_length_constraints.clear
59
+ end
60
+ end
61
+
62
+ class FormHelperWithColumnConstraintsTest < Test::Unit::TestCase
63
+ include ActionView::Helpers::TagHelper
64
+ include ActionView::Helpers::FormHelper
65
+
66
+ def setup
67
+ @user = User.new
68
+ end
69
+
70
+ def test_should_not_add_maxlength_for_text_area
71
+ assert_equal '<textarea cols="40" id="user_login" name="user[login]" rows="20"></textarea>', text_area(:user, :login)
72
+ end
73
+
74
+ def test_should_not_add_maxlength_for_hidden_field
75
+ assert_equal '<input id="user_password" name="user[password]" type="hidden" />', hidden_field(:user, :password)
76
+ end
77
+
78
+ def test_should_add_maxlength_for_password_field
79
+ assert_equal '<input id="user_password" maxlength="16" name="user[password]" size="30" type="password" />', password_field(:user, :password)
80
+ end
81
+
82
+ def test_should_add_maxlength_for_text_field
83
+ assert_equal '<input id="user_login" maxlength="12" name="user[login]" size="30" type="text" />', text_field(:user, :login)
84
+ end
85
+
86
+ def test_should_allow_maxlength_to_be_overridden
87
+ assert_equal '<input id="user_login" maxlength="100" name="user[login]" size="100" type="text" />', text_field(:user, :login, :maxlength => 100)
88
+ end
89
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ModelWithoutLengthValidationsTest < Test::Unit::TestCase
4
+ def test_should_not_have_any_constraints
5
+ assert User.smart_length_constraints.empty?
6
+ end
7
+ end
8
+
9
+ class ModelWithLengthValidationsTest < Test::Unit::TestCase
10
+ def test_should_not_track_constraint_for_minimum
11
+ User.validates_length_of :name, :minimum => 1
12
+ assert_nil User.smart_length_constraints['name']
13
+ end
14
+
15
+ def test_should_track_constraint_for_within
16
+ User.validates_length_of :name, :within => 1..10
17
+ assert_equal 10, User.smart_length_constraints['name']
18
+ end
19
+
20
+ def test_should_track_constraint_for_in
21
+ User.validates_length_of :name, :in => 1..10
22
+ assert_equal 10, User.smart_length_constraints['name']
23
+ end
24
+
25
+ def test_should_track_constraint_for_maximum
26
+ User.validates_length_of :name, :maximum => 10
27
+ assert_equal 10, User.smart_length_constraints['name']
28
+ end
29
+
30
+ def test_should_track_validation_for_is
31
+ User.validates_length_of :name, :is => 10
32
+ assert_equal 10, User.smart_length_constraints['name']
33
+ end
34
+
35
+ def teardown
36
+ User.class_eval do
37
+ ActiveRecord::Validations::VALIDATIONS.each do |validation|
38
+ instance_variable_set("@#{validation}_callbacks", nil)
39
+ end
40
+ end
41
+
42
+ User.smart_length_constraints.clear
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smart_field_constraints
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aaron Pfeifer
8
+ autorequire: smart_field_constraints
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-05 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: aaron@pluginaweek.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/smart_field_constraints
26
+ - lib/smart_field_constraints/extensions
27
+ - lib/smart_field_constraints/extensions/form_helper.rb
28
+ - lib/smart_field_constraints/extensions/validations.rb
29
+ - lib/smart_field_constraints.rb
30
+ - test/app_root
31
+ - test/app_root/log
32
+ - test/app_root/log/in_memory.log
33
+ - test/app_root/db
34
+ - test/app_root/db/migrate
35
+ - test/app_root/db/migrate/001_create_users.rb
36
+ - test/app_root/app
37
+ - test/app_root/app/models
38
+ - test/app_root/app/models/user.rb
39
+ - test/test_helper.rb
40
+ - test/unit
41
+ - test/unit/form_helper_test.rb
42
+ - test/unit/validations_test.rb
43
+ - CHANGELOG
44
+ - init.rb
45
+ - LICENSE
46
+ - Rakefile
47
+ - README
48
+ has_rdoc: true
49
+ homepage: http://www.pluginaweek.org
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.1.0
71
+ signing_key:
72
+ specification_version: 2
73
+ summary: Intelligently applies a maxlength attribute for text fields based on column constraints and validations
74
+ test_files:
75
+ - test/unit/form_helper_test.rb
76
+ - test/unit/validations_test.rb