IAM: Add String() method to DBTime struct (#111308)
add String() method to DBTime struct
This commit is contained in:
@@ -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{}
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
pkg/registry/apis/iam/legacy/testdata/mysql--create_service_account-create_service_account_basic.sql
Vendored
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+2
-2
@@ -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,
|
||||
'')
|
||||
|
||||
+2
-2
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
Vendored
+2
-2
@@ -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,
|
||||
'')
|
||||
|
||||
+2
-2
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+2
-2
@@ -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,
|
||||
'')
|
||||
|
||||
+2
-2
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
+1
-1
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user