SearchConfig
This class represents a configuration for full-text search, specifically used to cast an expression to the PostgreSQL regconfig type. It provides methods to initialize the configuration from a value or parameter and integrates with the SQL compilation process to ensure the correct database type casting. The class manages its underlying configuration as a source expression within the database abstraction layer.
Attributes
| Attribute | Type | Description |
|---|---|---|
| config | [Expression](../../../db/models/expressions/expression.md?sid=django_db_models_expressions_expression) | The configuration value or expression used to specify the text search configuration for PostgreSQL full-text search. |
Constructor
Signature
def SearchConfig(
config: Any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| config | Any | The configuration value or expression to be used for the search configuration. |
Signature
def SearchConfig(
config: string|Expression
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| config | `string | Expression` |
Methods
from_parameter()
@classmethod
def from_parameter(
config: any
) - > SearchConfig|null
Creates a SearchConfig instance from a parameter if it is not already one or null.
Parameters
| Name | Type | Description |
|---|---|---|
| config | any | The input parameter to be converted into a SearchConfig instance. |
Returns
| Type | Description |
|---|---|
| `SearchConfig | null` |
get_source_expressions()
@classmethod
def get_source_expressions() - > list
Fetches the underlying configuration expressions associated with this instance.
Returns
| Type | Description |
|---|---|
list | A list containing the single configuration expression used by this object. |
set_source_expressions()
@classmethod
def set_source_expressions(
exprs: list
) - > null
Updates the internal configuration expression with a new set of source expressions.
Parameters
| Name | Type | Description |
|---|---|---|
| exprs | list | A list containing exactly one expression to be assigned as the new configuration. |
Returns
| Type | Description |
|---|---|
null | None |
as_sql()
@classmethod
def as_sql(
compiler: [SQLCompiler](../../../db/models/sql/compiler/sqlcompiler.md?sid=django_db_models_sql_compiler_sqlcompiler),
connection: DatabaseConnection
) - > tuple
Generates the SQL representation of the search configuration, casting the value to the PostgreSQL regconfig type.
Parameters
| Name | Type | Description |
|---|---|---|
| compiler | [SQLCompiler](../../../db/models/sql/compiler/sqlcompiler.md?sid=django_db_models_sql_compiler_sqlcompiler) | The query compiler used to transform the expression into SQL. |
| connection | DatabaseConnection | The current database connection used for vendor-specific SQL generation. |
Returns
| Type | Description |
|---|---|
tuple | A tuple containing the SQL string with the regconfig cast and the list of parameters for the query. |