Skip to content

Commit 19d37b9

Browse files
committed
format
1 parent ffec1dd commit 19d37b9

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

docs/tutorial.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,20 +1334,46 @@ object CityId {
13341334
13351335
13361336
```scala
1337-
case class City2[T[_]](
1337+
case class City[T[_]](
13381338
id: T[CityId],
13391339
name: T[String],
13401340
countryCode: T[String],
13411341
district: T[String],
13421342
population: T[Long]
13431343
)
13441344
1345+
object City extends Table[City]() {
1346+
override def tableName: String = "city"
1347+
}
1348+
db.run(
1349+
City.insert.columns(
1350+
_.id := CityId(313373),
1351+
_.name := "test",
1352+
_.countryCode := "XYZ",
1353+
_.district := "district",
1354+
_.population := 1000000
1355+
)
1356+
)
1357+
1358+
db.run(City.select.filter(_.id === 313373).single) ==>
1359+
City[Sc](CityId(313373), "test", "XYZ", "district", 1000000)
1360+
```
1361+
1362+
```scala
1363+
case class City2[T[_]](
1364+
id: T[CityId2],
1365+
name: T[String],
1366+
countryCode: T[String],
1367+
district: T[String],
1368+
population: T[Long]
1369+
)
1370+
13451371
object City2 extends Table[City2]() {
13461372
override def tableName: String = "city"
13471373
}
13481374
db.run(
13491375
City2.insert.columns(
1350-
_.id := CityId(31337),
1376+
_.id := CityId2(31337),
13511377
_.name := "test",
13521378
_.countryCode := "XYZ",
13531379
_.district := "district",
@@ -1356,8 +1382,9 @@ db.run(
13561382
)
13571383
13581384
db.run(City2.select.filter(_.id === 31337).single) ==>
1359-
City2[Sc](CityId(31337), "test", "XYZ", "district", 1000000)
1360-
```
1385+
City2[Sc](CityId2(31337), "test", "XYZ", "district", 1000000)
1386+
1387+
st("customTableColumnNames") {
13611388
13621389
## Customizing Table and Column Names
13631390

scalasql/core/src/TypeMapper.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import java.util.UUID
2929
* Defaults are provided for most common Scala primitives, but you can also provide
3030
* your own by defining an `implicit val foo: TypeMapper[T]`
3131
*/
32-
trait TypeMapper[T] {outer =>
32+
trait TypeMapper[T] { outer =>
3333

3434
/**
3535
* The JDBC type of this type. Used for `setNull` which needs to know the
@@ -54,13 +54,13 @@ trait TypeMapper[T] {outer =>
5454

5555
/**
5656
* Create a new `TypeMapper[V]` based on this `TypeMapper[T]` given the
57-
* two conversion functions `f: V => T`, `g: T => V`
57+
* two conversion functions `f: V => T`, `g: T => V`
5858
*/
59-
def bimap[V](f: V => T, g: T => V): TypeMapper[V] = new TypeMapper[V]{
59+
def bimap[V](f: V => T, g: T => V): TypeMapper[V] = new TypeMapper[V] {
6060
def jdbcType: JDBCType = outer.jdbcType
6161
override def castTypeString: String = outer.castTypeString
6262
def get(r: ResultSet, idx: Int): V = g(outer.get(r, idx))
63-
def put(r: PreparedStatement, idx: Int, v: V): Unit = outer.put(r, idx, f(v))
63+
def put(r: PreparedStatement, idx: Int, v: V): Unit = outer.put(r, idx, f(v))
6464
}
6565
}
6666

0 commit comments

Comments
 (0)