Skip to content
This repository

Squeryl-record crash when field has ignoreField_? = true #1297

Open
brianhsu opened this Issue July 20, 2012 · 2 comments

3 participants

Brian Hsu Antonio Salazar Cardozo Dave Whittaker
Brian Hsu

According to API documentation, when a Record field is declared as ignoreField_? = true, ORM should ignore it.

But the following code will lead to a exception thrown by squeryl-record.

object Bookstore extends Schema {
    val users = table[User]("users")
}

object User extends User with MetaRecord[User]
class User extends Record[User] with KeyedRecord[Long] {
    def meta = User

    @Column(name="id")
    val idField = new LongField(this, 1)
    val email = new EmailField(this, 255)
    val password = new PasswordField(this)
    val ignoreString = new StringField(this, "") {
        override def ignoreField_? = true
    }
}

Stack trace when create DDL from Squeryl.

scala> inTransaction { Bookstore.printDdl }
java.lang.RuntimeException: error while reflecting on metadata for (Some(private final net.liftweb.record.field.StringField org.bedone.model.User.ignoreString),Some(public net.liftweb.record.field.StringField org.bedone.model.User.ignoreString()),None,Set()) of class org.bedone.model.User
        at org.squeryl.internals.PosoMetaData$$anonfun$4.apply(PosoMetaData.scala:115)
        at org.squeryl.internals.PosoMetaData$$anonfun$4.apply(PosoMetaData.scala:80)
        at scala.collection.immutable.HashMap$HashMap1.foreach(HashMap.scala:178)
        at scala.collection.immutable.HashMap$HashTrieMap.foreach(HashMap.scala:347)
        at org.squeryl.internals.PosoMetaData.<init>(PosoMetaData.scala:80)
        at org.squeryl.View.<init>(View.scala:66)
        at org.squeryl.Table.<init>(Table.scala:29)
        at org.squeryl.Schema$class.table(Schema.scala:338)
        at org.bedone.model.Bookstore$.table(Test.scala:19)
        at org.bedone.model.Bookstore$.<init>(Test.scala:20)
        at org.bedone.model.Bookstore$.<clinit>(Test.scala)
        .............
Caused by: java.lang.RuntimeException: failed to find field ignoreString in Record metadata for class org.bedone.model.User
        at org.squeryl.internals.Utils$.throwError(Utils.scala:95)
        at net.liftweb.squerylrecord.RecordMetaDataFactory.fieldFrom$1(RecordMetaDataFactory.scala:41)
        at net.liftweb.squerylrecord.RecordMetaDataFactory.findMetaField(RecordMetaDataFactory.scala:45)
        at net.liftweb.squerylrecord.RecordMetaDataFactory.build(RecordMetaDataFactory.scala:70)
        at org.squeryl.internals.PosoMetaData$$anonfun$4.apply(PosoMetaData.scala:112)
        ... 49 more
Antonio Salazar Cardozo
Collaborator

Hey Brian, it doesn't look like you've posted about this on the Lift list at https://groups.google.com/forum/?fromgroups#!forum/liftweb ; please do that before filing tickets here. Thanks!

Antonio Salazar Cardozo Shadowfiend closed this July 20, 2012
Dave Whittaker davewhittaker reopened this July 20, 2012
Dave Whittaker

I'm afraid this can't be addressed without some changes to the Squeryl internals. I'll see what I can do to get SquerylRecord using Record's own field lookup mechanism when Squeryl 0.9.6 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.