Skip to content

Commit d835b0a

Browse files
sql/ydb: fixed introspection of index uniqueness
1 parent 9cba6f2 commit d835b0a

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ require (
4242
google.golang.org/grpc v1.78.0 // indirect
4343
google.golang.org/protobuf v1.36.11 // indirect
4444
)
45+
46+
replace github.com/ydb-platform/ydb-go-sdk/v3 => github.com/LostImagin4tion/ydb-go-sdk/v3 v3.0.1-lostimagin4tion

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
44
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
55
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
6+
github.com/LostImagin4tion/ydb-go-sdk/v3 v3.0.1-lostimagin4tion h1:vGGqY93e5JImp1Wnt7+8brPDvir/u1m/3NqacWeJYVQ=
7+
github.com/LostImagin4tion/ydb-go-sdk/v3 v3.0.1-lostimagin4tion/go.mod h1:stS1mQYjbJvwwYaYzKyFY9eMiuVXWWXQA6T+SpOLg9c=
68
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
79
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
810
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
@@ -107,8 +109,6 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
107109
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
108110
github.com/ydb-platform/ydb-go-genproto v0.0.0-20251222105147-0bf751469a4a h1:nRqONRrMFulP2bTWM2RRnPM1VDhWuBZg4ULXkG4xXdk=
109111
github.com/ydb-platform/ydb-go-genproto v0.0.0-20251222105147-0bf751469a4a/go.mod h1:Er+FePu1dNUieD+XTMDduGpQuCPssK5Q4BjF+IIXJ3I=
110-
github.com/ydb-platform/ydb-go-sdk/v3 v3.125.0 h1:KPnGV2diuX1A4/1zXLO1UWHJokWC8yICzEfjdkSUWKo=
111-
github.com/ydb-platform/ydb-go-sdk/v3 v3.125.0/go.mod h1:/LjMxb/rXmoGAAnImoqAFIlhO5ampHacbvDetQitCk4=
112112
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
113113
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
114114
github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0=

sql/ydb/inspect.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@ func (i *inspect) indexes(
293293
// secondary indexes
294294
for _, idx := range tableDesc.Indexes {
295295
atlasIdx := &schema.Index{
296-
Name: idx.Name,
297-
Table: table,
296+
Name: idx.Name,
297+
Table: table,
298+
Unique: idx.Type == options.GlobalUniqueIndex(),
298299
}
299300

300301
for _, columnName := range idx.IndexColumns {
@@ -311,16 +312,16 @@ func (i *inspect) indexes(
311312
indexAttrs := &IndexAttributes{
312313
Async: idx.Type == options.GlobalAsyncIndex(),
313314
}
315+
314316
for _, dataCol := range idx.DataColumns {
315317
column, ok := table.Column(dataCol)
316318
if !ok {
317319
return fmt.Errorf("ydb: cover column %q not found in table %q", dataCol, table.Name)
318320
}
319321
indexAttrs.CoverColumns = append(indexAttrs.CoverColumns, column)
320322
}
321-
if indexAttrs.Async || len(indexAttrs.CoverColumns) > 0 {
322-
atlasIdx.Attrs = append(atlasIdx.Attrs, indexAttrs)
323-
}
323+
324+
atlasIdx.Attrs = append(atlasIdx.Attrs, indexAttrs)
324325

325326
table.AddIndexes(atlasIdx)
326327
}

0 commit comments

Comments
 (0)