doobie : un jdbc fonctionnel qui ne cache pas sql

Post on 16-Apr-2017

100 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Feedbacks from the trenches

François ARMAND @fanf42 - 2016-10

?

Who knows...

??JdbcTemplate

Who knows...

??JdbcTemplate

?Who knows...

?

Anorm ??Who knows...

?JdbcTemplate

?

Anorm ?Squeryl ? ?JdbcTemplate

?Who knows...

?

Anorm ?Squeryl ? ?JdbcTemplate

?

?

Who knows...

?

Anorm ?Squeryl ? ?JdbcTemplate

?

?SQL?

Who knows...

OBJECT MAPPING

PURESQL

?

Anorm ?Squeryl ? ?JdbcTemplate

?

?SQL?

Love SQL ?

Who knows...

Who’s talkin’ for why?

● 10 years of Scala

● CTO @Normation● Lead-dev on Rudder● chose Scala 7y ago for Rudder

Continuous Configuration for Effective ComplianceFrançois ARMAND / @fanf42

● 10 years of Scala

● CTO @Normation● Lead-dev on Rudder● chose Scala 7y ago for Rudder

Continuous Configuration for Effective Compliance

Squeryl

François ARMAND / @fanf42

Who’s talkin’ for why?

● 10 years of Scala

● CTO @Normation● Lead-dev on Rudder● chose Scala 7y ago for Rudder

Continuous Configuration for Effective Compliance

SquerylJdbcTemplate

François ARMAND / @fanf42

Who’s talkin’ for why?

But what ?

● 10 years of Scala

● CTO @Normation● Lead-dev on Rudder● chose Scala 7y ago for Rudder

Continuous Configuration for Effective Compliance

SquerylJdbcTemplate

François ARMAND / @fanf42

Who’s talkin’ for why?

Slick 3 ?

● Fairly popular, ~ default choice in 2016 for Scala world

● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.

● Fairly popular, ~ default choice in 2016 for Scala world

● Let’s test it ! ⇒ ported ~ 50% of Rudder code to it.

● Does not work for us :● Feels magic and ORM-y, with *Surprises*

○ in generated SQL■ you can’t precisely control it (that’s the point)

○ in performance (using path of least resistance)■ ex: run-time compilation for EACH request in the path of least resistance

○ with lift embeding type ■ i.e working with Rep[MyClass] in place of MyClass

● An awful lot of boilerplate

Slick 3 ?

Doobie ?

Use Doobie. It’s GREAT.

Doobie

Use Doobie. It’s GREAT.

Questions ?

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

● Mapping is a joy (actually make me smile)

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

● Mapping is a joy (actually make me smile)

● No surprises :○ it just works as expected. ○ Performance are ~ raw JDBC.○ NO JDBC part is beyond reach.

■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

● Mapping is a joy (actually make me smile)

● No surprises :○ it just works as expected. ○ Performance are ~ raw JDBC.○ NO JDBC part is beyond reach.

■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.

● Rob Norris (@tpolecat) is über nice and helpful

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

● Mapping is a joy (actually make me smile)

● No surprises :○ it just works as expected. ○ Performance are ~ raw JDBC.○ NO JDBC part is beyond reach.

■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.

● Rob Norris (@tpolecat) is über nice and helpful

● It actually makes me like SQL ○ (it tooks 15 years, and PostgreSQL helps a lot)

Doobie

Use Doobie.It’s GREAT.

● A pure functional database access layer for Scala

● Mapping is a joy (actually make me smile)

● No surprises :○ it just works as expected. ○ Performance are ~ raw JDBC.○ NO JDBC part is beyond reach.

■ Even dirty things about JDBC connection like SQLXML. Or variable number of params.

● Rob Norris (@tpolecat) is über nice and helpful

● It actually makes me like SQL ○ (it tooks 15 years, and PostgreSQL helps a lot)

Doobie

A pure functional database access layer for Scala

● everything is a value● standard functional programming idioms apply● Clear separation of concepts

○ (I won’t talk about Free Monad - oups)

Mapping just works. Returns what you want.

Mapping just works. No boilerplate.

Mapping just works. No boilerplate.

Mapping just works. No boilerplate.

Performance (especially in pure FP) matters

● The exact, 50 lines if you want,SQL queries you want to write.

● PreparedStatement by default.● Batch updates are given.

● Comparison with JDBC

Rob Norris @tpolecat

(like, he produced working code for SQLXML mapping. At 3 a.m. Just for me)(OK, 3 a.m for my timezone. But still :)

is extremely nice and helpful

actually likes SQL

Yes. Really.

Savant word for

“Makes you love SQL - No surprise, it just works”

Questions ?

The End

Testing mapping in the repl

References

● Book of Doobie : https://tpolecat.github.io/doobie-0.3.0/00-index.html

● Really nice presentation of concepts:○ SBTB 2015: Rob Norris, Programs as Values: JDBC Programming with Doobie

■ https://www.youtube.com/watch?v=M5MF6M7FHPo

● https://twitter.com/tpolecat

● https://gitter.im/tpolecat/doobie

top related