We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func NewMysqlServer(db sql.Database) (*MysqlConfig, *server.Server, error) { port, err := util.GetFreePort() if err != nil { return nil, nil, fmt.Errorf("get free port failed, %w", err) } engine := sqle.NewDefault( sql.NewDatabaseProvider( createTestDatabase(), information_schema.NewInformationSchemaDatabase(), )) config := server.Config{ Protocol: "tcp", Address: "127.0.0.1:" + strconv.Itoa(port), Auth: auth.NewNativeSingle("user", "pass", auth.AllPermissions), } s, err := server.NewDefaultServer(config, engine) if err != nil { return nil, nil, fmt.Errorf("new mysql server failed, %w", err) } return &MysqlConfig{ User: "user", Password: "pass", Address: config.Address, }, s, nil } func createTestDatabase() *memory.Database { const ( dbName = "test" tableName = "mytable" ) db := memory.NewDatabase(dbName) table := memory.NewTable(tableName, sql.Schema{ {Name: "name", Type: sql.Text, Nullable: false, Source: tableName}, {Name: "email", Type: sql.Text, Nullable: false, Source: tableName}, {Name: "phone_numbers", Type: sql.JSON, Nullable: false, Source: tableName}, {Name: "created_at", Type: sql.Timestamp, Nullable: false, Source: tableName}, }) db.AddTable(tableName, table) ctx := sql.NewEmptyContext() rows := []sql.Row{ sql.NewRow("John Doe", "john@doe.com", []string{"555-555-555"}, time.Now()), sql.NewRow("John Doe", "johnalt@doe.com", []string{}, time.Now()), sql.NewRow("Jane Doe", "jane@doe.com", []string{}, time.Now()), sql.NewRow("Evil Bob", "evilbob@gmail.com", []string{"555-666-555", "666-666-666"}, time.Now()), } for _, row := range rows { table.Insert(ctx, row) } return db }
Hi after init and start mysql server like above, I try to create a table has two unique fields while it goes an error;
mysql> CREATE TABLE `node_roles` (`node_id` bigint NOT NULL UNIQUE,`role` bigint NOT NULL UNIQUE); ERROR 1105 (HY000): Error: index already exists
run this ok in other mysql.
I don't know if the mysql version too low or some config not correct... Please help me. Thanks!
The text was updated successfully, but these errors were encountered:
This is a bug. @VinaiRachakonda, please follow up.
Sorry, something went wrong.
VinaiRachakonda
Successfully merging a pull request may close this issue.
Hi
after init and start mysql server like above, I try to create a table has two unique fields while it goes an error;
run this ok in other mysql.
I don't know if the mysql version too low or some config not correct...
Please help me. Thanks!
The text was updated successfully, but these errors were encountered: