OK, it's merged. An example usage of the new GenericIndex is:

package com.test.model

import _root_.net.liftweb.mapper._

class DateItem extends Mapper[DateItem] with IdPK {
  def getSingleton = DateItem
  object timestamp extends MappedDateTime(this)
  object time extends MappedTime(this)
  object date extends MappedDate(this)
}

object DateItem extends DateItem with MetaMapper[DateItem] {
  override def fieldOrder = date :: time :: timestamp :: Nil
  override def dbIndexes = GenericIndex({ (table,columns) =>
String.format("CREATE UNIQUE INDEX %s ON %s %s", "myindex_" + table + "_" +
columns.mkString("_"), table, columns.mkString("(", ",", ")"))},
IHaveValidatedThisSQL("Derek", "2009-07-13"), date) :: Nil
}

It's basically up to you to generate the DDL statement based on the table
and column names.

Derek

On Mon, Jul 13, 2009 at 4:11 PM, Derek Chen-Becker <[email protected]>wrote:

> OK, on wip-dcb-unique-indices there's now a GenericIndex that should give
> you full flexibility to do whatever you want for an index. I'll hold until
> tomorrow to merge with trunk.
>
> Derek
>
>
> On Mon, Jul 13, 2009 at 9:26 AM, Derek Chen-Becker 
> <[email protected]>wrote:
>
>> I'll add a UserIndex type that will let you specify the creation of the
>> index directly. Unique indices are generally supported across all DBs,
>> AFAIK, so it makes it more clear to have a specific type.
>>
>> Derek
>>
>>
>> On Mon, Jul 13, 2009 at 7:40 AM, Calen Pennington <
>> [email protected]> wrote:
>>
>>>
>>> Hey, I'm glad the code could make it in. One comment on your changes:
>>> It seems to me that using the pattern matching in ensureIndexes puts
>>> Lift in the position of maintaining support for various DBs, rather
>>> than letting the client code do it in a project by project basis (for
>>> instance, the FULLTEXT and SPACIAL index types that I mentioned, that
>>> are mysql specific.) Is there a reason that you preferred that over
>>> allowing client code to specify the index type?
>>>
>>> -Cale
>>>
>>> On Fri, Jul 10, 2009 at 5:32 PM, Derek Chen-Becker<[email protected]>
>>> wrote:
>>> > I've pushed a smaller commit into the wip-dcb-unique-indices branch on
>>> > GitHub that adds a UniqueIndex case class. Conceivably we could add
>>> other
>>> > types of indices if there's a need. If no one has any objections to
>>> what
>>> > I've added I can merge with trunk on Monday.
>>> >
>>> > Derek
>>> >
>>> > http://github.com/dpp/liftweb/tree/wip-dcb-unique-indices
>>> >
>>> > On Thu, Jul 9, 2009 at 9:44 PM, DFectuoso <[email protected]>
>>> wrote:
>>> >>
>>> >> I for one would like to say: Cool! Thanks! If i need unique indexes in
>>> >> the next couple of weeks i'll get this baby to the war( .war thats
>>> >> it ) =)
>>> >>
>>> >> On Jul 9, 11:30 am, Calen Pennington <[email protected]>
>>> >> wrote:
>>> >> > As mentioned is this issue
>>> >> > (http://github.com/dpp/liftweb/issues#issue/19), and as came up on
>>> the
>>> >> > list recently, Lift currently has no way to specify that a field or
>>> an
>>> >> > index be unique. I've coded up a patch that addresses this, and
>>> could
>>> >> > also be used for other index types on a project specific basis (for
>>> >> > instance, FULLTEXT or SPATIAL indexes in mysql).
>>> >> >
>>> >> > -Cale
>>> >> >
>>> >> >  0001-Adding-the-ability-to-create-UNIQUE-indexes-over-sin.patch
>>> >> > 5KViewDownload
>>> >>
>>> >>
>>> >
>>> >
>>> > >
>>> >
>>>
>>> >>>
>>>
>>
>

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

Reply via email to