mailru / dbr

Additions to Go's database/sql for super fast performance and convenience. (fork of gocraft/dbr)
MIT License
178 stars 36 forks source link

ReturnStrings issue with quoted stings #36

Open dizzyfool opened 3 years ago

dizzyfool commented 3 years ago

Prepare db:

create table test
(
    date  DateTime,
    event String
) engine MergeTree() order by date;

Run go code:

func TestIssue2(t *testing.T) {
    conn, _ := dbr.Open("clickhouse", "http://user:pass@localhost:8123/db", nil)

    conn.Exec("truncate table test")

    // 4 rows
    query := `insert into test (date, event) values 
       ('2021-01-01 00:00:00', 'click'),
       ('2021-01-01 01:00:00', '"" '),
       ('2021-01-01 02:00:00', '"with quotes" 1'),
       ('2021-01-01 02:00:00', '"with quotes" 2')`

    conn.Exec(query)

    sess := conn.NewSession(nil)

    res, err := sess.Select("event").From("test").ReturnStrings()
    fmt.Println(err)
    fmt.Println(len(res))
    // 2 rows
}

I expect that it will be 4 rows in result.