Files
zitadel/backend/v3/domain/projectstate_enumer.go
T
Tim MöhlmannandGitHub a45908b364 feat(rt): project repository (#10789)
# Which Problems Are Solved

Add projects to the relational tables

# How the Problems Are Solved

- Define table migrations
- Define and implement Project and Project Role repositories.
- Provide projection handlers to populate the relational tables.

# Additional Changes

- Statement Builder now has a constructor which allows setting of a base
query with arguments.
- Certain operations, like Get, Update and Delete require the Primary
Key to be set as conditions. However, this requires knowledge of the
implementation and table definition. This PR proposes an additional
condition for repositories: `PrimaryKeyCondition`. This gives clarity on
the required IDs for these operations.
- Added couple of helpers to the repository package, to allow more DRY
code.
- getOne / getMany: generic functions for query execution and scanning.
- checkRestrictingColumns, checkPkCondition: simplify condition
checking, instead of using ladders of conditionals.
- Added a couple of helpers to the repository test package:
  - Transaction, savepoint and rollback helpers.
- Create instance and organization helpers for objects that depend on
them (like projects).

# Additional Context

- after https://github.com/zitadel/zitadel/pull/10809
- closes #10765
2025-10-01 09:47:04 +00:00

110 lines
2.7 KiB
Go

// Code generated by "enumer -type ProjectState -transform lower -trimprefix ProjectState -sql"; DO NOT EDIT.
package domain
import (
"database/sql/driver"
"fmt"
"strings"
)
const _ProjectStateName = "activeinactive"
var _ProjectStateIndex = [...]uint8{0, 6, 14}
const _ProjectStateLowerName = "activeinactive"
func (i ProjectState) String() string {
if i >= ProjectState(len(_ProjectStateIndex)-1) {
return fmt.Sprintf("ProjectState(%d)", i)
}
return _ProjectStateName[_ProjectStateIndex[i]:_ProjectStateIndex[i+1]]
}
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _ProjectStateNoOp() {
var x [1]struct{}
_ = x[ProjectStateActive-(0)]
_ = x[ProjectStateInactive-(1)]
}
var _ProjectStateValues = []ProjectState{ProjectStateActive, ProjectStateInactive}
var _ProjectStateNameToValueMap = map[string]ProjectState{
_ProjectStateName[0:6]: ProjectStateActive,
_ProjectStateLowerName[0:6]: ProjectStateActive,
_ProjectStateName[6:14]: ProjectStateInactive,
_ProjectStateLowerName[6:14]: ProjectStateInactive,
}
var _ProjectStateNames = []string{
_ProjectStateName[0:6],
_ProjectStateName[6:14],
}
// ProjectStateString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ProjectStateString(s string) (ProjectState, error) {
if val, ok := _ProjectStateNameToValueMap[s]; ok {
return val, nil
}
if val, ok := _ProjectStateNameToValueMap[strings.ToLower(s)]; ok {
return val, nil
}
return 0, fmt.Errorf("%s does not belong to ProjectState values", s)
}
// ProjectStateValues returns all values of the enum
func ProjectStateValues() []ProjectState {
return _ProjectStateValues
}
// ProjectStateStrings returns a slice of all String values of the enum
func ProjectStateStrings() []string {
strs := make([]string, len(_ProjectStateNames))
copy(strs, _ProjectStateNames)
return strs
}
// IsAProjectState returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ProjectState) IsAProjectState() bool {
for _, v := range _ProjectStateValues {
if i == v {
return true
}
}
return false
}
func (i ProjectState) Value() (driver.Value, error) {
return i.String(), nil
}
func (i *ProjectState) Scan(value interface{}) error {
if value == nil {
return nil
}
var str string
switch v := value.(type) {
case []byte:
str = string(v)
case string:
str = v
case fmt.Stringer:
str = v.String()
default:
return fmt.Errorf("invalid value of ProjectState: %[1]T(%[1]v)", value)
}
val, err := ProjectStateString(str)
if err != nil {
return err
}
*i = val
return nil
}