ydb-platform / gorm-driver Goto Github PK
View Code? Open in Web Editor NEWGORM YDB driver
License: Apache License 2.0
GORM YDB driver
License: Apache License 2.0
https://gorm.io/docs/indexes.html
https://ydb.tech/en/docs/yql/reference/syntax/alter_table#secondary-index
behavior now:
db.AutoMigrate() failed when index already created
func TestSequentialAutoMigrateWithIndex(t *testing.T) {
type Migrations struct {
ID string `gorm:"primarykey;not null"`
Payload string `gorm:"index"`
}
dsn, has := os.LookupEnv("YDB_CONNECTION_STRING")
if !has {
t.Skip("skip test '" + t.Name() + "' without env 'YDB_CONNECTION_STRING'")
}
pathPrefix := t.Name()
for i := 0; i < 5; i++ {
t.Run("", func(t *testing.T) {
db, err := gorm.Open(
ydb.Open(dsn,
ydb.WithTablePathPrefix(pathPrefix),
),
)
require.NoError(t, err)
require.NotNil(t, db)
db = db.Debug()
err = db.AutoMigrate(&Migrations{})
require.NoError(t, err)
})
}
}
result:
=== RUN TestSequentialAutoMigrateWithIndex/#00
[494.824ms] [rows:0] CREATE TABLE `migrations` (`id` Utf8 NOT NULL,`payload` Utf8,PRIMARY KEY (`id`),INDEX `idx_migrations_payload` GLOBAL ON (`payload`))
--- PASS: TestSequentialAutoMigrateWithIndex/#00 (3.18s)
=== RUN TestSequentialAutoMigrateWithIndex/#01
[959.834ms] [rows:-] SELECT DATABASE()
[1095.721ms] [rows:-] SELECT count(*) FROM information_schema.statistics WHERE table_schema = $1 AND table_name = $2 AND index_name = $3
[327.297ms] [rows:0] CREATE INDEX `idx_migrations_payload` ON `migrations`(`payload`)
operation/GENERIC_ERROR (code = 400080, address = ..., issues = [{4:0 => 'Unexpected token 'CREATE' : cannot match to any predicted input...'}])
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*conn).Invoke(conn.go:361)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/balancer.(*Balancer).wrapCall(balancer.go:293)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).executeDataQuery(session.go:733)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/table.(*session).Execute(session.go:688)`
at `github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql.(*conn).execContext(conn.go:190)`
--- FAIL: TestSequentialAutoMigrateWithIndex/#01 (5.83s)
I tried code like this, but, as I understang this one is not working
db, err := gorm.Open(ydb.Open(os.Getenv("YDB_CONNECTION_STRING"),
ydb.WithTablePathPrefix("gorm"),
environ.WithEnvironCredentials(ctx)))
Is there a method to use this driver with authentication options?
some users want to use Datetime instead of Timestamp with time.Time
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.