You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: SQL_MIGRATION_v2_v3.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,39 @@
4
4
5
5
> Note: the article is being updated.
6
6
7
+
## `sql.Connector` initialization
8
+
9
+
Package `database/sql` provides two ways for making driver:
10
+
- from connection string (see [sql.Open(driverName, connectionString)](https://pkg.go.dev/database/sql#Open))
11
+
- from custom connector (see [sql.OpnDB(connector)](https://pkg.go.dev/database/sql#OpenDB))
12
+
13
+
Second way (making driver from connector) are different in `v2` and `v3`:
14
+
- in `v2`:
15
+
`ydbsql.Connector` returns single result (`sql.driver.Connector`) and init driver lazy on first request. This design causes rare errors.
16
+
```go
17
+
db:= sql.OpenDB(ydbsql.Connector(
18
+
ydbsql.WithDialer(dialer),
19
+
ydbsql.WithEndpoint(params.endpoint),
20
+
ydbsql.WithClient(&table.Client{
21
+
Driver: driver,
22
+
}),
23
+
))
24
+
defer db.Close()
25
+
```
26
+
- in `v3`:
27
+
`ydb.Connector` creates `sql.driver.Connector` from native `YDB` driver, returns two results (`sql.driver..Connector` and error) and exclude some lazy driver initialization.
In `ydb-go-sdk/v2/ydbsql` was allowed `sql.LevelReadCommitted` and `sql.LevelReadUncommitted` isolation levels for read-only interactive transactions. It implements with fake transaction with true `OnlineReadOnly` transaction control on each query inside transaction.
0 commit comments