I just spent a couple days getting the integration together in a draft way with the most recent changes in Lift and some pretty nice refinements of the DSL when using Records by Max.
Here's some example code using Records with Squeryl (adapted from the test project):
val kenFollet = new Author().age(59).name("Ken Follet")
authors.insert(kenFollet)
val alexandreDumas = new Author().age(70).name("Alexandre Dumas")
authors.insert(alexandreDumas)
val pillarsOfTheEarth = new Book().name("Pillars Of The Earth").authorId(kenFollet.id)
books.insert(pillarsOfTheEarth)
val laReineMargot = new Book().name("La Reine Margot").authorId(alexandreDumas.id)
books.insert(laReineMargot)
val qLaReineLargot = from(books, authors)((b,a) =>
where((a.name.value like "Alex%") and b.authorId === a.id)
select(b)
)
It seems to at least trivially work, so I think it'd be good if anyone interested started looking at it and using it a little for feedback.
The code for the integration is in a branch on github, rmm_wip_479: http://github.com/dpp/liftweb/commits/rmm_wip_479
And there is a test project: http://github.com/Dridus/test-squerylrecord
To use the code, you'll have to pull down a copy of rmm_wip_479 and then build and install that via mvn clean install. To run the test project, you'll have to have sbt and then do sbt clean update run.
The client code for the test project is KickTheTires.scala:
http://github.com/Dridus/test-squerylrecord/blob/master/src/main/scala/test/KickTheTires.scala
And the models are located in src/main/scala/test/model
Note that Squeryl requires Scala 2.8, so rmm_wip_479 is for Scala 2.8.0.RC6, not 2.7. Also note this is clearly not production level code, and I'm not sure how soon it will be in Lift and if so in what version (probably 3.0?).
The integration is composed of three primary parts, all located in lift-squeryl-record in liftweb/framework/lift-persistence:
- SquerylRecord object, which provides a method for setting up the environment properly for using Records with Squeryl. In particular, the init method must be called before any Records are used with Squeryl otherwise metadata will probably get incorrectly built.
- RecordMetaDataFactory which is a FieldMetaDataFactory for Squeryl that knows how to introspect the Record metadata and treat Record fields. Squeryl is configured to use RecordMetaDataFactory by SquerylRecord.init
- RecordTypeMode which is a specialization of Squeryl's PrimitiveTypeMode that supports using fields in the query DSL smoothly.
I _think_ at this point the entire Squeryl DSL should be supported... NULL types, sums, groups, etc. Max, please let me know if you think some of it isn't supported yet.
Have fun and please let Max and I know how you like it or if there are problems.
-Ross
P.S. Tim, I ripped out your JDBC stuff. I'll explain offline.
No testing done, but boy that looks clean.
Great stuff.
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.