mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-18 05:52:51 +00:00
## Summary This PR introduces the relational user repository for backend v3, including schema, repository APIs, reducers/projections, and tests for both human and machine users. ## What changed * Added user-focused relational migrations (users, verifications, metadata, PATs, machine keys, passkeys, identity provider links) and related FK wiring. * Implemented/expanded repository domain contracts and storage implementations for human and machine user flows. * Added support for machine secret handling and aligned access token type modeling. * Extended user domain models (verifications, password/email/phone/TOTP state, passkeys, metadata, invite handling, identity provider links). * Updated projection/reduction coverage and integration tests for key user lifecycle events. * Regenerated and updated mocks/enums plus supporting database change/column utilities. ## Notes for reviewers * This PR is large because it establishes the foundational relational user storage layer and related test scaffolding. Sorry for that. ## Closes Closes #10218 Closes #10224 Closes #10225 Closes #10209 Closes #10802 --------- Co-authored-by: Iraq Jaber <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Marco A. <[email protected]> Co-authored-by: Tim Möhlmann <[email protected]>
113 lines
2.2 KiB
Go
113 lines
2.2 KiB
Go
package database
|
|
|
|
type coalesce struct {
|
|
values []any
|
|
}
|
|
|
|
func Coalesce(values ...any) *coalesce {
|
|
return &coalesce{values: values}
|
|
}
|
|
|
|
// WriteArg implements [Change].
|
|
func (c *coalesce) WriteArg(builder *StatementBuilder) {
|
|
c.WriteQualified(builder)
|
|
}
|
|
|
|
// IsOnColumn implements [Change].
|
|
func (c coalesce) IsOnColumn(col Column) bool {
|
|
for _, value := range c.values {
|
|
if change, ok := value.(Change); ok {
|
|
if change.IsOnColumn(col) {
|
|
return true
|
|
}
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// Write implements [Change].
|
|
func (c coalesce) Write(builder *StatementBuilder) error {
|
|
builder.WriteString("COALESCE(")
|
|
for i, value := range c.values {
|
|
if i > 0 {
|
|
builder.WriteString(", ")
|
|
}
|
|
builder.WriteArg(value)
|
|
}
|
|
builder.WriteString(")")
|
|
return nil
|
|
}
|
|
|
|
// Equals implements [Column].
|
|
func (c *coalesce) Equals(col Column) bool {
|
|
if col == nil {
|
|
return c == nil
|
|
}
|
|
other, ok := col.(*coalesce)
|
|
if !ok || len(other.values) != len(c.values) {
|
|
return false
|
|
}
|
|
for i, value := range c.values {
|
|
if value != other.values[i] {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// Matches implements [Column].
|
|
func (c *coalesce) Matches(x any) bool {
|
|
toMatch, ok := x.(*coalesce)
|
|
if !ok || len(toMatch.values) != len(c.values) {
|
|
return false
|
|
}
|
|
for i, value := range c.values {
|
|
if value != toMatch.values[i] {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
|
|
// String implements [Column].
|
|
func (c *coalesce) String() string {
|
|
return "database.coalesce"
|
|
}
|
|
|
|
// WriteQualified implements [Column].
|
|
func (c *coalesce) WriteQualified(builder *StatementBuilder) {
|
|
builder.WriteString("COALESCE(")
|
|
for i, value := range c.values {
|
|
if i > 0 {
|
|
builder.WriteString(", ")
|
|
}
|
|
if col, ok := value.(Column); ok {
|
|
col.WriteQualified(builder)
|
|
continue
|
|
}
|
|
builder.WriteArg(value)
|
|
}
|
|
builder.WriteString(")")
|
|
}
|
|
|
|
// WriteUnqualified implements [Column].
|
|
func (c *coalesce) WriteUnqualified(builder *StatementBuilder) {
|
|
builder.WriteString("COALESCE(")
|
|
for i, value := range c.values {
|
|
if i > 0 {
|
|
builder.WriteString(", ")
|
|
}
|
|
if col, ok := value.(Column); ok {
|
|
col.WriteUnqualified(builder)
|
|
continue
|
|
}
|
|
builder.WriteArg(value)
|
|
}
|
|
builder.WriteString(")")
|
|
}
|
|
|
|
var (
|
|
_ Column = (*coalesce)(nil)
|
|
_ Change = (*coalesce)(nil)
|
|
)
|