datamapper 0.3.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/History.txt +0 -0
  2. data/Manifest.txt +5 -0
  3. data/README.txt +11 -0
  4. data/Rakefile +70 -0
  5. data/lib/datamapper.rb +8 -0
  6. metadata +152 -319
  7. data/CHANGELOG +0 -145
  8. data/FAQ +0 -96
  9. data/MIT-LICENSE +0 -22
  10. data/QUICKLINKS +0 -12
  11. data/README +0 -105
  12. data/environment.rb +0 -62
  13. data/example.rb +0 -156
  14. data/lib/data_mapper.rb +0 -88
  15. data/lib/data_mapper/adapters/abstract_adapter.rb +0 -43
  16. data/lib/data_mapper/adapters/data_object_adapter.rb +0 -480
  17. data/lib/data_mapper/adapters/mysql_adapter.rb +0 -72
  18. data/lib/data_mapper/adapters/postgresql_adapter.rb +0 -258
  19. data/lib/data_mapper/adapters/sql/coersion.rb +0 -134
  20. data/lib/data_mapper/adapters/sql/commands/load_command.rb +0 -545
  21. data/lib/data_mapper/adapters/sql/mappings/associations_set.rb +0 -34
  22. data/lib/data_mapper/adapters/sql/mappings/column.rb +0 -279
  23. data/lib/data_mapper/adapters/sql/mappings/conditions.rb +0 -172
  24. data/lib/data_mapper/adapters/sql/mappings/schema.rb +0 -60
  25. data/lib/data_mapper/adapters/sql/mappings/table.rb +0 -459
  26. data/lib/data_mapper/adapters/sql/quoting.rb +0 -24
  27. data/lib/data_mapper/adapters/sqlite3_adapter.rb +0 -159
  28. data/lib/data_mapper/associations.rb +0 -106
  29. data/lib/data_mapper/associations/belongs_to_association.rb +0 -160
  30. data/lib/data_mapper/associations/has_and_belongs_to_many_association.rb +0 -437
  31. data/lib/data_mapper/associations/has_many_association.rb +0 -283
  32. data/lib/data_mapper/associations/has_n_association.rb +0 -143
  33. data/lib/data_mapper/associations/reference.rb +0 -47
  34. data/lib/data_mapper/attributes.rb +0 -73
  35. data/lib/data_mapper/auto_migrations.rb +0 -36
  36. data/lib/data_mapper/base.rb +0 -17
  37. data/lib/data_mapper/callbacks.rb +0 -107
  38. data/lib/data_mapper/context.rb +0 -112
  39. data/lib/data_mapper/database.rb +0 -234
  40. data/lib/data_mapper/dependency_queue.rb +0 -28
  41. data/lib/data_mapper/embedded_value.rb +0 -145
  42. data/lib/data_mapper/identity_map.rb +0 -47
  43. data/lib/data_mapper/is/tree.rb +0 -121
  44. data/lib/data_mapper/migration.rb +0 -155
  45. data/lib/data_mapper/persistence.rb +0 -852
  46. data/lib/data_mapper/property.rb +0 -310
  47. data/lib/data_mapper/query.rb +0 -164
  48. data/lib/data_mapper/support/blank.rb +0 -35
  49. data/lib/data_mapper/support/connection_pool.rb +0 -117
  50. data/lib/data_mapper/support/enumerable.rb +0 -35
  51. data/lib/data_mapper/support/errors.rb +0 -16
  52. data/lib/data_mapper/support/inflector.rb +0 -265
  53. data/lib/data_mapper/support/object.rb +0 -54
  54. data/lib/data_mapper/support/serialization.rb +0 -96
  55. data/lib/data_mapper/support/silence.rb +0 -10
  56. data/lib/data_mapper/support/string.rb +0 -72
  57. data/lib/data_mapper/support/struct.rb +0 -7
  58. data/lib/data_mapper/support/symbol.rb +0 -82
  59. data/lib/data_mapper/support/typed_set.rb +0 -65
  60. data/lib/data_mapper/types/base.rb +0 -44
  61. data/lib/data_mapper/types/string.rb +0 -34
  62. data/lib/data_mapper/validatable_extensions/errors.rb +0 -12
  63. data/lib/data_mapper/validatable_extensions/macros.rb +0 -7
  64. data/lib/data_mapper/validatable_extensions/validatable_instance_methods.rb +0 -62
  65. data/lib/data_mapper/validatable_extensions/validation_base.rb +0 -18
  66. data/lib/data_mapper/validatable_extensions/validations/formats/email.rb +0 -43
  67. data/lib/data_mapper/validatable_extensions/validations/validates_acceptance_of.rb +0 -7
  68. data/lib/data_mapper/validatable_extensions/validations/validates_confirmation_of.rb +0 -7
  69. data/lib/data_mapper/validatable_extensions/validations/validates_each.rb +0 -7
  70. data/lib/data_mapper/validatable_extensions/validations/validates_format_of.rb +0 -28
  71. data/lib/data_mapper/validatable_extensions/validations/validates_length_of.rb +0 -15
  72. data/lib/data_mapper/validatable_extensions/validations/validates_numericality_of.rb +0 -7
  73. data/lib/data_mapper/validatable_extensions/validations/validates_presence_of.rb +0 -7
  74. data/lib/data_mapper/validatable_extensions/validations/validates_true_for.rb +0 -7
  75. data/lib/data_mapper/validatable_extensions/validations/validates_uniqueness_of.rb +0 -40
  76. data/lib/data_mapper/validations.rb +0 -20
  77. data/lib/data_mapper/validations/number_validator.rb +0 -40
  78. data/lib/data_mapper/validations/string_validator.rb +0 -20
  79. data/lib/data_mapper/validations/validator.rb +0 -13
  80. data/performance.rb +0 -307
  81. data/plugins/can_has_sphinx/LICENSE +0 -23
  82. data/plugins/can_has_sphinx/README +0 -4
  83. data/plugins/can_has_sphinx/REVISION +0 -1
  84. data/plugins/can_has_sphinx/Rakefile +0 -22
  85. data/plugins/can_has_sphinx/init.rb +0 -1
  86. data/plugins/can_has_sphinx/install.rb +0 -1
  87. data/plugins/can_has_sphinx/lib/acts_as_sphinx.rb +0 -123
  88. data/plugins/can_has_sphinx/lib/sphinx.rb +0 -460
  89. data/plugins/can_has_sphinx/scripts/sphinx.sh +0 -47
  90. data/plugins/can_has_sphinx/tasks/acts_as_sphinx_tasks.rake +0 -41
  91. data/profile_data_mapper.rb +0 -40
  92. data/rakefile.rb +0 -159
  93. data/spec/acts_as_tree_spec.rb +0 -67
  94. data/spec/adapters/data_object_adapter_spec.rb +0 -31
  95. data/spec/associations/belongs_to_association_spec.rb +0 -98
  96. data/spec/associations/has_and_belongs_to_many_association_spec.rb +0 -377
  97. data/spec/associations/has_many_association_spec.rb +0 -337
  98. data/spec/attributes_spec.rb +0 -52
  99. data/spec/auto_migrations_spec.rb +0 -101
  100. data/spec/callbacks_spec.rb +0 -186
  101. data/spec/can_has_sphinx.rb +0 -5
  102. data/spec/coersion_spec.rb +0 -41
  103. data/spec/column_spec.rb +0 -114
  104. data/spec/count_command_spec.rb +0 -45
  105. data/spec/database_spec.rb +0 -18
  106. data/spec/dataobjects_spec.rb +0 -27
  107. data/spec/delete_command_spec.rb +0 -11
  108. data/spec/dependency_spec.rb +0 -29
  109. data/spec/embedded_value_spec.rb +0 -161
  110. data/spec/fixtures/animals.yaml +0 -33
  111. data/spec/fixtures/animals_exhibits.yaml +0 -2
  112. data/spec/fixtures/careers.yaml +0 -5
  113. data/spec/fixtures/comments.yaml +0 -1
  114. data/spec/fixtures/exhibits.yaml +0 -90
  115. data/spec/fixtures/fruit.yaml +0 -6
  116. data/spec/fixtures/people.yaml +0 -37
  117. data/spec/fixtures/posts.yaml +0 -3
  118. data/spec/fixtures/projects.yaml +0 -13
  119. data/spec/fixtures/sections.yaml +0 -5
  120. data/spec/fixtures/serializers.yaml +0 -6
  121. data/spec/fixtures/tasks.yaml +0 -6
  122. data/spec/fixtures/tasks_tasks.yaml +0 -2
  123. data/spec/fixtures/tomatoes.yaml +0 -1
  124. data/spec/fixtures/users.yaml +0 -1
  125. data/spec/fixtures/zoos.yaml +0 -24
  126. data/spec/is_a_tree_spec.rb +0 -149
  127. data/spec/legacy_spec.rb +0 -16
  128. data/spec/load_command_spec.rb +0 -322
  129. data/spec/magic_columns_spec.rb +0 -26
  130. data/spec/migration_spec.rb +0 -267
  131. data/spec/mock_adapter.rb +0 -20
  132. data/spec/models/animal.rb +0 -12
  133. data/spec/models/candidate.rb +0 -8
  134. data/spec/models/career.rb +0 -7
  135. data/spec/models/chain.rb +0 -8
  136. data/spec/models/comment.rb +0 -6
  137. data/spec/models/exhibit.rb +0 -14
  138. data/spec/models/fence.rb +0 -7
  139. data/spec/models/fruit.rb +0 -8
  140. data/spec/models/job.rb +0 -8
  141. data/spec/models/person.rb +0 -30
  142. data/spec/models/post.rb +0 -14
  143. data/spec/models/project.rb +0 -41
  144. data/spec/models/sales_person.rb +0 -5
  145. data/spec/models/section.rb +0 -8
  146. data/spec/models/serializer.rb +0 -5
  147. data/spec/models/task.rb +0 -9
  148. data/spec/models/tomato.rb +0 -27
  149. data/spec/models/user.rb +0 -12
  150. data/spec/models/zoo.rb +0 -13
  151. data/spec/natural_key_spec.rb +0 -36
  152. data/spec/paranoia_spec.rb +0 -38
  153. data/spec/persistence_spec.rb +0 -479
  154. data/spec/postgres_spec.rb +0 -96
  155. data/spec/property_spec.rb +0 -151
  156. data/spec/query_spec.rb +0 -77
  157. data/spec/save_command_spec.rb +0 -94
  158. data/spec/schema_spec.rb +0 -8
  159. data/spec/serialize_spec.rb +0 -19
  160. data/spec/single_table_inheritance_spec.rb +0 -43
  161. data/spec/spec_helper.rb +0 -45
  162. data/spec/support/blank_spec.rb +0 -8
  163. data/spec/support/inflector_spec.rb +0 -41
  164. data/spec/support/object_spec.rb +0 -9
  165. data/spec/support/serialization_spec.rb +0 -61
  166. data/spec/support/silence_spec.rb +0 -15
  167. data/spec/support/string_spec.rb +0 -7
  168. data/spec/support/struct_spec.rb +0 -12
  169. data/spec/support/typed_set_spec.rb +0 -66
  170. data/spec/symbolic_operators_spec.rb +0 -27
  171. data/spec/table_spec.rb +0 -79
  172. data/spec/types/string.rb +0 -81
  173. data/spec/validates_confirmation_of_spec.rb +0 -55
  174. data/spec/validates_format_of_spec.rb +0 -78
  175. data/spec/validates_length_of_spec.rb +0 -117
  176. data/spec/validates_uniqueness_of_spec.rb +0 -92
  177. data/spec/validations/number_validator.rb +0 -59
  178. data/spec/validations/string_validator.rb +0 -14
  179. data/spec/validations_spec.rb +0 -141
  180. data/tasks/fixtures.rb +0 -53
@@ -1,60 +0,0 @@
1
- require File.dirname(__FILE__) + '/table'
2
-
3
- module DataMapper
4
- module Adapters
5
- module Sql
6
- module Mappings
7
-
8
- class Schema
9
-
10
- attr_reader :name
11
-
12
- def initialize(adapter, database_name)
13
- @name = database_name
14
- @adapter = adapter
15
- @tables = Hash.new { |h,k| h[k] = adapter.class::Mappings::Table.new(@adapter, k) }
16
- end
17
-
18
- def [](klass)
19
- @tables[klass]
20
- end
21
-
22
- def each
23
- @tables.values.each do |table|
24
- yield table
25
- end
26
- end
27
-
28
- def delete(table)
29
- @tables.delete(table.name)
30
- end
31
-
32
- def <<(table)
33
- @tables[table.name] = table
34
- end
35
-
36
- def to_tables_sql
37
- @to_column_exists_sql || @to_column_exists_sql = <<-EOS.compress_lines
38
- SELECT TABLE_NAME
39
- FROM INFORMATION_SCHEMA.TABLES
40
- WHERE TABLE_SCHEMA LIKE ?
41
- EOS
42
- end
43
-
44
- def get_database_tables(schema = "%")
45
- tables = []
46
- @adapter.connection do |db|
47
- command = db.create_command(to_tables_sql)
48
- command.execute_reader(schema) do |reader|
49
- tables = reader.map { @adapter.class::Mappings::Table.new(@adapter, reader.item(0)) }
50
- end
51
- end
52
- tables
53
- end
54
-
55
- end
56
-
57
- end
58
- end
59
- end
60
- end
@@ -1,459 +0,0 @@
1
- require File.dirname(__FILE__) + '/column'
2
- require File.dirname(__FILE__) + '/conditions'
3
- require File.dirname(__FILE__) + '/associations_set'
4
-
5
- module DataMapper
6
- module Adapters
7
- module Sql
8
- module Mappings
9
-
10
- class Table
11
-
12
- attr_reader :klass, :name, :indexes, :composite_indexes
13
-
14
- def initialize(adapter, klass_or_name)
15
- raise "\"klass_or_name\" must not be nil!" if klass_or_name.nil?
16
-
17
- @klass = klass_or_name.kind_of?(String) ? nil : klass_or_name
18
- @klass_or_name = klass_or_name
19
-
20
- @adapter = adapter
21
-
22
- @temporary = false
23
- @columns = SortedSet.new
24
- @columns_hash = Hash.new { |h,k| h[k] = columns.find { |c| c.name == k } }
25
-
26
- @associations = AssociationsSet.new
27
-
28
- @multi_class = false
29
- @paranoid = false
30
- @paranoid_column = nil
31
-
32
- if @klass && @klass.respond_to?(:persistent?) && @klass.superclass.respond_to?(:persistent?)
33
- super_table = @adapter.table(@klass.superclass)
34
-
35
- super_table.columns.each do |column|
36
- self.add_column(column.name, column.type, column.options)
37
- end
38
-
39
- super_table.associations.each do |association|
40
- @associations << association
41
- end
42
- end
43
- end
44
-
45
- def schema
46
- @schema || @schema = @adapter.schema
47
- end
48
-
49
- def conditions(args)
50
- Conditions.new(self, @adapter, @associations.empty?, args)
51
- end
52
-
53
- def paranoid?
54
- @paranoid
55
- end
56
-
57
- def paranoid_column
58
- @paranoid_column
59
- end
60
-
61
- def multi_class?
62
- @multi_class
63
- end
64
-
65
- def type_column
66
- @type_column
67
- end
68
-
69
- def temporary?
70
- @temporary
71
- end
72
-
73
- def temporary=(value)
74
- @temporary = value
75
- end
76
-
77
- def associations
78
- @associations
79
- end
80
-
81
- def activate_associations!(force = false)
82
- @associations.each do |association|
83
- association.activate! force
84
- end
85
- end
86
-
87
- def reflect_columns
88
- @adapter.reflect_columns(self)
89
- end
90
-
91
- def columns
92
- key if @key.nil?
93
- class << self
94
- attr_reader :columns
95
- end
96
-
97
- self.columns
98
- end
99
-
100
- def mapped_column_exists?(column_name)
101
- @columns.each {|column| return true if column.name == column_name}
102
- false
103
- end
104
-
105
- def exists?
106
- @adapter.connection do |db|
107
- command = db.create_command(to_exists_sql)
108
- command.execute_reader(name, schema.name) do |reader|
109
- reader.has_rows?
110
- end
111
- end
112
- end
113
-
114
- def drop!
115
- if exists?
116
- @adapter.connection do |db|
117
- result = db.create_command(to_drop_sql).execute_non_query
118
- database.identity_map.clear!(name)
119
- schema.delete(self)
120
- true
121
- end
122
- else
123
- false
124
- end
125
- end
126
-
127
- def create!(force = false)
128
- if exists?
129
- if force
130
- drop!
131
- create!
132
- else
133
- false
134
- end
135
- else
136
- @adapter.connection do |db|
137
- db.create_command(to_create_sql).execute_non_query
138
- index_queries = to_create_index_sql + to_create_composite_index_sql
139
- index_queries.each { |q| db.create_command(q).execute_non_query }
140
- schema << self
141
- true
142
- end
143
- end
144
- end
145
-
146
- def delete_all!
147
- @adapter.connection do |db|
148
- db.create_command("DELETE FROM #{to_sql}").execute_non_query
149
- end
150
- database.identity_map.clear!(name)
151
- end
152
-
153
- def truncate!
154
- @adapter.connection do |db|
155
- result = db.create_command(to_truncate_sql).execute_non_query
156
- database.identity_map.clear!(name)
157
- result.to_i > 0
158
- end
159
- end
160
-
161
- def count(args={})
162
- sql = "SELECT COUNT(*) AS row_count FROM #{to_sql}"
163
- parameters = []
164
-
165
- paramsql, *parameters = conditions(args).to_params_sql
166
- sql << paramsql #gotta shift it in
167
-
168
- @adapter.connection do |db|
169
- command = db.create_command(sql)
170
- command.execute_reader(*parameters) do |reader|
171
- if reader.has_rows?
172
- reader.current_row.first.to_i
173
- else
174
- 0
175
- end
176
- end
177
- end
178
- end
179
-
180
- def insert(hash)
181
- @adapter.connection do |db|
182
-
183
- columns_to_insert = []
184
- values = []
185
-
186
- hash.each_pair do |k,v|
187
- column = self[k.to_sym]
188
- columns_to_insert << (column ? column.to_sql : k)
189
- values << v
190
- end
191
-
192
- command = db.create_command("INSERT INTO #{to_sql} (#{columns_to_insert.join(', ')}) VALUES (#{values.map { '?' }.join(', ')})")
193
- command.execute_non_query(*values)
194
- end
195
- end
196
-
197
- def key
198
- @key || begin
199
- @key = @columns.find { |column| column.key? }
200
-
201
- if @key.nil?
202
- unless @klass.nil?
203
- @klass.send(:property, :id, :integer, :serial => true, :ordinal => -1)
204
- @key = self[:id]
205
- else
206
- @key = add_column(:id, :integer, :serial => true, :ordinal => -1)
207
- end
208
- end
209
-
210
- @key
211
- end
212
-
213
- class << self
214
- attr_accessor :key
215
- end
216
- Persistence::dependencies.resolve!
217
-
218
- self.key
219
- end
220
-
221
- def keys
222
- @keys || begin
223
- @keys = @columns.select { |column| column.key? }
224
- end
225
- end
226
-
227
- def indexes
228
- @indexes || begin
229
- @indexes = @columns.select { |column| column.index? }
230
- end
231
- end
232
-
233
- # Add a composite index to the table.
234
- # +index_columns+ should be an array including each column name.
235
- def add_composite_index(index_columns = [], unique = false)
236
- @composite_indexes ||= []
237
- @composite_indexes << [index_columns, unique] # add paired tuple with the index
238
- end
239
-
240
- def add_column(column_name, type, options = {})
241
-
242
- column_ordinal = if options.is_a?(Hash) && options.has_key?(:ordinal)
243
- options.delete(:ordinal)
244
- else
245
- @columns.size
246
- end
247
-
248
- column = @adapter.class::Mappings::Column.new(@adapter, self, column_name, type, column_ordinal, options)
249
- @columns << column
250
-
251
- if column_name == :type
252
- @multi_class = true
253
- @type_column = column
254
- end
255
-
256
- if column_name.to_s =~ /^deleted\_(at|on)$/
257
- @paranoid = true
258
- @paranoid_column = column
259
- end
260
-
261
- self.flush_sql_caches!
262
- @columns_hash.clear
263
-
264
- return column
265
- end
266
-
267
- def [](column_name)
268
- @columns_hash[column_name.to_sym]
269
- end
270
-
271
- def name
272
- @name || @name = begin
273
- if @custom_name
274
- @custom_name
275
- elsif @klass_or_name.kind_of?(String)
276
- @klass_or_name
277
- elsif @klass_or_name.kind_of?(Class)
278
- persistent_ancestor = @klass_or_name.superclass.respond_to?(:persistent?)
279
- if @klass_or_name.superclass.respond_to?(:persistent?)
280
- @adapter.table(@klass_or_name.superclass).name
281
- else
282
- Inflector.tableize(@klass_or_name.name)
283
- end
284
- else
285
- raise "+klass_or_name+ (#{@klass_or_name.inspect}) must be a Class or a string containing the name of a table"
286
- end
287
- end.freeze
288
- end
289
-
290
- def name=(value)
291
- flush_sql_caches!
292
- @custom_name = value
293
- self.name
294
- end
295
-
296
- def default_foreign_key
297
- @default_foreign_key ||= Inflector.foreign_key(@klass_or_name, key.name).freeze
298
- end
299
-
300
- def to_sql
301
- @to_sql ||= quote_table.freeze
302
- end
303
-
304
- def to_s
305
- name.to_s
306
- end
307
-
308
- def unquote_default(default)
309
- default
310
- end
311
-
312
- def get_database_columns
313
- columns = []
314
- @adapter.connection do |db|
315
- command = db.create_command(to_columns_sql)
316
- command.execute_reader(name, schema.name) do |reader|
317
- columns = reader.map {
318
- @adapter.class::Mappings::Column.new(@adapter, self, reader.item(1),
319
- @adapter.class::TYPES.index(reader.item(2)),reader.item(0).to_i,
320
- :nullable => reader.item(3).to_i != 99, :default => unquote_default(reader.item(4)))
321
- }
322
- end
323
- end
324
- columns
325
- end
326
- alias_method :database_columns, :get_database_columns
327
-
328
- def to_create_sql
329
- @to_create_sql || @to_create_sql = begin
330
- sql = "CREATE"
331
- sql << " TEMPORARY" if temporary?
332
- sql << " TABLE #{to_sql} (#{ columns.map { |c| c.to_long_form }.join(",\n") }"
333
- unless keys.blank? || (keys.size == 1 && keys.first.serial?)
334
- sql << ", PRIMARY KEY (#{keys.map { |c| c.to_sql }.join(', ') })"
335
- end
336
- sql << ")"
337
-
338
- sql.compress_lines
339
- end
340
- end
341
-
342
- # Returns an array with each separate CREATE INDEX statement
343
- def to_create_index_sql
344
- queries = []
345
- unless indexes.blank?
346
- indexes.each do |column|
347
- sql = "CREATE INDEX #{to_s.downcase}_#{column}_index ON "
348
- sql << "#{to_sql} (#{column.to_sql})"
349
- queries << sql.compress_lines
350
- end
351
- end
352
- queries
353
- end
354
-
355
- # Returns an array with each separate CREATE INDEX statement
356
- def to_create_composite_index_sql
357
- queries = []
358
- unless composite_indexes.blank?
359
- composite_indexes.each do |columns, unique|
360
- sql = "CREATE #{unique ? 'UNIQUE ' : ''}INDEX "
361
- sql << "#{to_s.downcase}_#{columns.join('_')}_index ON "
362
- sql << "#{to_sql} (#{columns.join(', ')})"
363
- queries << sql.compress_lines
364
- end
365
- end
366
- queries
367
- end
368
-
369
- def to_truncate_sql
370
- "TRUNCATE TABLE #{to_sql}"
371
- end
372
-
373
- def to_drop_sql
374
- @to_drop_sql || @to_drop_sql = "DROP TABLE #{to_sql}"
375
- end
376
-
377
- def to_exists_sql
378
- @to_exists_sql || @to_exists_sql = <<-EOS.compress_lines
379
- SELECT TABLE_NAME
380
- FROM INFORMATION_SCHEMA.TABLES
381
- WHERE TABLE_NAME = ?
382
- AND #{@adapter.database_column_name} = ?
383
- EOS
384
- end
385
-
386
- def to_column_exists_sql
387
- @to_column_exists_sql || @to_column_exists_sql = <<-EOS.compress_lines
388
- SELECT TABLE_NAME, COLUMN_NAME
389
- FROM INFORMATION_SCHEMA.COLUMNS
390
- WHERE TABLE_NAME = ?
391
- AND COLUMN_NAME = ?
392
- AND #{@adapter.database_column_name} = ?
393
- EOS
394
- end
395
-
396
- def to_columns_sql
397
- @to_column_exists_sql || @to_column_exists_sql = <<-EOS.compress_lines
398
- SELECT ORDINAL_POSITION, COLUMN_NAME, DATA_TYPE,
399
- (CASE IS_NULLABLE WHEN 'NO' THEN 99 ELSE 0 END),
400
- COLUMN_DEFAULT
401
- FROM INFORMATION_SCHEMA.COLUMNS
402
- WHERE TABLE_NAME = ?
403
- AND #{@adapter.database_column_name} = ?
404
- EOS
405
- end
406
-
407
- def quote_table
408
- @adapter.quote_table_name(name)
409
- end
410
-
411
- def inspect
412
- "#<%s:0x%x @klass=%s, @name=%s, @columns=%s>" % [
413
- self.class.name,
414
- (object_id * 2),
415
- klass.inspect,
416
- to_sql,
417
- @columns.inspect
418
- ]
419
- end
420
-
421
- def flush_sql_caches!(flush_columns = true)
422
- @to_column_exists_sql = nil
423
- @to_column_exists_sql = nil
424
- @to_exists_sql = nil
425
- @to_create_sql = nil
426
- @to_drop_sql = nil
427
- @to_sql = nil
428
- @name = nil
429
- @columns_hash.clear
430
-
431
- if flush_columns
432
- @columns.each do |column|
433
- column.send(:flush_sql_caches!)
434
- end
435
- end
436
-
437
- true
438
- end
439
-
440
- def activate!
441
- @activated = true
442
- activate_associations!
443
- end
444
-
445
- def activated?
446
- @activated
447
- end
448
-
449
- end
450
-
451
- class Schema
452
- def to_tables_sql
453
- end
454
- end
455
-
456
- end
457
- end
458
- end
459
- end