GithubHelp home page GithubHelp logo

gorm-driver's People

Contributors

asmyasnikov avatar dependabot[bot] avatar impressionableraccoon avatar rekby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gorm-driver's Issues

GORM: constraints in YDB

  1. return nil
  2. служебная табличка + nop
  3. попытка делать проверки на стороне GORM драйвера

feat: support database indexes

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.