Certainly.  I will open a ticket.  I might have found 3 different issues...
(one each for Mapper, schemify, CRUDify) all related to dbColumnName (see
details below).

I created a new scaled down project against 1.1-SNAPSHOT and an embedded
Derby database, and it exhibits the Mapper dbColumnName behavior as well as
two other odd behaviors related to dbColumnName:
==> schemify tries to ALTER TABLE to add the columns that override
dbColumnName a second time, and of course fails with duplicate column name
exception.
==> CRUDify gets confused when I use a '  def primaryKeyField =
projectTypeId' and when projectTypeId uses 'override def dbColumnName =
'PROJECT_TYPE_ID" (see complete DDL below) where it creates all the links in
the "List" page with '-1' for the ID such as /PROJECT_TYPE/view/-1 or
/PROJECT_TYPE/edit/-1 instead of the proper PROJECT_TYPE_ID such as
.../view/1 or .../edit/1.  I think it's because these are all coming back as
-1 from the Mapper.

Here's schemify's DDL output and stack trace... just for grins... my ticket
will include this as well of course.

INFO - CREATE TABLE todo (priority INTEGER , id BIGINT NOT NULL
AUTO_INCREMENT ,
 desc_c VARCHAR(128) , done BOOLEAN , owner BIGINT)
INFO - ALTER TABLE todo ADD CONSTRAINT todo_PK PRIMARY KEY(id)
INFO - CREATE TABLE PROJECT_TYPE (ACTIVE BOOLEAN , val4 VARCHAR(128) , val3
VARC
HAR(128) , val2 INTEGER , val1 BIGINT , LAST_MODIFIED_BY VARCHAR(30) ,
GUI_PROJE
CT_LIST_VISIBLE BOOLEAN , GUI_TREE_VISIBLE BOOLEAN , GUI_NAME VARCHAR(25) ,
type
_name VARCHAR(25) , create_date TIMESTAMP , PROJECT_TYPE_ID BIGINT NOT NULL
AUTO
_INCREMENT)
INFO - ALTER TABLE PROJECT_TYPE ADD CONSTRAINT PROJECT_TYPE_PK PRIMARY
KEY(PROJE
CT_TYPE_ID)
INFO - ALTER TABLE PROJECT_TYPE ADD COLUMN ACTIVE BOOLEAN
ERROR - Failed to Boot
org.h2.jdbc.JdbcSQLException: Duplicate column name ACTIVE; SQL statement:

---> ALTER TABLE PROJECT_TYPE ADD COLUMN ACTIVE BOOLEAN [42121-121]

        at org.h2.message.Message.getSQLException(Message.java:106)
        at org.h2.message.Message.getSQLException(Message.java:117)
        at org.h2.message.Message.getSQLException(Message.java:76)
        at org.h2.table.Table.setColumns(Table.java:336)
        at org.h2.table.TableData.<init>(TableData.java:82)
        at org.h2.schema.Schema.createTable(Schema.java:492)
        at
org.h2.command.ddl.AlterTableAlterColumn.copyData(AlterTableAlterColu
mn.java:256)
        at
org.h2.command.ddl.AlterTableAlterColumn.update(AlterTableAlterColumn
.java:162)
        at org.h2.command.CommandContainer.update(CommandContainer.java:72)
        at org.h2.command.Command.executeUpdate(Command.java:208)
        at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:162)
        at
net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier$$maybeWr
ite(Schemifier.scala:151)
        at
net.liftweb.mapper.Schemifier$$anonfun$6$$anonfun$apply$10.apply(Sche
mifier.scala:207)
        at
net.liftweb.mapper.Schemifier$$anonfun$6$$anonfun$apply$10.apply(Sche
mifier.scala:206)
        at scala.List.foreach(List.scala:841)
        at
net.liftweb.mapper.Schemifier$$anonfun$6.apply(Schemifier.scala:205)
        at
net.liftweb.mapper.Schemifier$$anonfun$6.apply(Schemifier.scala:187)
        at scala.List.flatMap(List.scala:1132)
        at
net.liftweb.mapper.Schemifier$.net$liftweb$mapper$Schemifier$$ensureC
olumns(Schemifier.scala:186)
        at
net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun$2.apply(Sc
hemifier.scala:62)
        at
net.liftweb.mapper.Schemifier$$anonfun$schemify$1$$anonfun$2.apply(Sc
hemifier.scala:62)
        at scala.List.foldLeft(List.scala:1066)
        at
net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply(Schemifier.sc
ala:62)
        at
net.liftweb.mapper.Schemifier$$anonfun$schemify$1.apply(Schemifier.sc
ala:55)
        at net.liftweb.mapper.DB$.use(DB.scala:419)
        at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:54)
        at net.liftweb.mapper.Schemifier$.schemify(Schemifier.scala:37)
        at bootstrap.liftweb.Boot.boot(Boot.scala:29)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at
net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHel
pers.scala:409)
        at
net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHel
pers.scala:407)
        at
net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.sca
la:1188)
        at
net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.sca
la:1188)
        at net.liftweb.common.Full.map(Box.scala:330)
        at net.liftweb.http.DefaultBootstrap$.boot(LiftRules.scala:1188)
        at
net.liftweb.http.provider.HTTPProvider$class.bootLift(HTTPProvider.sc
ala:70)
        at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:516)
        at
net.liftweb.http.provider.servlet.ServletFilterProvider$class.init(Se
rvletFilterProvider.scala:20)
        at net.liftweb.http.LiftFilter.init(LiftServlet.scala:516)
        at
org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)


On Fri, Oct 30, 2009 at 6:55 AM, David Pollak <[email protected]
> wrote:

>
>
> On Thu, Oct 29, 2009 at 10:15 PM, Troy Noble <[email protected]> wrote:
>
>>
>> We are using Mapper with a legacy database with many columns that we
>> are not allowed to rename in our database.  For example CREATE_DATE
>> for which we created the following seemingly simple mapped field in
>> our model:
>>
>>  object createDate extends MappedDateTime(this) {
>>    override def dbColumnName = "CREATE_DATE"
>>  }
>>
>> When we added "with CRUDify" the resulting List and Edit forms all
>> display this fields as Jan 01, 1970 all the time.  We tried this
>> experiment also with other columns of different types (MappedString,
>> MappedInt, MappedFriendlyString, MappedDouble, MappedBoolean) and
>> these all seemed to always display the default value rather than the
>> real data value from the database column.
>>
>
> This should have nothing to do with CRUDify.
>
> Can you provide a simple DDL and a very simple Lift app (along with the DB
> version you're running against) and we'll look into (please open a ticket)?
>
>
>>
>> We weren't sure if it was CRUDify or Mapper causing the problem.  I
>> think we narrowed it down to the Mapper by creating our own simple
>> snippet to create a basic HTML table and bound this value using
>>
>> class ProjType {
>>  def projects(xhtml: NodeSeq): NodeSeq =
>>     ProjectType.findAll(OrderBy(ProjectType.createDate, Ascending))
>>      .flatMap(aProjType => bind("projtype", xhtml,
>>                 "createDate" -> aProjType.createDate))
>> }
>>
>> and our xhtml section that uses this snippet is:
>>
>>  <table>
>>   <lift:snippet type="ProjType:projects">
>>    <tr>
>>      <td><projtype:createDate>01/01/2009</projtype:createDate></td>
>>    </tr>
>>   </lift:snippet>
>>  </table>
>>
>> but createDate is still coming back Jan 01, 1970 in our custom
>> rendered table.
>>
>> If we instead changed our mapped field name in our class to match the
>> legacy column name (CREATE_DATE) exactly:
>>
>>  object CREATE_DATE extends MappedDateTime(this)
>>
>> and our binding to "createDate" -> aProjType.CREATE_DATE
>>
>> everything is happy (both CRUDify and our custom form).
>>
>> We're not sure if this is a bug or if we're doing something wrong.
>>
>> Thanks, Troy
>>
>>
>>
>
>
> --
> 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 [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