@Column annotations with columnNameFromPropertyName Bug

17 views
Skip to first unread message

wang xinli

unread,
Dec 15, 2014, 4:06:15 AM12/15/14
to squ...@googlegroups.com
Hello, 

I have find a problem that when an entity field with an @Column and then ,I overwrite the columnNameFromPropertyName in the Schema  defineation,

I foud that this property mapped twice with to defferent columns in table.

below is the code

trait IdTrait extends KeyedEntity[Long]

class Book(val id: Long, var title: String, @Column("coAuthorId") val authorId: Long, val coAuthorId: Option[Long]) extends IdTrait {
  def this() = this(0, "", 0, Some(0))
}

object Library extends squeryl.Schema {

  val book = table[Book]

on(book)(b => declare(
    b.title is indexed
  ))

 override def columnNameFromPropertyName(propertyName: String) = {
    val camelCase: Array[String] = StringUtils.splitByCharacterTypeCamelCase(propertyName)
    camelCase.toList.reduceLeft((a, b) => a + "_" + b.toLowerCase)
  }

}

===================================Printed SQL Statement==============================================================

create table Book (
    id bigint primary key not null auto_increment,
    coAuthorId bigint not null,
    co_author_id bigint,
    title varchar(128) not null
  ) 

David Whittaker

unread,
Dec 15, 2014, 4:35:45 PM12/15/14
to squ...@googlegroups.com
Hmm... that does look like a bug.  I turned on Github issues for the repo, can you please create one?

--
You received this message because you are subscribed to the Google Groups "Squeryl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to squeryl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages