Skip to content

Commit

Permalink
Merge pull request #69 from taosdata/feat/TD-27190
Browse files Browse the repository at this point in the history
fix timestamp PRECISION bug
  • Loading branch information
sheyanjie-qq authored Nov 13, 2023
2 parents 2b14a89 + 165d01b commit 65d085c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func parseSql(audit AuditInfo) string {
details = details[:MAX_DETAIL_LEN]
}

ts := time.UnixMilli(audit.Timestamp).Format(time.RFC3339)
ts := time.UnixMilli(audit.Timestamp).Format(time.RFC3339Nano)
return fmt.Sprintf(
"insert into %s using operations_v2 tags ('%s') values ('%s', '%s', '%s', '%s', '%s', '%s', '%s')",
getTableName(audit), audit.ClusterID, ts, audit.User, audit.Operation, audit.Db, audit.Resource, audit.ClientAdd, details)
Expand Down
12 changes: 6 additions & 6 deletions api/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ func TestAudit(t *testing.T) {
}{
{
name: "1",
ts: 1692840000000,
data: `{"timestamp": 1692840000000, "cluster_id": "cluster_id", "user": "user", "operation": "operation", "db":"dbnamea", "resource":"resourcenamea", "client_add": "localhost:30000", "details": "detail"}`,
ts: 1699839716440,
data: `{"timestamp": 1699839716440, "cluster_id": "cluster_id", "user": "user", "operation": "operation", "db":"dbnamea", "resource":"resourcenamea", "client_add": "localhost:30000", "details": "detail"}`,
expect: "detail",
},
{
name: "2",
ts: 1692850000000,
data: `{"timestamp": 1692850000000, "cluster_id": "cluster_id", "user": "user", "operation": "operation", "db":"dbnamea", "resource":"resourcenamea", "client_add": "localhost:30000", "details": "` + longDetails + `"}`,
ts: 1699839716441,
data: `{"timestamp": 1699839716441, "cluster_id": "cluster_id", "user": "user", "operation": "operation", "db":"dbnamea", "resource":"resourcenamea", "client_add": "localhost:30000", "details": "` + longDetails + `"}`,
expect: longDetails[:50000],
},
{
name: "3",
ts: 1692860000000,
data: "{\"timestamp\": 1692860000000, \"cluster_id\": \"cluster_id\", \"user\": \"user\", \"operation\": \"operation\", \"db\":\"dbnameb\", \"resource\":\"resourcenameb\", \"client_add\": \"localhost:30000\", \"details\": \"create database `meter` buffer 32 cachemodel 'none' duration 50d keep 3650d single_stable 0 wal_retention_period 3600 precision 'ms'\"}",
ts: 1699839716442,
data: "{\"timestamp\": 1699839716442, \"cluster_id\": \"cluster_id\", \"user\": \"user\", \"operation\": \"operation\", \"db\":\"dbnameb\", \"resource\":\"resourcenameb\", \"client_add\": \"localhost:30000\", \"details\": \"create database `meter` buffer 32 cachemodel 'none' duration 50d keep 3650d single_stable 0 wal_retention_period 3600 precision 'ms'\"}",
expect: "create database `meter` buffer 32 cachemodel 'none' duration 50d keep 3650d single_stable 0 wal_retention_period 3600 precision 'ms'",
},
}
Expand Down

0 comments on commit 65d085c

Please sign in to comment.