Skip to content

Commit

Permalink
structure for new chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
tpolecat committed Mar 14, 2015
1 parent af7e76f commit dee9b1d
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 59 deletions.
2 changes: 1 addition & 1 deletion doc/src/main/tut/02-Toolkit.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ The types used for both APIs are identical; the difference lies only in the expo

### Vendor Extensions

The 0.2.0 release introduces small add-on libraries to support vendor-specific features outside the JDBC specification. Initial support libraries for [Hikari](https://github.com/brettwooldridge/HikariCP), [H2](http://h2database.com), [PostgreSQL](http://www.postgresql.org/), and [Specs2](http://etorreborre.github.io/specs2/) are available and are described briefly in a later chapter. This is an area of active development and contributions are especially welcome.
The 0.2.0 release introduced small add-on libraries to support vendor-specific features outside the JDBC specification. Initial support libraries for [Hikari](https://github.com/brettwooldridge/HikariCP), [H2](http://h2database.com), [PostgreSQL](http://www.postgresql.org/), and [Specs2](http://etorreborre.github.io/specs2/) are available and are described in later chapters. This is an area of active development and contributions are especially welcome.

4 changes: 4 additions & 0 deletions doc/src/main/tut/03-Connecting.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ val xa = DriverManagerTransactor[Task](

A `Transactor` is simply a structure that knows how to connect to a database, hand out connections, and clean them up; and with this knowledge it can transform `ConnectionIO ~> Task`, which gives us something we can run. Specifically it gives us a `Task` that, when run, will connect to the database and run our program in a single transaction.

The `DriverManagerTransactor` simply delegates to the `java.sql.DriverManager` to allocate connections, which is fine for development but inefficient for production use. In a later chapter we discuss other approaches for connection management.

Right, so let's do this.

```tut
val task = program1.transact(xa)
task.run
Expand Down
2 changes: 1 addition & 1 deletion doc/src/main/tut/10-Custom-Mappings.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ val create =
(drop *> create).quick.run
```

Note that our `check` output now knows about the `Json` and `Person` mappings. This is a side-effect of constructing instance above, which isn't a good design. Will revisit this, possibly after 0.2.0; this information is only used for diagnostics so it's not critical.
Note that our `check` output now knows about the `Json` and `Person` mappings. This is a side-effect of constructing instance above, which isn't a good design. Will revisit this for 0.3.0; this information is only used for diagnostics so it's not critical.

```tut:plain
sql"select owner from pet".query[Int].check.run
Expand Down
31 changes: 31 additions & 0 deletions doc/src/main/tut/12-Managing-Connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
layout: book
number: 12
title: Managing Connections
---

### Using the `java.sql.DriverManager`

### Using HikariCP

The `doobie-contrib-hikari` add-on provides a `Transactor` implementation backed by a [HikariCP](https://github.com/brettwooldridge/HikariCP) connection pool. Constructing an instance is an effect:

```scala
for {
xa <- HikariTransactor[Task]("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "")
_ <- longRunningProgram(xa) ensuring xa.shutdown
} yield ()
```

The returned instance is of type `HikariTransactor`, which provides a `shutdown` method (shown above) as well as a `configure` method that provides access to the underlying `HikariDataSource`. See the source for details.

### Using an Existing `java.sql.Connection`


### Using an Existing `javax.sql.DataSource`


### Building your own `Transactor`



57 changes: 0 additions & 57 deletions doc/src/main/tut/12-Vendor-Extensions.md

This file was deleted.

52 changes: 52 additions & 0 deletions doc/src/main/tut/13-Extensions-PostgreSQL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: book
number: 13
title: Extensions for PostgreSQL
---


### Array Types

Postgres typed arrays are supported and map to `Array`, `List`, `Vector`. Multi-dimensional arrays are not supported yet.

### Enum Types

### Geometric Types

The following geometric types are supported, and map to driver-supplied types. These will normally be mapped to application-specific types.
- the `box` schema type maps to `org.postgresql.geometric.PGbox`
- the `circle` schema type maps to `org.postgresql.geometric.PGcircle`
- the `lseg` schema type maps to `org.postgresql.geometric.PGlseg`
- the `path` schema type maps to `org.postgresql.geometric.PGpath`
- the `point` schema type maps to `org.postgresql.geometric.PGpoint`
- the `polygon` schema type maps to `org.postgresql.geometric.PGpolygon`

### PostGIS Types

This adds support for the main PostGIS types:

- `PGgeometry`
- `PGbox2d`
- `PGbox3d`

As well as the following abstract and fine-grained types carried by `PGgeometry`:

- `Geometry`
- `ComposedGeom`
- `GeometryCollection`
- `MultiLineString`
- `MultiPolygon`
- `PointComposedGeom`
- `LineString`
- `MultiPoint`
- `Polygon`
- `Point`

### Miscellaneous Nonstandard Types

- The `uuid` schema type is supported and maps to `java.util.UUID`.
- The `inet` schema type is supported and maps to `java.net.InetAddress`.

### Error Handling Extensions

A complete table of SQLSTATE values is provided in the `doobie.contrib.postgresql.sqlstate` module, and recovery combinators for each of these (`onUniqueViolation` for example) are provided in `doobie.contrib.postgresql.syntax`.
15 changes: 15 additions & 0 deletions doc/src/main/tut/14-Extensions-H2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
layout: book
number: 14
title: Extensions for H2
---

The `doobie-contrib-h2` add-on provides mappings for the following [H2](http://www.h2database.com/html/main.html) types in the `doobie.contrib.h2.h2types` module.

### Array Types

- H2 `array` types are supported and map to `Array`, `List`, `Vector`.

### Other Nonstandard Types

- The `uuid` type is supported and maps to `java.util.UUID`.

0 comments on commit dee9b1d

Please sign in to comment.