Documentation
¶
Index ¶
Constants ¶
const ( // PRE is a format string for matching values that start with a specific pattern. // For example, applying PRE to "bar" results in "%bar". PRE = "%%%s" // POST is a format string for matching values that end with a specific pattern. // For example, applying POST to "bar" results in "bar%". POST = "%s%%" // AROUND is a format string for matching values that contain a specific pattern. // For example, applying AROUND to "bar" results in "%bar%". AROUND = "%%%s%%" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BetweenFilter ¶
type BetweenFilter uint8
BetweenFilter represents a filter for SQL BETWEEN conditions. It constructs a condition that checks if a column's value falls within a range defined by two placeholders.
func (BetweenFilter) Apply ¶
func (BetweenFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
Apply creates an SQL BETWEEN condition string for a column using two placeholders. Parameters:
column: The name of the SQL column to filter. _: The total number of arguments (ignored). currentIndex: The index for the starting placeholder in the SQL query. placeholder: The placeholder interface for generating the placeholder strings.
Returns:
A string representing the SQL BETWEEN condition, with placeholders for the range values.
Example:
If column = "age", currentIndex = 1, and placeholder.Get(n) returns ":1" and ":2", the result would be: "(age BETWEEN :1 AND :2)"
func (BetweenFilter) EnrichValue ¶
func (BetweenFilter) EnrichValue(*any) error
EnrichValue is a no-op method for BetweenFilter, as it does not modify the value. Parameters:
value: A pointer to the value to be enriched (ignored).
Returns:
An error, which is always nil for this filter as it does not perform any modifications.
type DateAfterFilter ¶
type DateAfterFilter uint8
func (DateAfterFilter) Apply ¶
func (DateAfterFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
func (DateAfterFilter) EnrichValue ¶
func (DateAfterFilter) EnrichValue(*any) error
type DateBeforeFilter ¶
type DateBeforeFilter uint8
func (DateBeforeFilter) Apply ¶
func (DateBeforeFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
func (DateBeforeFilter) EnrichValue ¶
func (DateBeforeFilter) EnrichValue(*any) error
type DateIsFilter ¶
type DateIsFilter uint8
func (DateIsFilter) Apply ¶
func (DateIsFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
func (DateIsFilter) EnrichValue ¶
func (DateIsFilter) EnrichValue(*any) error
type DateIsNotFilter ¶
type DateIsNotFilter uint8
func (DateIsNotFilter) Apply ¶
func (DateIsNotFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
func (DateIsNotFilter) EnrichValue ¶
func (DateIsNotFilter) EnrichValue(*any) error
type InFilter ¶
type InFilter uint8
InFilter represents a filter for SQL IN conditions. It constructs a condition that checks if a column's value is within a set of values, using a variable number of placeholders.
func (InFilter) Apply ¶
func (InFilter) Apply(column string, totalArguments int, currentIndex int, placeholder placeholder.Placeholder) string
Apply creates an SQL IN condition string for a column using the provided placeholders. Parameters:
column: The name of the SQL column to filter. totalArguments: The total number of placeholders to include in the IN clause. currentIndex: The starting index for the placeholders in the SQL query. placeholder: The placeholder interface for generating the placeholder strings.
Returns:
A string representing the SQL IN condition, with placeholders for the values.
Example:
For column = "status", totalArguments = 3, currentIndex = 1, and placeholder.Get(n) returns ":1", ":2", ":3", the result would be: "(status IN (:1, :2, :3))"
func (InFilter) EnrichValue ¶
EnrichValue is a no-op method for InFilter, as it does not modify the value. Parameters:
value: A pointer to the value to be enriched (ignored).
Returns:
Always returns nil as no modification is performed.
type MutatedValueFilter ¶
type MutatedValueFilter struct {
Operation string // SQL operation to use in the condition (e.g., "=", "<>").
MutationFunc func(v *any) // Function to mutate the value before applying the filter.
}
MutatedValueFilter represents a filter that applies a SQL condition with a specific operation and also allows for mutation of the value before applying the filter. It uses an operation string (e.g., "=", "<>", ">") and a function to mutate the value.
func (*MutatedValueFilter) Apply ¶
func (m *MutatedValueFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
Apply creates an SQL condition string using the column name, the filter's operation, and the placeholder for the current index. Parameters:
column: The name of the SQL column to filter. _: The total number of arguments (ignored). currentIndex: The index of the current placeholder in the SQL query. placeholder: The placeholder interface for generating the placeholder string.
Returns:
A string representing the SQL condition, including the column, operation, and placeholder.
Example:
For column = "age", currentIndex = 1, and placeholder.Get(n) returns ":1", if the operation is ">", the result would be: "(age > :1)"
func (*MutatedValueFilter) EnrichValue ¶
func (m *MutatedValueFilter) EnrichValue(value *any) error
EnrichValue applies the mutation function to the value, modifying it before using it in a filter. Parameters:
value: A pointer to the value to be mutated. The value is modified in place.
Returns:
Always returns nil as no error is expected from the mutation function.
type PatternMatchFilter ¶
type PatternMatchFilter struct {
Operation string // SQL operation (e.g., "LIKE") used in the condition.
Format string // Format string to build the pattern for matching.
}
PatternMatchFilter represents a filter for SQL pattern matching conditions. It applies operations like `LIKE` to a column, using a format to build the pattern for matching.
func NewPatternMatchFilter ¶
func NewPatternMatchFilter(operation, format string) *PatternMatchFilter
NewPatternMatchFilter creates a new PatternMatchFilter with the specified operation and format. Parameters:
operation: The SQL operation for the condition (e.g., "LIKE"). format: The format string to build the pattern (e.g., "%%%s%%").
Returns:
A pointer to a new PatternMatchFilter instance.
func (*PatternMatchFilter) Apply ¶
func (f *PatternMatchFilter) Apply(column string, _, currentIndex int, placeholder placeholder.Placeholder) string
Apply constructs an SQL condition string using the column name, the filter's operation, and the placeholder for the current index. Parameters:
column: The name of the SQL column to filter. _: The total number of arguments (ignored). currentIndex: The index of the current placeholder in the SQL query. placeholder: The placeholder interface for generating the placeholder string.
Returns:
A string representing the SQL condition with the column, operation, and placeholder.
Example:
For column = "name", operation = "LIKE", currentIndex = 1, and placeholder.Get(n) returns ":1", the result would be: "(name LIKE :1)"
func (*PatternMatchFilter) EnrichValue ¶
func (f *PatternMatchFilter) EnrichValue(value *any) error
EnrichValue modifies the value by applying the filter's format string if the value is a string. Parameters:
v: A pointer to the value to be enriched. If the value is a string, it is formatted using the filter's Format.
Returns:
Always returns nil, as the function does not produce an error.
Behavior:
- If the value is a string, it formats the value using the filter's format string (e.g., "foo" becomes "%%%s%%" if Format = "%%%s%%").
- If the value is not a string, it remains unchanged.
type ValueFilter ¶
type ValueFilter string
ValueFilter represents a filter that applies a specific SQL condition to a column. It uses a string to define the SQL operation (e.g., "=", "<>", ">") and formats SQL conditions with placeholders for parameterized queries.
func (ValueFilter) Apply ¶
func (f ValueFilter) Apply(column string, _ int, currentIndex int, placeholder placeholder.Placeholder) string
Apply creates an SQL condition string using the column name, the filter's operation, and the placeholder for the current index. Parameters:
column: The name of the SQL column to filter. _: The total number of arguments (ignored). currentIndex: The index of the current placeholder in the SQL query. placeholder: The placeholder interface for generating the placeholder string.
Returns:
A string representing the SQL condition, including the column, operation, and placeholder.
Example:
For column = "age", currentIndex = 1, and placeholder.Get(n) returns ":1", if the filter operation is "=", the result would be: "(age = :1)"
func (ValueFilter) EnrichValue ¶
func (ValueFilter) EnrichValue(value *any) error
EnrichValue is a no-op method for ValueFilter, as it does not modify the value. Parameters:
value: A pointer to the value to be enriched (ignored).
Returns:
Always returns nil as no modification is performed.