Lift's Squeryl/Record integration preview

82 görüntüleme
İlk okunmamış mesaja atla

Ross Mellgren

okunmadı,
27 Haz 2010 01:45:3827.06.2010
alıcı liftweb
As has been mentioned on the list previously, there is an integration being developed by Max (Squeryl's author) and myself to use Squeryl as the data storage layer of Records, allowing one to use any of the Record abstractions such as form generation together with Squeryl's awesome DSL.

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.

TylerWeir

okunmadı,
27 Haz 2010 08:28:5227.06.2010
alıcı Lift
No testing done, but boy that looks clean.

Great stuff.

On Jun 27, 1:45 am, Ross Mellgren <dri...@gmail.com> wrote:
> As has been mentioned on the list previously, there is an integration being developed by Max (Squeryl's author) and myself to use Squeryl as the data storage layer of Records, allowing one to use any of the Record abstractions such as form generation together with Squeryl's awesome DSL.
>
> 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/scal...

Maxime Lévesque

okunmadı,
27 Haz 2010 09:35:4627.06.2010
alıcı Lift


Thanks Ross, regarding the readyness for production,
I am pretty confident of its stability, given that there is very
little code in it.
i.e. the code that gets excercised in a Squeryl-Record scenario will
be
more than 99% the same code as plain Squeryl code.
As far as completeness is concerned, the whole DSL should be
supported.

Cheers
> > P.S. Tim, I ripped out your JDBC stuff. I'll explain offline.- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

David Pollak

okunmadı,
28 Haz 2010 00:14:1928.06.2010
alıcı lif...@googlegroups.com
On Sun, Jun 27, 2010 at 5:28 AM, TylerWeir <tyler...@gmail.com> wrote:
No testing done, but boy that looks clean.

Great stuff.

Wicked sweet 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.




--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Blog: http://goodstuff.im
Surf the harmonics
Tümünü yanıtla
Yazarı yanıtla
Yönlendir
0 yeni ileti