Documentation
¶
Overview ¶
Package sql provides utilities for building SQL expressions from conditional expressions. This package is designed to work with the goqu library to construct SQL queries dynamically.
Supported Features: - Logical Operators:
- AND: Combines multiple conditions with a logical AND.
- OR: Combines multiple conditions with a logical OR.
- Comparison Operators:
- = : Equal to
- !=: Not equal to
- > : Greater than
- < : Less than
- >=: Greater than or equal to
- <=: Less than or equal to
- IN: Checks if a value exists within a list of values
- IS NULL: Checks if a field is null (no value required)
- IS NOT NULL: Checks if a field is not null (no value required)
Limitations: - Only supports fields that are valid SQL identifiers:
- Must contain only alphanumeric characters, `$`, and `_`.
- Must be between 1 and 128 characters in length.
- Does not support advanced SQL features such as:
- LIKE or ILIKE for pattern matching.
- NOT IN or other negated set operations.
- Complex expressions involving functions or subqueries.
- Requires all conditions to have a non-empty field and operator. For most operators, a value is also required, except for IS NULL and IS NOT NULL.
Index ¶
- type ConditionBuilder
- func (cb ConditionBuilder) Build(cond condexpr.Condition) (goqu.Expression, error)
- func (cb ConditionBuilder) BuildCompositeAnd(cond condexpr.Condition) (goqu.Expression, error)
- func (cb ConditionBuilder) BuildCompositeOr(cond condexpr.Condition) (goqu.Expression, error)
- func (cb ConditionBuilder) BuildLeafCondition(cond condexpr.Condition) (goqu.Expression, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConditionBuilder ¶
type ConditionBuilder struct{}
func NewConditionBuilder ¶
func NewConditionBuilder() *ConditionBuilder
func (ConditionBuilder) Build ¶
func (cb ConditionBuilder) Build(cond condexpr.Condition) (goqu.Expression, error)
func (ConditionBuilder) BuildCompositeAnd ¶
func (cb ConditionBuilder) BuildCompositeAnd(cond condexpr.Condition) (goqu.Expression, error)
func (ConditionBuilder) BuildCompositeOr ¶
func (cb ConditionBuilder) BuildCompositeOr(cond condexpr.Condition) (goqu.Expression, error)
func (ConditionBuilder) BuildLeafCondition ¶
func (cb ConditionBuilder) BuildLeafCondition(cond condexpr.Condition) (goqu.Expression, error)
Click to show internal directories.
Click to hide internal directories.