lafcadio 0.4.3 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/bin/lafcadio_schema +28 -0
  2. data/lib/lafcadio.rb +3 -4
  3. data/lib/lafcadio.rb~ +3 -4
  4. data/lib/lafcadio/TestSuite.rb +2 -0
  5. data/lib/lafcadio/TestSuite.rb~ +16 -0
  6. data/lib/lafcadio/dateTime.rb +93 -2
  7. data/lib/lafcadio/{dateTime/Month.rb → dateTime.rb~} +33 -33
  8. data/lib/lafcadio/depend.rb +3 -0
  9. data/lib/lafcadio/domain.rb +574 -70
  10. data/lib/lafcadio/domain.rb~ +570 -70
  11. data/lib/lafcadio/mock.rb +92 -2
  12. data/lib/lafcadio/mock.rb~ +93 -0
  13. data/lib/lafcadio/objectField.rb +614 -3
  14. data/lib/lafcadio/objectField.rb~ +618 -0
  15. data/lib/lafcadio/objectStore.rb +662 -19
  16. data/lib/lafcadio/objectStore.rb~ +746 -0
  17. data/lib/lafcadio/query.rb +415 -31
  18. data/lib/lafcadio/query.rb~ +572 -0
  19. data/lib/lafcadio/schema.rb +57 -2
  20. data/lib/lafcadio/test.rb +17 -2
  21. data/lib/lafcadio/{test/LafcadioTestCase.rb → test.rb~} +5 -5
  22. data/lib/lafcadio/test/testconfig.dat +1 -1
  23. data/lib/lafcadio/util.rb +337 -20
  24. metadata +16 -77
  25. data/lib/lafcadio/domain/DomainObject.rb +0 -375
  26. data/lib/lafcadio/domain/DomainObject.rb~ +0 -371
  27. data/lib/lafcadio/domain/MapObject.rb +0 -22
  28. data/lib/lafcadio/domain/ObjectType.rb +0 -80
  29. data/lib/lafcadio/includer.rb +0 -18
  30. data/lib/lafcadio/mock/MockDbBridge.rb +0 -78
  31. data/lib/lafcadio/mock/MockDbBridge.rb~ +0 -74
  32. data/lib/lafcadio/mock/MockObjectStore.rb +0 -20
  33. data/lib/lafcadio/objectField/AutoIncrementField.rb +0 -25
  34. data/lib/lafcadio/objectField/BooleanField.rb +0 -83
  35. data/lib/lafcadio/objectField/DateField.rb +0 -33
  36. data/lib/lafcadio/objectField/DateTimeField.rb +0 -25
  37. data/lib/lafcadio/objectField/DecimalField.rb +0 -41
  38. data/lib/lafcadio/objectField/EmailField.rb +0 -28
  39. data/lib/lafcadio/objectField/EnumField.rb +0 -62
  40. data/lib/lafcadio/objectField/FieldValueError.rb +0 -4
  41. data/lib/lafcadio/objectField/IntegerField.rb +0 -15
  42. data/lib/lafcadio/objectField/LinkField.rb +0 -92
  43. data/lib/lafcadio/objectField/LinkField.rb~ +0 -86
  44. data/lib/lafcadio/objectField/MoneyField.rb +0 -13
  45. data/lib/lafcadio/objectField/MonthField.rb +0 -16
  46. data/lib/lafcadio/objectField/ObjectField.rb +0 -142
  47. data/lib/lafcadio/objectField/PasswordField.rb +0 -29
  48. data/lib/lafcadio/objectField/StateField.rb +0 -13
  49. data/lib/lafcadio/objectField/SubsetLinkField.rb +0 -25
  50. data/lib/lafcadio/objectField/TextField.rb +0 -23
  51. data/lib/lafcadio/objectField/TextListField.rb +0 -21
  52. data/lib/lafcadio/objectField/TimeStampField.rb +0 -15
  53. data/lib/lafcadio/objectStore/Cache.rb +0 -81
  54. data/lib/lafcadio/objectStore/Committer.rb +0 -65
  55. data/lib/lafcadio/objectStore/CouldntMatchObjectTypeError.rb +0 -4
  56. data/lib/lafcadio/objectStore/DbBridge.rb +0 -140
  57. data/lib/lafcadio/objectStore/DbBridge.rb~ +0 -140
  58. data/lib/lafcadio/objectStore/DomainComparable.rb +0 -25
  59. data/lib/lafcadio/objectStore/DomainObjectInitError.rb +0 -9
  60. data/lib/lafcadio/objectStore/DomainObjectNotFoundError.rb +0 -4
  61. data/lib/lafcadio/objectStore/DomainObjectProxy.rb +0 -62
  62. data/lib/lafcadio/objectStore/DomainObjectSqlMaker.rb +0 -74
  63. data/lib/lafcadio/objectStore/ObjectStore.rb +0 -207
  64. data/lib/lafcadio/objectStore/ObjectStore.rb~ +0 -207
  65. data/lib/lafcadio/objectStore/SqlValueConverter.rb +0 -30
  66. data/lib/lafcadio/objectStore/SqlValueConverter.rb~ +0 -30
  67. data/lib/lafcadio/query/Compare.rb +0 -55
  68. data/lib/lafcadio/query/CompoundCondition.rb +0 -39
  69. data/lib/lafcadio/query/Condition.rb +0 -66
  70. data/lib/lafcadio/query/Condition.rb~ +0 -66
  71. data/lib/lafcadio/query/Equals.rb +0 -45
  72. data/lib/lafcadio/query/In.rb +0 -20
  73. data/lib/lafcadio/query/Like.rb +0 -48
  74. data/lib/lafcadio/query/Link.rb +0 -20
  75. data/lib/lafcadio/query/Max.rb +0 -32
  76. data/lib/lafcadio/query/Max.rb~ +0 -25
  77. data/lib/lafcadio/query/Not.rb +0 -21
  78. data/lib/lafcadio/query/Query.rb +0 -92
  79. data/lib/lafcadio/schema/CreateTableStatement.rb +0 -61
  80. data/lib/lafcadio/schema/CreateTableStatement.rb~ +0 -59
  81. data/lib/lafcadio/util/Context.rb +0 -61
  82. data/lib/lafcadio/util/ContextualService.rb +0 -33
  83. data/lib/lafcadio/util/English.rb +0 -117
  84. data/lib/lafcadio/util/HashOfArrays.rb +0 -48
  85. data/lib/lafcadio/util/LafcadioConfig.rb +0 -25
  86. data/lib/lafcadio/util/QueueHash.rb +0 -67
  87. data/lib/lafcadio/util/UsStates.rb +0 -29
  88. data/lib/lafcadio/xml.rb +0 -2
@@ -39,8 +39,8 @@
39
39
  # # => "select * from invoices where client = 99"
40
40
  #
41
41
  # == Inclusion: +in+
42
- # first_three_invs = object_store.getInvoices { |inv| inv.pkId.in( 1, 2, 3 ) }
43
- # # => "select * from invoices where pkId in ( 1, 2, 3 )"
42
+ # first_three_invs = object_store.getInvoices { |inv| inv.pk_id.in( 1, 2, 3 ) }
43
+ # # => "select * from invoices where pk_id in ( 1, 2, 3 )"
44
44
  #
45
45
  # == Text comparison: +like+
46
46
  # fname_starts_with_a = object_store.getUsers { |user|
@@ -84,54 +84,427 @@
84
84
  # invoices = object_store.getInvoices { |inv| inv.rate.equals( 50 ).not }
85
85
  # # => "select * from invoices where rate != 50"
86
86
 
87
- require 'lafcadio/includer'
88
- Includer.include( 'query' )
87
+ require 'delegate'
89
88
 
90
89
  module Lafcadio
91
90
  class Query
92
91
  def self.And( *conditions ); CompoundCondition.new( *conditions ); end
93
92
 
93
+ def self.infer( domain_class, &action )
94
+ inferrer = Query::Inferrer.new( domain_class ) { |obj|
95
+ action.call( obj )
96
+ }
97
+ inferrer.execute
98
+ end
99
+
94
100
  def self.Or( *conditions )
95
101
  conditions << CompoundCondition::OR
96
102
  CompoundCondition.new( *conditions)
97
103
  end
98
104
 
105
+ ASC = 1
106
+ DESC = 2
107
+
108
+ attr_reader :object_type, :condition
109
+ attr_accessor :order_by, :order_by_order, :limit
110
+
111
+ def initialize(object_type, pk_idOrCondition = nil)
112
+ @object_type = object_type
113
+ ( @condition, @order_by, @limit ) = [ nil, nil, nil ]
114
+ if pk_idOrCondition
115
+ if pk_idOrCondition.class <= Condition
116
+ @condition = pk_idOrCondition
117
+ else
118
+ @condition = Query::Equals.new( object_type.sql_primary_key_name,
119
+ pk_idOrCondition, object_type )
120
+ end
121
+ end
122
+ @order_by_order = ASC
123
+ end
124
+
125
+ def and( &action ); compound( CompoundCondition::AND, action ); end
126
+
127
+ def compound( comp_type, action )
128
+ rquery = Query.infer( @object_type ) { |dobj| action.call( dobj ) }
129
+ comp_cond = Query::CompoundCondition.new( @condition, rquery.condition,
130
+ comp_type )
131
+ comp_cond.query
132
+ end
133
+
134
+ def eql?( other ); other.class <= Query && other.to_sql == to_sql; end
135
+
136
+ def fields; '*'; end
137
+
138
+ def hash; to_sql.hash; end
139
+
140
+ def limit_clause
141
+ "limit #{ @limit.begin }, #{ @limit.end - @limit.begin + 1 }" if @limit
142
+ end
143
+
144
+ def or( &action ); compound( CompoundCondition::OR, action ); end
145
+
146
+ def order_clause
147
+ if @order_by
148
+ clause = "order by #{ @order_by } "
149
+ clause += @order_by_order == ASC ? 'asc' : 'desc'
150
+ clause
151
+ end
152
+ end
153
+
154
+ def sql_primary_key_field(object_type)
155
+ "#{ object_type.table_name }.#{ object_type.sql_primary_key_name }"
156
+ end
157
+
158
+ def tables
159
+ concrete_classes = object_type.self_and_concrete_superclasses.reverse
160
+ table_names = concrete_classes.collect { |domain_class|
161
+ domain_class.table_name
162
+ }
163
+ table_names.join( ', ' )
164
+ end
165
+
166
+ def to_sql
167
+ clauses = [ "select #{ fields }", "from #{ tables }" ]
168
+ clauses << where_clause if where_clause
169
+ clauses << order_clause if order_clause
170
+ clauses << limit_clause if limit_clause
171
+ clauses.join ' '
172
+ end
173
+
174
+ def where_clause
175
+ concrete_classes = object_type.self_and_concrete_superclasses.reverse
176
+ where_clauses = []
177
+ concrete_classes.each_with_index { |domain_class, i|
178
+ if i < concrete_classes.size - 1
179
+ join_clause = sql_primary_key_field( domain_class ) + ' = ' +
180
+ sql_primary_key_field( concrete_classes[i+1] )
181
+ where_clauses << join_clause
182
+ else
183
+ where_clauses << @condition.to_sql if @condition
184
+ end
185
+ }
186
+ where_clauses.size > 0 ? 'where ' + where_clauses.join( ' and ' ) : nil
187
+ end
188
+
189
+ class Condition #:nodoc:
190
+ def Condition.search_term_type
191
+ Object
192
+ end
193
+
194
+ attr_reader :object_type
195
+
196
+ def initialize(fieldName, searchTerm, object_type)
197
+ @fieldName = fieldName
198
+ @searchTerm = searchTerm
199
+ unless @searchTerm.class <= self.class.search_term_type
200
+ raise "Incorrect searchTerm type #{ searchTerm.class }"
201
+ end
202
+ @object_type = object_type
203
+ if @object_type
204
+ unless @object_type <= DomainObject
205
+ raise "Incorrect object type #{ @object_type.to_s }"
206
+ end
207
+ end
208
+ end
209
+
210
+ def db_field_name; get_field.db_table_and_field_name; end
211
+
212
+ def get_field
213
+ anObjectType = @object_type
214
+ field = nil
215
+ while (anObjectType < DomainObject || anObjectType < DomainObject) &&
216
+ !field
217
+ field = anObjectType.get_class_field( @fieldName ) ||
218
+ anObjectType.get_class_field_by_db_name( @fieldName )
219
+ anObjectType = anObjectType.superclass
220
+ end
221
+ if field
222
+ field
223
+ else
224
+ errStr = "Couldn't find field \"#{ @fieldName }\" in " +
225
+ "#{ @object_type } domain class"
226
+ raise( MissingError, errStr, caller )
227
+ end
228
+ end
229
+
230
+ def query; Query.new( @object_type, self ); end
231
+
232
+ def not
233
+ Query::Not.new( self )
234
+ end
235
+
236
+ def primary_key_field?
237
+ [ @object_type.sql_primary_key_name, 'pk_id' ].include?( @fieldName )
238
+ end
239
+
240
+ def to_condition; self; end
241
+ end
242
+
243
+ class Compare < Condition #:nodoc:
244
+ LESS_THAN = 1
245
+ LESS_THAN_OR_EQUAL = 2
246
+ GREATER_THAN_OR_EQUAL = 3
247
+ GREATER_THAN = 4
248
+
249
+ @@comparators = {
250
+ LESS_THAN => '<',
251
+ LESS_THAN_OR_EQUAL => '<=',
252
+ GREATER_THAN_OR_EQUAL => '>=',
253
+ GREATER_THAN => '>'
254
+ }
255
+
256
+ @@mockComparators = {
257
+ LESS_THAN => Proc.new { |d1, d2| d1 < d2 },
258
+ LESS_THAN_OR_EQUAL => Proc.new { |d1, d2| d1 <= d2 },
259
+ GREATER_THAN_OR_EQUAL => Proc.new { |d1, d2| d1 >= d2 },
260
+ GREATER_THAN => Proc.new { |d1, d2| d1 > d2 }
261
+ }
262
+
263
+ def initialize(fieldName, searchTerm, object_type, compareType)
264
+ super fieldName, searchTerm, object_type
265
+ @compareType = compareType
266
+ end
267
+
268
+ def to_sql
269
+ if ( get_field.kind_of?( LinkField ) &&
270
+ !@searchTerm.respond_to?( :pk_id ) )
271
+ search_val = @searchTerm.to_s
272
+ else
273
+ search_val = get_field.value_for_sql( @searchTerm ).to_s
274
+ end
275
+ "#{ db_field_name } #{ @@comparators[@compareType] } " + search_val
276
+ end
277
+
278
+ def object_meets(anObj)
279
+ value = anObj.send @fieldName
280
+ value = value.pk_id if value.class <= DomainObject
281
+ if value
282
+ @@mockComparators[@compareType].call(value, @searchTerm)
283
+ else
284
+ false
285
+ end
286
+ end
287
+ end
288
+
289
+ class CompoundCondition < Condition #:nodoc:
290
+ AND = 1
291
+ OR = 2
292
+
293
+ def initialize(*conditions)
294
+ if( [ AND, OR ].index(conditions.last) )
295
+ @compoundType = conditions.last
296
+ conditions.pop
297
+ else
298
+ @compoundType = AND
299
+ end
300
+ @conditions = conditions
301
+ @object_type = conditions[0].object_type
302
+ end
303
+
304
+ def object_meets(anObj)
305
+ if @compoundType == AND
306
+ @conditions.inject( true ) { |result, cond|
307
+ result && cond.object_meets( anObj )
308
+ }
309
+ else
310
+ @conditions.inject( false ) { |result, cond|
311
+ result || cond.object_meets( anObj )
312
+ }
313
+ end
314
+ end
315
+
316
+ def to_sql
317
+ booleanString = @compoundType == AND ? 'and' : 'or'
318
+ subSqlStrings = @conditions.collect { |cond| cond.to_sql }
319
+ "(#{ subSqlStrings.join(" #{ booleanString } ") })"
320
+ end
321
+ end
322
+
99
323
  class DomainObjectImpostor #:nodoc:
100
- attr_reader :domainClass
324
+ attr_reader :domain_class
101
325
 
102
- def initialize( domainClass )
103
- @domainClass = domainClass
326
+ def initialize( domain_class )
327
+ @domain_class = domain_class
104
328
  end
105
329
 
106
330
  def method_missing( methId, *args )
107
331
  fieldName = methId.id2name
108
- if fieldName == 'pkId'
109
- ObjectFieldImpostor.new( self, fieldName )
110
- else
111
- begin
112
- classField = @domainClass.getField( fieldName )
113
- ObjectFieldImpostor.new( self, classField )
114
- rescue MissingError
115
- super( methId, *args )
116
- end
332
+ begin
333
+ classField = @domain_class.get_field( fieldName )
334
+ ObjectFieldImpostor.new( self, classField )
335
+ rescue MissingError
336
+ super( methId, *args )
117
337
  end
118
338
  end
119
339
  end
120
340
 
341
+ class Equals < Condition #:nodoc:
342
+ def r_val_string
343
+ field = get_field
344
+ if @searchTerm.class <= ObjectField
345
+ @searchTerm.db_table_and_field_name
346
+ else
347
+ field.value_for_sql(@searchTerm).to_s
348
+ end
349
+ end
350
+
351
+ def object_meets(anObj)
352
+ if @searchTerm.class <= ObjectField
353
+ compare_value = anObj.send( @searchTerm.name )
354
+ else
355
+ compare_value = @searchTerm
356
+ end
357
+ compare_value == anObj.send( @fieldName )
358
+ end
359
+
360
+ def to_sql
361
+ sql = "#{ db_field_name } "
362
+ unless @searchTerm.nil?
363
+ sql += "= " + r_val_string
364
+ else
365
+ sql += "is null"
366
+ end
367
+ sql
368
+ end
369
+ end
370
+
371
+ class In < Condition #:nodoc:
372
+ def self.search_term_type
373
+ Array
374
+ end
375
+
376
+ def object_meets(anObj)
377
+ value = anObj.send @fieldName
378
+ @searchTerm.index(value) != nil
379
+ end
380
+
381
+ def to_sql
382
+ "#{ db_field_name } in (#{ @searchTerm.join(', ') })"
383
+ end
384
+ end
385
+
121
386
  class Inferrer #:nodoc:
122
- def initialize( domainClass, &action )
123
- @domainClass = domainClass; @action = action
387
+ def initialize( domain_class, &action )
388
+ @domain_class = domain_class; @action = action
124
389
  end
125
390
 
126
391
  def execute
127
- impostor = DomainObjectImpostor.new( @domainClass )
128
- condition = @action.call( impostor )
129
- query = Query.new( @domainClass, condition )
392
+ impostor = DomainObjectImpostor.new( @domain_class )
393
+ condition = @action.call( impostor ).to_condition
394
+ query = Query.new( @domain_class, condition )
395
+ end
396
+ end
397
+
398
+ class Like < Condition #:nodoc:
399
+ PRE_AND_POST = 1
400
+ PRE_ONLY = 2
401
+ POST_ONLY = 3
402
+
403
+ def initialize(
404
+ fieldName, searchTerm, object_type, matchType = PRE_AND_POST)
405
+ super fieldName, searchTerm, object_type
406
+ @matchType = matchType
407
+ end
408
+
409
+ def get_regexp
410
+ if @matchType == PRE_AND_POST
411
+ Regexp.new(@searchTerm)
412
+ elsif @matchType == PRE_ONLY
413
+ Regexp.new(@searchTerm.to_s + "$")
414
+ elsif @matchType == POST_ONLY
415
+ Regexp.new("^" + @searchTerm)
416
+ end
417
+ end
418
+
419
+ def object_meets(anObj)
420
+ value = anObj.send @fieldName
421
+ if value.class <= DomainObject || value.class == DomainObjectProxy
422
+ value = value.pk_id.to_s
423
+ end
424
+ if value.class <= Array
425
+ (value.index(@searchTerm) != nil)
426
+ else
427
+ get_regexp.match(value) != nil
428
+ end
429
+ end
430
+
431
+ def to_sql
432
+ withWildcards = @searchTerm
433
+ if @matchType == PRE_AND_POST
434
+ withWildcards = "%" + withWildcards + "%"
435
+ elsif @matchType == PRE_ONLY
436
+ withWildcards = "%" + withWildcards
437
+ elsif @matchType == POST_ONLY
438
+ withWildcards += "%"
439
+ end
440
+ "#{ db_field_name } like '#{ withWildcards }'"
130
441
  end
131
442
  end
443
+
444
+ class Link < Condition #:nodoc:
445
+ def initialize( fieldName, searchTerm, object_type )
446
+ if searchTerm.pk_id.nil?
447
+ raise ArgumentError,
448
+ "Can't query using an uncommitted domain object as a search term",
449
+ caller
450
+ else
451
+ super( fieldName, searchTerm, object_type )
452
+ end
453
+ end
132
454
 
455
+ def self.search_term_type
456
+ DomainObject
457
+ end
458
+
459
+ def object_meets(anObj)
460
+ value = anObj.send @fieldName
461
+ value ? value.pk_id == @searchTerm.pk_id : false
462
+ end
463
+
464
+ def to_sql
465
+ "#{ db_field_name } = #{ @searchTerm.pk_id }"
466
+ end
467
+ end
468
+
469
+ class Max < Query #:nodoc:
470
+ attr_reader :field_name
471
+
472
+ def initialize( object_type, field_name = 'pk_id' )
473
+ super( object_type )
474
+ @field_name = field_name
475
+ end
476
+
477
+ def collect( coll )
478
+ max = coll.inject( nil ) { |max, d_obj|
479
+ a_value = d_obj.send( @field_name )
480
+ ( max.nil? || a_value > max ) ? a_value : max
481
+ }
482
+ [ max ]
483
+ end
484
+
485
+ def fields
486
+ "max(#{ @object_type.get_field( @field_name ).db_field_name })"
487
+ end
488
+ end
489
+
490
+ class Not < Condition #:nodoc:
491
+ def initialize(unCondition)
492
+ @unCondition = unCondition
493
+ end
494
+
495
+ def object_meets(obj)
496
+ !@unCondition.object_meets(obj)
497
+ end
498
+
499
+ def object_type; @unCondition.object_type; end
500
+
501
+ def to_sql
502
+ "!(#{ @unCondition.to_sql })"
503
+ end
504
+ end
505
+
133
506
  class ObjectFieldImpostor #:nodoc:
134
- def ObjectFieldImpostor.comparators
507
+ def self.comparators
135
508
  {
136
509
  'lt' => Compare::LESS_THAN, 'lte' => Compare::LESS_THAN_OR_EQUAL,
137
510
  'gte' => Compare::GREATER_THAN_OR_EQUAL,
@@ -143,32 +516,32 @@ module Lafcadio
143
516
 
144
517
  def initialize( domainObjectImpostor, class_field_or_name )
145
518
  @domainObjectImpostor = domainObjectImpostor
146
- if class_field_or_name == 'pkId'
147
- @db_field_name = 'pkId'
519
+ if class_field_or_name == 'pk_id'
520
+ @db_field_name = 'pk_id'
148
521
  else
149
522
  @class_field = class_field_or_name
150
- @db_field_name = class_field_or_name.dbFieldName
523
+ @db_field_name = class_field_or_name.db_field_name
151
524
  end
152
525
  end
153
526
 
154
527
  def method_missing( methId, *args )
155
528
  methodName = methId.id2name
156
529
  if !ObjectFieldImpostor.comparators.keys.index( methodName ).nil?
157
- registerCompareCondition( methodName, *args )
530
+ register_compare_condition( methodName, *args )
158
531
  else
159
532
  super( methId, *args )
160
533
  end
161
534
  end
162
535
 
163
- def registerCompareCondition( compareStr, searchTerm)
536
+ def register_compare_condition( compareStr, searchTerm)
164
537
  compareVal = ObjectFieldImpostor.comparators[compareStr]
165
538
  Compare.new( @db_field_name, searchTerm,
166
- @domainObjectImpostor.domainClass, compareVal )
539
+ @domainObjectImpostor.domain_class, compareVal )
167
540
  end
168
541
 
169
542
  def equals( searchTerm )
170
543
  Equals.new( @db_field_name, field_or_field_name( searchTerm ),
171
- @domainObjectImpostor.domainClass )
544
+ @domainObjectImpostor.domain_class )
172
545
  end
173
546
 
174
547
  def field_or_field_name( search_term )
@@ -191,13 +564,24 @@ module Lafcadio
191
564
  matchType = Query::Like::PRE_AND_POST
192
565
  end
193
566
  Query::Like.new( @db_field_name, searchTerm,
194
- @domainObjectImpostor.domainClass, matchType )
567
+ @domainObjectImpostor.domain_class, matchType )
195
568
  end
196
569
 
197
570
  def in( *searchTerms )
198
571
  Query::In.new( @db_field_name, searchTerms,
199
- @domainObjectImpostor.domainClass )
572
+ @domainObjectImpostor.domain_class )
200
573
  end
574
+
575
+ def to_condition
576
+ if @class_field.instance_of?( BooleanField )
577
+ Query::Equals.new( @db_field_name, true,
578
+ @domainObjectImpostor.domain_class )
579
+ else
580
+ raise
581
+ end
582
+ end
583
+
584
+ def not; to_condition.not; end
201
585
  end
202
586
  end
203
587
  end