I know there are a lot of mapper tickets open, but please add this one.
 I'll spend a day or two this week getting the Mapper tickets closed.

On Sat, Oct 3, 2009 at 3:00 AM, Peter Robinett <pe...@bubblefoundry.com>wrote:

>
> I have a model, Node, with a string index. I have another model,
> Packet, which has a MappedStringForeignKey to Node. Unfortunately,
> Schemifier doesn't seem to respect the MappedStringForeignKey type and
> creates a BIGINT column in the packets table, as you can see from its
> output:
> INFO - CREATE TABLE packets (temp DOUBLE , id BIGINT UNSIGNED NOT NULL
> AUTO_INCREMENT UNIQUE KEY , mac BIGINT UNSIGNED , dt DATETIME , mah
> DOUBLE , lux DOUBLE , rssi DOUBLE)  ENGINE = InnoDB
> INFO - ALTER TABLE packets ADD CONSTRAINT packets_PK PRIMARY KEY(id)
> INFO - CREATE INDEX packets_mac ON packets ( mac )
>
> Is this a bug? I can override fieldCreatorString for the foreign key
> but I don't think I should have to. This is with 1.1-SNAPSHOT.
>
> Peter
>
> And the relevant parts of my models:
>
> class Node extends KeyedMapper[String, Node] {
>  def getSingleton = Node
>  /* MAC address as primary key */
>  def primaryKeyField = mac
>  object mac extends MappedStringIndex(this, 17) with IndexedField
> [String] {
>        override def dbDisplay_? = true
>        override lazy val defaultValue = randomString(maxLen)
>        /* allow user-defined primary key */
>        override def writePermission_? = true
>        override def dbAutogenerated_? = false
>        private var myDirty = false
>        override def dirty_? = myDirty
>        override def dirty_?(b : Boolean) = { myDirty = b;
> super.dirty_?(b) }
>        override def fieldCreatorString(dbType: DriverType, colName:
> String): String = colName+" CHAR("+maxLen+") NOT NULL "
>  }
> }
>
> class Packet extends LongKeyedMapper[Packet] with IdPK {
>  def getSingleton = Packet
>  object node extends MappedStringForeignKey(this, Node, 17) {
>        // Change the default behavior to add a database index for
> this column.
>        override def dbIndexed_? = true
>        override def dbColumnName = "mac"
>  }
> }
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to