Unsupported fields should be rejected early
Currently Squeryl simply ignores fields of unsupported types in table classes. It should probably throw an exception of some sort for unannotated fields of unsupported types , and provide some sort of annotation to allow fields to exist in table classes that are ignored by Squeryl (like @transient to match the EJB3 persistence annotations).
=======================
It looks like there's already an @transient annotation, so that part is already done!
=======================
Test case (currently fails) :
=======================
It looks like there's already an @transient annotation, so that part is already done!
=======================
Test case (currently fails) :
package org.squeryl.tests
import org.specs.Specification
import org.squeryl.Schema
import org.squeryl.annotations.Transient
/**
* Tests schema related functionality.
*/
class SchemaTests extends Specification
{
"Schema" should {
"reject empty record classes" in {
class EmptyRecord {
}
object EmptyRecordSchema extends Schema {
def tbl = table[EmptyRecord]
}
} must throwAn[IllegalArgumentException]
"reject records with unsupported types" in {
case class UnsupportedTypeRecord (unsupportedType :Thread) {
def this() = this(null)
}
object UnsupportedTypeSchema extends Schema {
def tbl = table[UnsupportedTypeRecord]
}
// should not be reached
} must throwAn[IllegalArgumentException]
"allow records with annotated types" in {
case class AnnotatedUnsupportedTypeRecord (
@Transient
unsupportedType :Thread
) {
def this() = this(null)
}
object AnnotatedUnsupportedTypeSchema extends Schema {
def tbl = table[AnnotatedUnsupportedTypeRecord]
}
1 must be(1) // if we reach here, the test passed
}
}
}
Leave a comment