mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix: handle user metadata projection correctly (#4098)
This commit is contained in:
parent
6b30be77e6
commit
dba0fdcf7b
@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
UserMetadataProjectionTable = "projections.user_metadata"
|
||||
UserMetadataProjectionTable = "projections.user_metadata2"
|
||||
|
||||
UserMetadataColumnUserID = "user_id"
|
||||
UserMetadataColumnCreationDate = "creation_date"
|
||||
@ -42,7 +42,7 @@ func newUserMetadataProjection(ctx context.Context, config crdb.StatementHandler
|
||||
crdb.NewColumn(UserMetadataColumnKey, crdb.ColumnTypeText),
|
||||
crdb.NewColumn(UserMetadataColumnValue, crdb.ColumnTypeBytes, crdb.Nullable()),
|
||||
},
|
||||
crdb.NewPrimaryKey(UserMetadataColumnInstanceID, UserMetadataColumnUserID),
|
||||
crdb.NewPrimaryKey(UserMetadataColumnInstanceID, UserMetadataColumnUserID, UserMetadataColumnKey),
|
||||
crdb.WithIndex(crdb.NewIndex("ro_idx", []string{UserGrantResourceOwner})),
|
||||
),
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "UPSERT INTO projections.user_metadata (user_id, resource_owner, instance_id, creation_date, change_date, sequence, key, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedStmt: "UPSERT INTO projections.user_metadata2 (user_id, resource_owner, instance_id, creation_date, change_date, sequence, key, value) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"ro-id",
|
||||
@ -77,7 +77,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata WHERE (user_id = $1) AND (key = $2)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1) AND (key = $2)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"key",
|
||||
@ -105,7 +105,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
@ -132,7 +132,7 @@ func TestUserMetadataProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.user_metadata WHERE (user_id = $1)",
|
||||
expectedStmt: "DELETE FROM projections.user_metadata2 WHERE (user_id = $1)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
},
|
||||
|
@ -12,13 +12,13 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
userMetadataQuery = `SELECT projections.user_metadata.creation_date,` +
|
||||
` projections.user_metadata.change_date,` +
|
||||
` projections.user_metadata.resource_owner,` +
|
||||
` projections.user_metadata.sequence,` +
|
||||
` projections.user_metadata.key,` +
|
||||
` projections.user_metadata.value` +
|
||||
` FROM projections.user_metadata`
|
||||
userMetadataQuery = `SELECT projections.user_metadata2.creation_date,` +
|
||||
` projections.user_metadata2.change_date,` +
|
||||
` projections.user_metadata2.resource_owner,` +
|
||||
` projections.user_metadata2.sequence,` +
|
||||
` projections.user_metadata2.key,` +
|
||||
` projections.user_metadata2.value` +
|
||||
` FROM projections.user_metadata2`
|
||||
userMetadataCols = []string{
|
||||
"creation_date",
|
||||
"change_date",
|
||||
@ -27,14 +27,14 @@ var (
|
||||
"key",
|
||||
"value",
|
||||
}
|
||||
userMetadataListQuery = `SELECT projections.user_metadata.creation_date,` +
|
||||
` projections.user_metadata.change_date,` +
|
||||
` projections.user_metadata.resource_owner,` +
|
||||
` projections.user_metadata.sequence,` +
|
||||
` projections.user_metadata.key,` +
|
||||
` projections.user_metadata.value,` +
|
||||
userMetadataListQuery = `SELECT projections.user_metadata2.creation_date,` +
|
||||
` projections.user_metadata2.change_date,` +
|
||||
` projections.user_metadata2.resource_owner,` +
|
||||
` projections.user_metadata2.sequence,` +
|
||||
` projections.user_metadata2.key,` +
|
||||
` projections.user_metadata2.value,` +
|
||||
` COUNT(*) OVER ()` +
|
||||
` FROM projections.user_metadata`
|
||||
` FROM projections.user_metadata2`
|
||||
userMetadataListCols = []string{
|
||||
"creation_date",
|
||||
"change_date",
|
||||
|
Loading…
Reference in New Issue
Block a user