-
Notifications
You must be signed in to change notification settings - Fork 348
/
statement.scala
127 lines (95 loc) · 3.41 KB
/
statement.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright (c) 2013-2018 Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT
package doobie.hi
import doobie.enum.Holdability
import doobie.enum.FetchDirection
import doobie.enum.ResultSetConcurrency
import doobie.enum.ResultSetType
import doobie.syntax.monaderror._
import java.sql.SQLWarning
import scala.Predef.intArrayOps
/**
* Module of high-level constructors for `StatementIO` actions.
* @group Modules
*/
object statement {
/** @group Batching */
def addBatch(sql: String): StatementIO[Unit] =
FS.addBatch(sql)
/** @group Batching */
val clearBatch: StatementIO[Unit] =
FS.clearBatch
/** @group Execution */
val executeBatch: StatementIO[List[Int]] =
FS.executeBatch.map(_.toList)
/** @group Execution */
def executeQuery[A](sql: String)(k: ResultSetIO[A]): StatementIO[A] =
FS.executeQuery(sql).flatMap(s => FS.embed(s, k guarantee FRS.close))
/** @group Execution */
def executeUpdate(sql: String): StatementIO[Int] =
FS.executeUpdate(sql)
/** @group Properties */
val getFetchDirection: StatementIO[FetchDirection] =
FS.getFetchDirection.map(FetchDirection.unsafeFromInt)
/** @group Properties */
val getFetchSize: StatementIO[Int] =
FS.getFetchSize
/** @group Results */
def getGeneratedKeys[A](k: ResultSetIO[A]): StatementIO[A] =
FS.getGeneratedKeys.flatMap(s => FS.embed(s, k guarantee FRS.close))
/** @group Properties */
val getMaxFieldSize: StatementIO[Int] =
FS.getMaxFieldSize
/** @group Properties */
val getMaxRows: StatementIO[Int] =
FS.getMaxRows
// /** @group Batching */
// def getMoreResults(a: Int): StatementIO[Boolean] =
// Predef.???
/** @group Batching */
val getMoreResults: StatementIO[Boolean] =
FS.getMoreResults
/** @group Properties */
val getQueryTimeout: StatementIO[Int] =
FS.getQueryTimeout
/** @group Batching */
def getResultSet[A](k: ResultSetIO[A]): StatementIO[A] =
FS.getResultSet.flatMap(s => FS.embed(s, k))
/** @group Properties */
val getResultSetConcurrency: StatementIO[ResultSetConcurrency] =
FS.getResultSetConcurrency.map(ResultSetConcurrency.unsafeFromInt)
/** @group Properties */
val getResultSetHoldability: StatementIO[Holdability] =
FS.getResultSetHoldability.map(Holdability.unsafeFromInt)
/** @group Properties */
val getResultSetType: StatementIO[ResultSetType] =
FS.getResultSetType.map(ResultSetType.unsafeFromInt)
/** @group Results */
val getUpdateCount: StatementIO[Int] =
FS.getUpdateCount
/** @group Results */
val getWarnings: StatementIO[SQLWarning] =
FS.getWarnings
/** @group Properties */
def setCursorName(name: String): StatementIO[Unit] =
FS.setCursorName(name)
/** @group Properties */
def setEscapeProcessing(a: Boolean): StatementIO[Unit] =
FS.setEscapeProcessing(a)
/** @group Properties */
def setFetchDirection(fd: FetchDirection): StatementIO[Unit] =
FS.setFetchDirection(fd.toInt)
/** @group Properties */
def setFetchSize(n: Int): StatementIO[Unit] =
FS.setFetchSize(n)
/** @group Properties */
def setMaxFieldSize(n: Int): StatementIO[Unit] =
FS.setMaxFieldSize(n)
/** @group Properties */
def setMaxRows(n: Int): StatementIO[Unit] =
FS.setMaxRows(n)
/** @group Properties */
def setQueryTimeout(a: Int): StatementIO[Unit] =
FS.setQueryTimeout(a)
}