<commit_before>package dialects

import (
	"errors"
	"fmt"
	sb "github.com/umisama/go-sqlbuilder"
)

type MySql struct{}

func (m MySql) QuerySuffix() string {
	return ";"
}

func (m MySql) BindVar(i int) string {
	return "?"
}

func (m MySql) QuoteField(field string) string {
	return "`" + field + "`"
}

func (m MySql) ColumnTypeToString(cc sb.ColumnConfig) (string, error) {
	if cc.Option().SqlType != "" {
		return cc.Option().SqlType, nil
	}

	typ := ""
	switch cc.Type() {
	case sb.ColumnTypeInt:
		typ = "INTEGER"
	case sb.ColumnTypeString:
		typ = fmt.Sprintf("VARCHAR(%d)", cc.Option().Size)
	case sb.ColumnTypeDate:
		typ = "DATETIME"
	case sb.ColumnTypeFloat:
		typ = "FLOAT"
	case sb.ColumnTypeBool:
		typ = "BOOLEAN"
	case sb.ColumnTypeBytes:
		typ = "BLOB"
	}

	if typ == "" {
		return "", errors.New("dialects: unknown column type")
	} else {
		return typ, nil
	}
}

func (m MySql) ColumnOptionToString(co *sb.ColumnOption) (string, error) {
	opt := ""
	args := make([]interface{}, 0)
	if co.PrimaryKey {
		opt = str_append(opt, "PRIMARY KEY")
	}
	if co.AutoIncrement {
		opt = str_append(opt, "AUTO_INCREMENT")
	}
	if co.NotNull {
		opt = str_append(opt, "NOT NULL")
	}
	if co.Unique {
		opt = str_append(opt, "UNIQUE")
	}
	if co.Default == nil {
		opt = str_append(opt, "DEFAULT NULL")
	} else {
		opt = str_append(opt, "DEFAULT ?")
		args = append(args, co.Default)
	}

	return opt, nil
}

func (m MySql) TableOptionToString(to *sb.TableOption) (string, []interface{}, error) {<commit_msg>Oops, type of MySQL dialect is invalid...<commit_after>package dialects

import (
	"errors"
	"fmt"
	sb "github.com/umisama/go-sqlbuilder"
)

type MySql struct{}

func (m MySql) QuerySuffix() string {
	return ";"
}

func (m MySql) BindVar(i int) string {
	return "?"
}

func (m MySql) QuoteField(field string) string {
	return "`" + field + "`"
}

func (m MySql) ColumnTypeToString(cc sb.ColumnConfig) (string, error) {
	if cc.Option().SqlType != "" {
		return cc.Option().SqlType, nil
	}

	typ := ""
	switch cc.Type() {
	case sb.ColumnTypeInt:
		typ = "INTEGER"
	case sb.ColumnTypeString:
		typ = fmt.Sprintf("VARCHAR(%d)", cc.Option().Size)
	case sb.ColumnTypeDate:
		typ = "DATETIME"
	case sb.ColumnTypeFloat:
		typ = "FLOAT"
	case sb.ColumnTypeBool:
		typ = "BOOLEAN"
	case sb.ColumnTypeBytes:
		typ = "BLOB"
	}

	if typ == "" {
		return "", errors.New("dialects: unknown column type")
	} else {
		return typ, nil
	}
}

func (m MySql) ColumnOptionToString(co *sb.ColumnOption) (string, []interface{}, error) {
	opt := ""
	args := make([]interface{}, 0)
	if co.PrimaryKey {
		opt = str_append(opt, "PRIMARY KEY")
	}
	if co.AutoIncrement {
		opt = str_append(opt, "AUTO_INCREMENT")
	}
	if co.NotNull {
		opt = str_append(opt, "NOT NULL")
	}
	if co.Unique {
		opt = str_append(opt, "UNIQUE")
	}
	if co.Default == nil {
		opt = str_append(opt, "DEFAULT NULL")
	} else {
		opt = str_append(opt, "DEFAULT ?")
		args = append(args, co.Default)
	}

	return opt, args, nil
}

func (m MySql) TableOptionToString(to *sb.TableOption) (string, []interface{}, error) {
{'fraction_non_alphanumeric': 0.16182707993474715, 'fraction_numerical': 0.0006525285481239804, 'mean_word_length': 3.8821656050955413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2800597', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1180, 'n_words': 288}