|
|
|
@@ -23,7 +23,7 @@ func WithTableSuffix(name string) func(*execConfig) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCreateStatement(event eventstore.EventReader, values []handler.Column, opts ...execOption) *handler.Statement {
|
|
|
|
|
func NewCreateStatement(event eventstore.Event, values []handler.Column, opts ...execOption) *handler.Statement {
|
|
|
|
|
cols, params, args := columnsToQuery(values)
|
|
|
|
|
columnNames := strings.Join(cols, ", ")
|
|
|
|
|
valuesPlaceholder := strings.Join(params, ", ")
|
|
|
|
@@ -48,7 +48,7 @@ func NewCreateStatement(event eventstore.EventReader, values []handler.Column, o
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewUpsertStatement(event eventstore.EventReader, values []handler.Column, opts ...execOption) *handler.Statement {
|
|
|
|
|
func NewUpsertStatement(event eventstore.Event, values []handler.Column, opts ...execOption) *handler.Statement {
|
|
|
|
|
cols, params, args := columnsToQuery(values)
|
|
|
|
|
columnNames := strings.Join(cols, ", ")
|
|
|
|
|
valuesPlaceholder := strings.Join(params, ", ")
|
|
|
|
@@ -73,7 +73,7 @@ func NewUpsertStatement(event eventstore.EventReader, values []handler.Column, o
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewUpdateStatement(event eventstore.EventReader, values []handler.Column, conditions []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
func NewUpdateStatement(event eventstore.Event, values []handler.Column, conditions []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
cols, params, args := columnsToQuery(values)
|
|
|
|
|
wheres, whereArgs := conditionsToWhere(conditions, len(params))
|
|
|
|
|
args = append(args, whereArgs...)
|
|
|
|
@@ -106,7 +106,7 @@ func NewUpdateStatement(event eventstore.EventReader, values []handler.Column, c
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewDeleteStatement(event eventstore.EventReader, conditions []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
func NewDeleteStatement(event eventstore.Event, conditions []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
wheres, args := conditionsToWhere(conditions, 0)
|
|
|
|
|
|
|
|
|
|
wheresPlaceholders := strings.Join(wheres, " AND ")
|
|
|
|
@@ -131,7 +131,7 @@ func NewDeleteStatement(event eventstore.EventReader, conditions []handler.Condi
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewNoOpStatement(event eventstore.EventReader) *handler.Statement {
|
|
|
|
|
func NewNoOpStatement(event eventstore.Event) *handler.Statement {
|
|
|
|
|
return &handler.Statement{
|
|
|
|
|
AggregateType: event.Aggregate().Type,
|
|
|
|
|
Sequence: event.Sequence(),
|
|
|
|
@@ -139,7 +139,7 @@ func NewNoOpStatement(event eventstore.EventReader) *handler.Statement {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewMultiStatement(event eventstore.EventReader, opts ...func(eventstore.EventReader) Exec) *handler.Statement {
|
|
|
|
|
func NewMultiStatement(event eventstore.Event, opts ...func(eventstore.Event) Exec) *handler.Statement {
|
|
|
|
|
if len(opts) == 0 {
|
|
|
|
|
return NewNoOpStatement(event)
|
|
|
|
|
}
|
|
|
|
@@ -157,26 +157,26 @@ func NewMultiStatement(event eventstore.EventReader, opts ...func(eventstore.Eve
|
|
|
|
|
|
|
|
|
|
type Exec func(ex handler.Executer, projectionName string) error
|
|
|
|
|
|
|
|
|
|
func AddCreateStatement(columns []handler.Column, opts ...execOption) func(eventstore.EventReader) Exec {
|
|
|
|
|
return func(event eventstore.EventReader) Exec {
|
|
|
|
|
func AddCreateStatement(columns []handler.Column, opts ...execOption) func(eventstore.Event) Exec {
|
|
|
|
|
return func(event eventstore.Event) Exec {
|
|
|
|
|
return NewCreateStatement(event, columns, opts...).Execute
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func AddUpsertStatement(values []handler.Column, opts ...execOption) func(eventstore.EventReader) Exec {
|
|
|
|
|
return func(event eventstore.EventReader) Exec {
|
|
|
|
|
func AddUpsertStatement(values []handler.Column, opts ...execOption) func(eventstore.Event) Exec {
|
|
|
|
|
return func(event eventstore.Event) Exec {
|
|
|
|
|
return NewUpsertStatement(event, values, opts...).Execute
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func AddUpdateStatement(values []handler.Column, conditions []handler.Condition, opts ...execOption) func(eventstore.EventReader) Exec {
|
|
|
|
|
return func(event eventstore.EventReader) Exec {
|
|
|
|
|
func AddUpdateStatement(values []handler.Column, conditions []handler.Condition, opts ...execOption) func(eventstore.Event) Exec {
|
|
|
|
|
return func(event eventstore.Event) Exec {
|
|
|
|
|
return NewUpdateStatement(event, values, conditions, opts...).Execute
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func AddDeleteStatement(conditions []handler.Condition, opts ...execOption) func(eventstore.EventReader) Exec {
|
|
|
|
|
return func(event eventstore.EventReader) Exec {
|
|
|
|
|
func AddDeleteStatement(conditions []handler.Condition, opts ...execOption) func(eventstore.Event) Exec {
|
|
|
|
|
return func(event eventstore.Event) Exec {
|
|
|
|
|
return NewDeleteStatement(event, conditions, opts...).Execute
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -206,7 +206,7 @@ func NewArrayRemoveCol(column string, value interface{}) handler.Column {
|
|
|
|
|
// if the value of a col is empty the data will be copied from the selected row
|
|
|
|
|
// if the value of a col is not empty the data will be set by the static value
|
|
|
|
|
// conds represent the conditions for the selection subquery
|
|
|
|
|
func NewCopyStatement(event eventstore.EventReader, cols []handler.Column, conds []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
func NewCopyStatement(event eventstore.Event, cols []handler.Column, conds []handler.Condition, opts ...execOption) *handler.Statement {
|
|
|
|
|
columnNames := make([]string, len(cols))
|
|
|
|
|
selectColumns := make([]string, len(cols))
|
|
|
|
|
argCounter := 0
|
|
|
|
|