@@ -15,8 +15,6 @@ You need `libpq` installed and available in your `$PATH`.
15
15
This package is uploaded to MavenCentral and supports macOS and linuxX64.
16
16
Windows is currently not supported.
17
17
18
- Supported SQLDelight version: 2.0.0-alpha05.
19
-
20
18
```` kotlin
21
19
repositories {
22
20
mavenCentral()
@@ -26,7 +24,7 @@ dependencies {
26
24
implementation(" app.softwork:postgres-native-sqldelight-driver:LATEST" )
27
25
}
28
26
29
- // optional SQLDelight setup: requires 2.0.0-alpha05
27
+ // optional SQLDelight setup:
30
28
sqldelight {
31
29
databases.register(" NativePostgres" ) {
32
30
dialect(" app.softwork:postgres-native-sqldelight-dialect:LATEST" )
@@ -49,10 +47,11 @@ val driver = PostgresNativeDriver(
49
47
)
50
48
```
51
49
50
+ ### Listeners
51
+
52
52
This driver supports local and remote listeners.
53
- Local listeners only notify this client, ideally for testing or using the database with only one client at a time with
54
- SQLDelight only.
55
- Remote listener support uses ` NOTIFY ` and ` LISTEN ` , so you can use this with multiple clients or with existing database
53
+ Local listeners only notify this client, ideally for testing or using the database with only one client at a time.
54
+ Remote listener support uses ` NOTIFY ` and ` LISTEN ` , so you can use this to sync multiple clients or with existing database
56
55
triggers.
57
56
SQLDelight uses and expects the table name as payload, but you can provide a mapper function.
58
57
@@ -69,35 +68,9 @@ The identifier is used to reuse prepared statements.
69
68
driver.execute(identifier = null , sql = " INSERT INTO foo VALUES (42)" , parameters = 0 , binders = null )
70
69
```
71
70
72
- It also supports a real lazy cursor or a Flow. The ` fetchSize ` parameter defines how many rows are fetched at once:
71
+ It also supports a real lazy cursor by using a ` Flow ` . The ` fetchSize ` parameter defines how many rows are fetched at once:
73
72
74
73
``` kotlin
75
- val names: List <Simple > = driver.executeQueryWithNativeCursor(
76
- identifier = null ,
77
- sql = " SELECT index, name, bytes FROM foo" ,
78
- mapper = { cursor ->
79
- // You need to call `next` and use the cursor to return your type, here it is a list.
80
-
81
- // Important, don't leak this cursor, eg by returning a Sequence,
82
- // otherwise the cursor will be closed before fetching rows.
83
- // If you need to use an async iterator, use the `Flow` overload, `executeQueryAsFlow`.
84
- buildList {
85
- while (cursor.next()) {
86
- add(
87
- Simple (
88
- index = cursor.getLong(0 )!! .toInt(),
89
- name = cursor.getString(1 ),
90
- byteArray = cursor.getBytes(2 )
91
- )
92
- )
93
- }
94
- }
95
- },
96
- parameters = 0 ,
97
- fetchSize = 100 ,
98
- binders = null
99
- )
100
-
101
74
val namesFlow: Flow <Simple > = driver.executeQueryAsFlow(
102
75
identifier = null ,
103
76
sql = " SELECT index, name, bytes FROM foo" ,
@@ -146,12 +119,6 @@ For compilers to find libpq you may need to set:
146
119
147
120
If you install libpq with homebrew, it will install the platform-specific artifact.
148
121
149
- | Host | Supported test targets |
150
- | -------------| ------------------------|
151
- | linux x64 | linux x64 |
152
- | macOS x64 | macOS x64 |
153
- | macOS arm64 | macOS arm64 |
154
-
155
122
To test other platforms, eg. linux x64 on macOS, you need to install the platform-specific libpq of linux x64 too.
156
123
157
124
To start the postgres instance, you can use docker:
0 commit comments