go-gorm / clickhouse

GORM clickhouse driver
MIT License
249 stars 72 forks source link

QuoteTo function has bugs #107

Open taomin597715379 opened 1 year ago

taomin597715379 commented 1 year ago

GORM Playground Link

https://github.com/go-gorm/playground/pull/1

Description

There is an issue with the QuoteTo method for the tuple data type of clickhouse, which resulted in the data not being written. An attempt was made to fix the issue, and the code is as follows:

func (dialector Dialector)  QuoteTo(writer clause.Writer, str string) {
    writer.WriteByte('`')
    if strings.Contains(str, ".") {
        for idx, str := range strings.Split(str, ".") {
            if idx > 0 {
                writer.WriteString(".")
            }
            writer.WriteString(str)
        }
        writer.WriteByte('`')
    } else {
        writer.WriteString(str)
        writer.WriteByte('`')
    }

}