mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
perf: query data AS OF SYSTEM TIME
(#5231)
Queries the data in the storage layser at the timestamp when the call hit the API layer
This commit is contained in:
@@ -12,6 +12,33 @@ import (
|
||||
errs "github.com/zitadel/zitadel/internal/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
preparePrivacyPolicyStmt = `SELECT projections.privacy_policies2.id,` +
|
||||
` projections.privacy_policies2.sequence,` +
|
||||
` projections.privacy_policies2.creation_date,` +
|
||||
` projections.privacy_policies2.change_date,` +
|
||||
` projections.privacy_policies2.resource_owner,` +
|
||||
` projections.privacy_policies2.privacy_link,` +
|
||||
` projections.privacy_policies2.tos_link,` +
|
||||
` projections.privacy_policies2.help_link,` +
|
||||
` projections.privacy_policies2.is_default,` +
|
||||
` projections.privacy_policies2.state` +
|
||||
` FROM projections.privacy_policies2` +
|
||||
` AS OF SYSTEM TIME '-1 ms'`
|
||||
preparePrivacyPolicyCols = []string{
|
||||
"id",
|
||||
"sequence",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"privacy_link",
|
||||
"tos_link",
|
||||
"help_link",
|
||||
"is_default",
|
||||
"state",
|
||||
}
|
||||
)
|
||||
|
||||
func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
type want struct {
|
||||
sqlExpectations sqlExpectation
|
||||
@@ -28,17 +55,7 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
prepare: preparePrivacyPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueries(
|
||||
regexp.QuoteMeta(`SELECT projections.privacy_policies2.id,`+
|
||||
` projections.privacy_policies2.sequence,`+
|
||||
` projections.privacy_policies2.creation_date,`+
|
||||
` projections.privacy_policies2.change_date,`+
|
||||
` projections.privacy_policies2.resource_owner,`+
|
||||
` projections.privacy_policies2.privacy_link,`+
|
||||
` projections.privacy_policies2.tos_link,`+
|
||||
` projections.privacy_policies2.help_link,`+
|
||||
` projections.privacy_policies2.is_default,`+
|
||||
` projections.privacy_policies2.state`+
|
||||
` FROM projections.privacy_policies2`),
|
||||
regexp.QuoteMeta(preparePrivacyPolicyStmt),
|
||||
nil,
|
||||
nil,
|
||||
),
|
||||
@@ -56,29 +73,8 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
prepare: preparePrivacyPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQuery(
|
||||
regexp.QuoteMeta(`SELECT projections.privacy_policies2.id,`+
|
||||
` projections.privacy_policies2.sequence,`+
|
||||
` projections.privacy_policies2.creation_date,`+
|
||||
` projections.privacy_policies2.change_date,`+
|
||||
` projections.privacy_policies2.resource_owner,`+
|
||||
` projections.privacy_policies2.privacy_link,`+
|
||||
` projections.privacy_policies2.tos_link,`+
|
||||
` projections.privacy_policies2.help_link,`+
|
||||
` projections.privacy_policies2.is_default,`+
|
||||
` projections.privacy_policies2.state`+
|
||||
` FROM projections.privacy_policies2`),
|
||||
[]string{
|
||||
"id",
|
||||
"sequence",
|
||||
"creation_date",
|
||||
"change_date",
|
||||
"resource_owner",
|
||||
"privacy_link",
|
||||
"tos_link",
|
||||
"help_link",
|
||||
"is_default",
|
||||
"state",
|
||||
},
|
||||
regexp.QuoteMeta(preparePrivacyPolicyStmt),
|
||||
preparePrivacyPolicyCols,
|
||||
[]driver.Value{
|
||||
"pol-id",
|
||||
uint64(20211109),
|
||||
@@ -111,17 +107,7 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
prepare: preparePrivacyPolicyQuery,
|
||||
want: want{
|
||||
sqlExpectations: mockQueryErr(
|
||||
regexp.QuoteMeta(`SELECT projections.privacy_policies2.id,`+
|
||||
` projections.privacy_policies2.sequence,`+
|
||||
` projections.privacy_policies2.creation_date,`+
|
||||
` projections.privacy_policies2.change_date,`+
|
||||
` projections.privacy_policies2.resource_owner,`+
|
||||
` projections.privacy_policies2.privacy_link,`+
|
||||
` projections.privacy_policies2.tos_link,`+
|
||||
` projections.privacy_policies2.help_link,`+
|
||||
` projections.privacy_policies2.is_default,`+
|
||||
` projections.privacy_policies2.state`+
|
||||
` FROM projections.privacy_policies2`),
|
||||
regexp.QuoteMeta(preparePrivacyPolicyStmt),
|
||||
sql.ErrConnDone,
|
||||
),
|
||||
err: func(err error) (error, bool) {
|
||||
@@ -136,7 +122,7 @@ func Test_PrivacyPolicyPrepares(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
assertPrepare(t, tt.prepare, tt.object, tt.want.sqlExpectations, tt.want.err)
|
||||
assertPrepare(t, tt.prepare, tt.object, tt.want.sqlExpectations, tt.want.err, defaultPrepareArgs...)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user