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
SELECT TIME type, if over 24 hours, leading zero are added even if less 100 hours. Why is this? (is there any meaning? or bug?)
Please excuse my poor English, and if I missed something, I'm sorry.
CREATE TABLE time_test ( id INTEGER PRIMARY KEY, tm TIME ); INSERT INTO time_test (id, tm) VALUES (1, '01:12:34'); INSERT INTO time_test (id, tm) VALUES (2, '23:12:34'); INSERT INTO time_test (id, tm) VALUES (3, '123:12:34'); INSERT INTO time_test (id, tm) VALUES (4, '24:12:34');
func TestTest(t *testing.T) { db, err := sql.Open("mysql", "your_dsn") if err != nil { panic(err) } else if err = db.Ping(); err != nil { panic(err) } for id := 1; id <= 4; id++ { rows, err := db.Query(`SELECT id, tm FROM time_test WHERE id = ?`, id) if err != nil { t.Fatal(err) } if !rows.Next() { t.Fatal("no rows found") } var holder struct { ID int Tm string } err = rows.Scan(&holder.ID, &holder.Tm) if err != nil { t.Fatal(err) } rows.Close() fmt.Printf("id %d: %q\n", holder.ID, holder.Tm) } }
id 1: "01:12:34" id 2: "23:12:34" id 3: "123:12:34" id 4: "024:12:34" ... ❓
id 1: "01:12:34"
id 2: "23:12:34"
id 3: "123:12:34"
id 4: "024:12:34"
Driver version (or git SHA): v1.4.0
Go version: go1.10.3 darwin/amd64
Server version: MySQL 5.7
Server OS: macOS 10.13.5
The text was updated successfully, but these errors were encountered:
Nice catch. It seems bug of formatBinaryDateTime() which converts binary representation into text.
formatBinaryDateTime()
Sorry, something went wrong.
Fix TIME format for binary columns
5436878
fixes go-sql-driver#817
ee43fdd
dc3665b
f09c12c
Successfully merging a pull request may close this issue.
Issue description
SELECT TIME type, if over 24 hours, leading zero are added even if less 100 hours.
Why is this? (is there any meaning? or bug?)
Please excuse my poor English, and if I missed something, I'm sorry.
Preparations (in MySQL)
Example code
Output
id 1: "01:12:34"
id 2: "23:12:34"
id 3: "123:12:34"
id 4: "024:12:34"
... ❓Configuration
Driver version (or git SHA): v1.4.0
Go version: go1.10.3 darwin/amd64
Server version: MySQL 5.7
Server OS: macOS 10.13.5
The text was updated successfully, but these errors were encountered: