Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Boolean type does not work in raw CREATE TABLE queries #611

Closed
@wolfrace

Description

@wolfrace

err: "invalid connection": query := "CREATE TABLE schema_migrations (version bigint not null primary key, dirty boolean not null)"
all is ok: query := "CREATE TABLE schema_migrations (version bigint not null primary key, dirty bit not null)"

package mysql

import (
   dbSql "database/sql"
   "os"
   "testing"
   "time"

   _ "github.com/go-sql-driver/mysql"
   "github.com/stretchr/testify/assert"
   "gopkg.in/src-d/go-mysql-server.v0"
   "gopkg.in/src-d/go-mysql-server.v0/auth"
   "gopkg.in/src-d/go-mysql-server.v0/mem"
   "gopkg.in/src-d/go-mysql-server.v0/server"
)

type DataSourceName struct {
   User     string
   Password string
   Host     string
   Database string
   Protocol string
}

var dsn = DataSourceName{
   User:     "root",
   Password: "123",
   Host:     "localhost:3400",
   Database: "roll",
   Protocol: "tcp",
}

func TestMain(m *testing.M) {
   engine := sqle.NewDefault()
   engine.AddDatabase(createTestDatabase(dsn.Database))

   config := server.Config{
   	Protocol: dsn.Protocol,
   	Address:  dsn.Host,
   	Auth:     auth.NewNativeSingle(dsn.User, dsn.Password, auth.AllPermissions),
   }

   s, err := server.NewDefaultServer(config, engine)
   if err != nil {
   	panic(err)
   }

   go s.Start()
   retCode := m.Run()
   s.Close()

   os.Exit(retCode)
}

func TestWorkWithDb(t *testing.T) {
   time.Sleep(1000 * time.Millisecond)
   conn, err := dbSql.Open("mysql", "root:123@tcp(localhost:3400)/roll")
   if err != nil {
   	t.Error(err)
   }
   defer conn.Close()

   //query := "CREATE TABLE schema_migrations (version bigint not null primary key, dirty boolean not null)"
   query := "CREATE TABLE schema_migrations (version bigint not null primary key, dirty bit not null)"

   _, err = conn.Exec(query)
   assert.NoError(t, err)
}

func createTestDatabase(dbName string) *mem.Database {
   return mem.NewDatabase(dbName)
}

Metadata

Metadata

Assignees

Labels

3rd-partyThird party compatibilitybugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions