
    +h                         d dl mZ d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dlm
Z
  G d	 d
e
ej                        Zy)   )exc)util)	coercions)elements)	operators)roles)_generative)
Generativec                   Z     e Zd ZdZdZdZ fdZed        Zed        Z	ed        Z
 xZS )matcha[  Produce a ``MATCH (X, Y) AGAINST ('TEXT')`` clause.

    E.g.::

        from sqlalchemy import desc
        from sqlalchemy.dialects.mysql import match

        match_expr = match(
            users_table.c.firstname,
            users_table.c.lastname,
            against="Firstname Lastname",
        )

        stmt = (
            select(users_table)
            .where(match_expr.in_boolean_mode())
            .order_by(desc(match_expr))
        )

    Would produce SQL resembling::

        SELECT id, firstname, lastname
        FROM user
        WHERE MATCH(firstname, lastname) AGAINST (:param_1 IN BOOLEAN MODE)
        ORDER BY MATCH(firstname, lastname) AGAINST (:param_2) DESC

    The :func:`_mysql.match` function is a standalone version of the
    :meth:`_sql.ColumnElement.match` method available on all
    SQL expressions, as when :meth:`_expression.ColumnElement.match` is
    used, but allows to pass multiple columns

    :param cols: column expressions to match against

    :param against: expression to be compared towards

    :param in_boolean_mode: boolean, set "boolean mode" to true

    :param in_natural_language_mode: boolean , set "natural language" to true

    :param with_query_expansion: boolean, set "query expansion" to true

    .. versionadded:: 1.4.19

    .. seealso::

        :meth:`_expression.ColumnElement.match`

    mysql_matchTc                 h   |st        j                  d      |j                  dd       }|t        j                  d      t        j                  t
        j                  |      }t        j                  j                  t        j                  |      }d|_        t        j                  |j                  dd      |j                  dd      |j                  dd      d	      }|r't        j                  d
dj                  |      z        t         t"        | K  ||t        j&                  |       y )Nzcolumns are requiredagainstzagainst is required)clausesFin_boolean_modein_natural_language_modewith_query_expansion)mysql_boolean_modemysql_natural_languagemysql_query_expansionzunknown arguments: %sz, )	modifiers)r   ArgumentErrorpopr   expectr   ExpressionElementRoler   BooleanClauseList_construct_rawr   comma_opgroupr   immutabledictjoinsuperr   __init__match_op)selfcolskwr   leftflags	__class__s         W/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/dialects/mysql/expression.pyr#   zmatch.__init__A   s   ##$:;;&&D)?##$9::""''

 ))88 9 
 
""&(ff->&F*,&&.+ *,0F)N
 ##$;tyy}$MNNeT#'9-- 	$ 	
    c                 H    | j                   j                  ddi      | _         y)zApply the "IN BOOLEAN MODE" modifier to the MATCH expression.

        :return: a new :class:`_mysql.match` instance with modifications
         applied.
        r   TNr   unionr%   s    r+   r   zmatch.in_boolean_modee   s      --/CT.JKr,   c                 H    | j                   j                  ddi      | _         y)zApply the "IN NATURAL LANGUAGE MODE" modifier to the MATCH
        expression.

        :return: a new :class:`_mysql.match` instance with modifications
         applied.
        r   TNr.   r0   s    r+   r   zmatch.in_natural_language_modeo   s      --/G.NOr,   c                 H    | j                   j                  ddi      | _         y)zApply the "WITH QUERY EXPANSION" modifier to the MATCH expression.

        :return: a new :class:`_mysql.match` instance with modifications
         applied.
        r   TNr.   r0   s    r+   r   zmatch.with_query_expansionz   s      --/F.MNr,   )__name__
__module____qualname____doc____visit_name__inherit_cacher#   r	   r   r   r   __classcell__)r*   s   @r+   r   r      s]    /b #NM"
H L L P P O Or,   r   N) r   r   sqlr   r   r   r   sql.baser	   r
   BinaryExpressionr    r,   r+   <module>r?      s5          # "wOJ11 wOr,   