Skip to content

Commit 2802c62

Browse files
authored
Merge pull request #1583 from ydb-platform/examples
alias for scripting fake txx to query fake tx + refactored examples and SLO's for using database/sql legacy and propose implementations + added example for goose
2 parents 35cc3d5 + d708511 commit 2802c62

File tree

34 files changed

+1469
-81
lines changed

34 files changed

+1469
-81
lines changed

.github/workflows/examples.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
ydb-version: [ 24.1, 24.2, 24.3 ]
19-
application: [ native/table, native/query, database_sql, gorm, xorm ]
19+
application: [ native/table, native/query ]
2020
services:
2121
ydb:
2222
image: ydbplatform/local-ydb:${{ matrix.ydb-version }}
@@ -47,6 +47,48 @@ jobs:
4747
- name: Run basic example ${{ matrix.application }}
4848
working-directory: ./examples/basic/${{ matrix.application }}
4949
run: go run .
50+
basic-ydb-database-sql:
51+
concurrency:
52+
group: basic-ydb-${{ github.ref }}-${{ matrix.ydb-version }}-${{ matrix.application }}-${{ matrix.query_service }}
53+
cancel-in-progress: true
54+
runs-on: ubuntu-latest
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
ydb-version: [ 24.1, 24.2, 24.3 ]
59+
application: [ database/sql, gorm, xorm ]
60+
query_service: [ true, false ]
61+
services:
62+
ydb:
63+
image: ydbplatform/local-ydb:${{ matrix.ydb-version }}
64+
ports:
65+
- 2135:2135
66+
- 2136:2136
67+
- 8765:8765
68+
volumes:
69+
- /tmp/ydb_certs:/ydb_certs
70+
env:
71+
YDB_LOCAL_SURVIVE_RESTART: true
72+
YDB_USE_IN_MEMORY_PDISKS: true
73+
YDB_TABLE_ENABLE_PREPARED_DDL: true
74+
options: '-h localhost'
75+
env:
76+
OS: ubuntu-latest
77+
GO: 1.23.x
78+
YDB_CONNECTION_STRING: grpc://localhost:2136/local
79+
YDB_ANONYMOUS_CREDENTIALS: 1
80+
YDB_VERSION: ${{ matrix.ydb-version }}
81+
YDB_DATABASE_SQL_OVER_QUERY_SERVICE: ${{ matrix.query_service }}
82+
steps:
83+
- name: Checkout code
84+
uses: actions/checkout@v4
85+
- name: Install Go
86+
uses: actions/setup-go@v5
87+
with:
88+
cache: true
89+
- name: Run basic example ${{ matrix.application }}
90+
working-directory: ./examples/basic/${{ matrix.application }}
91+
run: go run .
5092
basic-postgres:
5193
concurrency:
5294
group: basic-postgres-${{ matrix.application }}-${{ github.ref }}

.github/workflows/slo.yml

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ jobs:
3232
strategy:
3333
matrix:
3434
sdk:
35-
- id: database_sql
36-
name: database-sql
37-
path: ./database/sql
38-
label: database/sql
35+
- id: database_sql_legacy
36+
name: database-sql-legacy
37+
path: ./database/sql/legacy
38+
label: database/sql/legacy
39+
- id: database_sql_propose
40+
name: database-sql-propose
41+
path: ./database/sql/propose
42+
label: database/sql/propose
3943
- id: native_query
4044
name: native-query
4145
path: ./native/query
@@ -44,14 +48,22 @@ jobs:
4448
name: native-table
4549
path: ./native/table
4650
label: native/table
47-
- id: gorm
48-
name: gorm
49-
path: ./gorm
50-
label: gorm
51-
- id: xorm
52-
name: xorm
53-
path: ./xorm
54-
label: xorm
51+
- id: gorm_legacy
52+
name: gorm-legacy
53+
path: ./gorm/legacy
54+
label: gorm/legacy
55+
- id: gorm_propose
56+
name: gorm-propose
57+
path: ./gorm/propose
58+
label: gorm/propose
59+
- id: xorm_legacy
60+
name: xorm-legacy
61+
path: ./xorm/legacy
62+
label: xorm/legacy
63+
- id: xorm_propose
64+
name: xorm-propose
65+
path: ./xorm/propose
66+
label: xorm/propose
5567

5668
concurrency:
5769
group: slo-${{ github.ref }}-${{ matrix.sdk.name }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Added alias from `ydb.WithFakeTx(ydb.ScriptingQueryMode)` to `ydb.WithFakeTx(ydb.QueryExecuteQueryMode)` for compatibility with legacy code
2+
13
## v3.95.0
24
* Added implementation of `database/sql` driver over query service client
35
* Added `ydb.WithQueryService(bool)` option to explicitly enable `database/sql` driver over query service client

SQL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,4 +651,4 @@ db := sql.OpenDB(connector)
651651
652652
## Example of usage <a name="example"></a>
653653
654-
[Basic example](https://github.com/ydb-platform/ydb-go-examples/tree/master/basic) about series written with `database/sql` driver for `YDB` placed in [examples repository](https://github.com/ydb-platform/ydb-go-examples/tree/master/database_sql)
654+
[Basic example](https://github.com/ydb-platform/ydb-go-sdk/tree/master/examples/basic/native/query) about series written with `database/sql` driver for `YDB` placed in [examples repository](https://github.com/ydb-platform/ydb-go-sdk/tree/master/examples/database/sql)
File renamed without changes.

examples/basic/database_sql/data.go renamed to examples/basic/database/sql/data.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
database_sql
3-
*/
4-
51
package main
62

73
import (

examples/basic/database_sql/main.go renamed to examples/basic/database/sql/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
}
3232
defer func() { _ = cc.Close(ctx) }()
3333

34-
prefix := path.Join(cc.Name(), "database_sql")
34+
prefix := path.Join(cc.Name(), "database/sql")
3535

3636
c, err := ydb.Connector(cc,
3737
ydb.WithAutoDeclare(),
File renamed without changes.

examples/go.mod

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ module examples
33
go 1.23
44

55
require (
6-
github.com/golang-jwt/jwt/v4 v4.5.0
6+
github.com/golang-jwt/jwt/v4 v4.5.1
77
github.com/google/uuid v1.6.0
88
github.com/gorilla/mux v1.8.0
99
github.com/lib/pq v1.10.2
10+
github.com/pressly/goose/v3 v3.23.1
1011
github.com/prometheus/client_golang v1.13.0
1112
github.com/ydb-platform/gorm-driver v0.1.3
1213
github.com/ydb-platform/ydb-go-sdk-auth-environ v0.3.0
1314
github.com/ydb-platform/ydb-go-sdk-prometheus/v2 v2.0.1
14-
github.com/ydb-platform/ydb-go-sdk/v3 v3.67.0
15+
github.com/ydb-platform/ydb-go-sdk/v3 v3.95.0
1516
github.com/ydb-platform/ydb-go-yc v0.12.1
16-
golang.org/x/sync v0.7.0
17+
golang.org/x/sync v0.10.0
1718
google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80
1819
gorm.io/driver/postgres v1.5.0
1920
gorm.io/driver/sqlite v1.5.0
2021
gorm.io/gorm v1.25.10
21-
modernc.org/sqlite v1.18.2
22+
modernc.org/sqlite v1.34.1
2223
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978
2324
xorm.io/xorm v1.3.2
2425
)
@@ -31,46 +32,45 @@ require (
3132
github.com/goccy/go-json v0.9.11 // indirect
3233
github.com/golang/protobuf v1.5.4 // indirect
3334
github.com/golang/snappy v0.0.4 // indirect
35+
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
3436
github.com/jackc/pgpassfile v1.0.0 // indirect
35-
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
36-
github.com/jackc/pgx/v5 v5.5.4 // indirect
37-
github.com/jackc/puddle/v2 v2.2.1 // indirect
37+
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
38+
github.com/jackc/pgx/v5 v5.7.1 // indirect
39+
github.com/jackc/puddle/v2 v2.2.2 // indirect
3840
github.com/jinzhu/inflection v1.0.0 // indirect
3941
github.com/jinzhu/now v1.1.5 // indirect
4042
github.com/jonboulle/clockwork v0.4.0 // indirect
4143
github.com/json-iterator/go v1.1.12 // indirect
42-
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
43-
github.com/mattn/go-isatty v0.0.17 // indirect
44+
github.com/mattn/go-isatty v0.0.20 // indirect
4445
github.com/mattn/go-sqlite3 v1.14.15 // indirect
4546
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
47+
github.com/mfridman/interpolate v0.0.2 // indirect
4648
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
4749
github.com/modern-go/reflect2 v1.0.2 // indirect
50+
github.com/ncruces/go-strftime v0.1.9 // indirect
4851
github.com/prometheus/client_model v0.5.0 // indirect
4952
github.com/prometheus/common v0.37.0 // indirect
50-
github.com/prometheus/procfs v0.8.0 // indirect
53+
github.com/prometheus/procfs v0.12.0 // indirect
5154
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
55+
github.com/sethvargo/go-retry v0.3.0 // indirect
5256
github.com/syndtr/goleveldb v1.0.0 // indirect
5357
github.com/yandex-cloud/go-genproto v0.0.0-20220815090733-4c139c0154e2 // indirect
5458
github.com/ydb-platform/ydb-go-genproto v0.0.0-20241112172322-ea1f63298f77 // indirect
5559
github.com/ydb-platform/ydb-go-yc-metadata v0.6.1 // indirect
56-
golang.org/x/crypto v0.24.0 // indirect
57-
golang.org/x/mod v0.17.0 // indirect
58-
golang.org/x/net v0.26.0 // indirect
59-
golang.org/x/sys v0.21.0 // indirect
60-
golang.org/x/text v0.16.0 // indirect
61-
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
60+
go.uber.org/multierr v1.11.0 // indirect
61+
golang.org/x/crypto v0.31.0 // indirect
62+
golang.org/x/net v0.30.0 // indirect
63+
golang.org/x/sys v0.28.0 // indirect
64+
golang.org/x/text v0.21.0 // indirect
6265
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
6366
google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291 // indirect
6467
google.golang.org/grpc v1.64.1 // indirect
6568
google.golang.org/protobuf v1.34.1 // indirect
66-
lukechampine.com/uint128 v1.2.0 // indirect
67-
modernc.org/cc/v3 v3.40.0 // indirect
68-
modernc.org/ccgo/v3 v3.16.13 // indirect
69-
modernc.org/libc v1.22.2 // indirect
70-
modernc.org/mathutil v1.5.0 // indirect
71-
modernc.org/memory v1.5.0 // indirect
72-
modernc.org/opt v0.1.3 // indirect
73-
modernc.org/strutil v1.1.3 // indirect
69+
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
70+
modernc.org/libc v1.55.3 // indirect
71+
modernc.org/mathutil v1.6.0 // indirect
72+
modernc.org/memory v1.8.0 // indirect
73+
modernc.org/strutil v1.2.0 // indirect
7474
modernc.org/token v1.1.0 // indirect
7575
)
7676

0 commit comments

Comments
 (0)