IAM: Add String() method to DBTime struct (#111308)

add String() method to DBTime struct
This commit is contained in:
Mihai Doarna
2025-09-18 15:41:20 +03:00
committed by GitHub
parent acd9838701
commit 7c2846dfdf
25 changed files with 38 additions and 30 deletions
+8
View File
@@ -79,6 +79,14 @@ func (t DBTime) Value() (driver.Value, error) {
return t.Format(time.DateTime), nil
}
func (t DBTime) String() string {
if t.IsZero() {
return ""
}
return t.Format(time.DateTime)
}
func (t *DBTime) Scan(value interface{}) error {
if value == nil {
t.Time = time.Time{}
@@ -2,4 +2,4 @@ INSERT INTO `grafana`.`org_user`
(org_id, user_id, role, created, updated)
VALUES
(2, 456, 'Admin',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00')
@@ -2,4 +2,4 @@ INSERT INTO `grafana`.`org_user`
(org_id, user_id, role, created, updated)
VALUES
(1, 123, 'Viewer',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00')
@@ -4,4 +4,4 @@ INSERT INTO `grafana`.`user`
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
false, true, '', '', '2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00 +0000 UTC')
@@ -4,4 +4,4 @@ INSERT INTO `grafana`.`user`
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
false, true, '', '', '2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00 +0000 UTC')
@@ -1,6 +1,6 @@
INSERT INTO `grafana`.`team`
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-1', 'Team 1', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team1@example.com', FALSE,
('team-1', 'Team 1', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team1@example.com', FALSE,
'')
@@ -1,6 +1,6 @@
INSERT INTO `grafana`.`team`
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-2', 'Team 2', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team2@example.com', TRUE,
('team-2', 'Team 2', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team2@example.com', TRUE,
'team-2-uid')
@@ -6,4 +6,4 @@ VALUES
'Admin User', 2, TRUE,
FALSE, TRUE,
TRUE, false, 'adminsalt', 'adminrands',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00')
@@ -6,4 +6,4 @@ VALUES
'User One', 1, FALSE,
FALSE, TRUE,
FALSE, false, 'randomsalt', 'randomrands',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00')
@@ -2,4 +2,4 @@ INSERT INTO "grafana"."org_user"
(org_id, user_id, role, created, updated)
VALUES
(2, 456, 'Admin',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00')
@@ -2,4 +2,4 @@ INSERT INTO "grafana"."org_user"
(org_id, user_id, role, created, updated)
VALUES
(1, 123, 'Viewer',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00')
@@ -4,4 +4,4 @@ INSERT INTO "grafana"."user"
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
false, true, '', '', '2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00 +0000 UTC')
@@ -4,4 +4,4 @@ INSERT INTO "grafana"."user"
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
false, true, '', '', '2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00 +0000 UTC')
@@ -1,6 +1,6 @@
INSERT INTO "grafana"."team"
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-1', 'Team 1', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team1@example.com', FALSE,
('team-1', 'Team 1', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team1@example.com', FALSE,
'')
@@ -1,6 +1,6 @@
INSERT INTO "grafana"."team"
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-2', 'Team 2', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team2@example.com', TRUE,
('team-2', 'Team 2', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team2@example.com', TRUE,
'team-2-uid')
@@ -6,4 +6,4 @@ VALUES
'Admin User', 2, TRUE,
FALSE, TRUE,
TRUE, false, 'adminsalt', 'adminrands',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00')
@@ -6,4 +6,4 @@ VALUES
'User One', 1, FALSE,
FALSE, TRUE,
FALSE, false, 'randomsalt', 'randomrands',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00')
@@ -2,4 +2,4 @@ INSERT INTO "grafana"."org_user"
(org_id, user_id, role, created, updated)
VALUES
(2, 456, 'Admin',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00')
@@ -2,4 +2,4 @@ INSERT INTO "grafana"."org_user"
(org_id, user_id, role, created, updated)
VALUES
(1, 123, 'Viewer',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00')
@@ -4,4 +4,4 @@ INSERT INTO "grafana"."user"
VALUES
('abcdef', 0, 'sa-1-service-account-1', 'sa-1-service-account-1', 'Service Account 1',
1, false, FALSE, false,
false, true, '', '', '2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
false, true, '', '', '2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00 +0000 UTC')
@@ -4,4 +4,4 @@ INSERT INTO "grafana"."user"
VALUES
('abcdef', 0, 'sa-2-disabled-service-account', 'sa-2-disabled-service-account', 'Disabled Service Account',
2, false, TRUE, false,
false, true, '', '', '2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
false, true, '', '', '2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00 +0000 UTC')
@@ -1,6 +1,6 @@
INSERT INTO "grafana"."team"
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-1', 'Team 1', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team1@example.com', FALSE,
('team-1', 'Team 1', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team1@example.com', FALSE,
'')
@@ -1,6 +1,6 @@
INSERT INTO "grafana"."team"
(uid, name, org_id, created, updated, email, is_provisioned, external_uid)
VALUES
('team-2', 'Team 2', 1, '2023-01-01 12:00:00 +0000 UTC',
'2023-01-01 12:00:00 +0000 UTC', 'team2@example.com', TRUE,
('team-2', 'Team 2', 1, '2023-01-01 12:00:00',
'2023-01-01 12:00:00', 'team2@example.com', TRUE,
'team-2-uid')
@@ -6,4 +6,4 @@ VALUES
'Admin User', 2, TRUE,
FALSE, TRUE,
TRUE, false, 'adminsalt', 'adminrands',
'2023-02-01 10:30:00 +0000 UTC', '2023-02-01 10:30:00 +0000 UTC', '2013-02-01 10:30:00 +0000 UTC')
'2023-02-01 10:30:00', '2023-02-01 10:30:00', '2013-02-01 10:30:00')
@@ -6,4 +6,4 @@ VALUES
'User One', 1, FALSE,
FALSE, TRUE,
FALSE, false, 'randomsalt', 'randomrands',
'2023-01-01 12:00:00 +0000 UTC', '2023-01-01 12:00:00 +0000 UTC', '2013-01-01 12:00:00 +0000 UTC')
'2023-01-01 12:00:00', '2023-01-01 12:00:00', '2013-01-01 12:00:00')