I looked into this a little bit. The relevant chunks of code seem to
be Schemifier.scala, lines 163 and 207, where
connection.driverType.pkDefinedByIndexColumn_? is checked before using
an ALTER TABLE to set a primary key, and Driver.scala, line 131, where
the H2Driver has pkDefinedByIndexColumn_? set to True with the comment
"Whether the primary key has been defined by the index column. H2
creates primary key for a table, when AUTO_INCREMENT type is used."

So, it looks like lift is expecting H2 to use the autoincrement key as
the primary key automatically, but H2 isn't doing that, or isn't
reporting that it's doing that. However, I don't know enough about H2
to know which.

Hope that was helpful.

-Cale

On Wed, Jul 8, 2009 at 7:09 PM, Naftoli Gugenhem<naftoli...@gmail.com> wrote:
>
> Anyone? Why isn't IdPK telling Schemifier to create the id column as a unique 
> primary key, and how can I get it to?
>
> -------------------------------------
> Naftoli Gugenhem<naftoli...@gmail.com> wrote:
>
> I just found the INFORMATION_SCHEMA.INDEXES table. It clearly says that all 
> my id's are non-unique, non primary key. I'm mixing in IdPK. What am I doing 
> wrong?
>
> -------------------------------------
> Tim Nelson<tnell...@gmail.com> wrote:
>
> H2 has a great console servlet that you can use to connect to any jdbc
> compliant database and I just figured out how to configure it to work with
> lift.
>
> Assuming you already have H2 as a dependency, just add a mapping to the
> servlet in your web.xml. Mine looks like this:
>
> <web-app>
>
>  <filter>
>    <filter-name>LiftFilter</filter-name>
>    <display-name>Lift Filter</display-name>
>    <description>The Filter that intercepts lift calls</description>
>    <filter-class>net.liftweb.http.LiftFilter</filter-class>
>  </filter>
>
>  <filter-mapping>
>    <filter-name>LiftFilter</filter-name>
>    <url-pattern>/*</url-pattern>
>  </filter-mapping>
>
>  <servlet>
>    <servlet-name>H2Console</servlet-name>
>    <servlet-class>org.h2.server.web.WebServlet</servlet-class>
>    <load-on-startup>1</load-on-startup>
>  </servlet>
>  <servlet-mapping>
>    <servlet-name>H2Console</servlet-name>
>    <url-pattern>/console/*</url-pattern>
>  </servlet-mapping>
>
> </web-app>
>
> Then you need to add a rule to LiftRules.liftRequest using the following
> line in boot:
>
> LiftRules.liftRequest.append({case r if (r.path.partPath match {case
> "console" :: _ => true case _ => false}) => false})
>
> That basically allows all requests that start with "console" to be ignored
> by lift and passed thru to the servlet.
>
> I am actually using PostgreSQL, but I prefer using this to pgAdmin or other
> SQL tools.
>
> Tim
>
>
> On Fri, Jul 3, 2009 at 3:25 PM, Naftoli Gugenheim <naftoli...@gmail.com>wrote:
>
>> Okay. What about two fields in a unique constraint, e.g. first+last?Also,
>> my H2 databased generated by schemifying allowed me to insert rows that had
>> duplicate primary keys (or at least they're supposed to be primary keys).
>> I'm using LongKeyedMapper ... with IdPK. Am I missing something?
>> Anyone know how to read constraints in H2, meaning get it to to tell me
>> what constraints/indexes exists?
>> Thanks!
>>
>>
>> On Thu, Jul 2, 2009 at 9:50 AM, Calen Pennington <
>> calen.penning...@gmail.com> wrote:
>>
>>>
>>> I actually had the same question last night. I didn't see the
>>> valUnique on mapped string. However, it seems like a better way to do
>>> this would be to change the Schemifier::ensureIndexes (line 260 in
>>> Schemifier.scala) to do "CREATE UNIQUE INDEX" on request. Is there a
>>> known reason why this is hard, or is it just that no one has taken the
>>> time to do it yet? If it's the latter (and if I can figure out what's
>>> going wrong with my attempts to build lift from source), I hope to
>>> take a stab at it in the next day or two.
>>>
>>> -Cale
>>>
>>> On Thu, Jul 2, 2009 at 7:21 AM, Joe Wass<j...@folktunefinder.com> wrote:
>>> >
>>> > Yes for MappedString, valUnique .
>>> >
>>> >
>>> http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/mapper/MappedString.html
>>> >
>>> > Joe
>>> >
>>> >
>>> >
>>> > On Jul 2, 7:55 am, Naftoli Gugenhem <naftoli...@gmail.com> wrote:
>>> >> Does lift have any way to specify a unique constraint on a field, via
>>> schemify (or validation)?
>>> >> If not, how complex would it be to implement?
>>> >
>>> > >
>>> >
>>>
>>>
>>>
>>
>> >
>>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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