Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Schemefier Creates a BIGINT for a MappedStringForeignKey #79

Closed
pr1001 opened this Issue Oct 6, 2009 · 2 comments

Comments

Projects
None yet
3 participants
Member

pr1001 commented Oct 6, 2009

Schemifier doesn't seem to respect the MappedStringForeignKey type and creates a BIGINT column, as you can see in the following 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 )

I can override fieldCreatorString for the foreign key but I don't think I should have to. This is with 1.1-SNAPSHOT.

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"
 }

@ghost ghost assigned dpp Mar 1, 2012

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment