SQL syntax error near '`mbr_order` ASC, mbr_id DESC ASC'

Support MB Relationships SQL syntax error near '`mbr_order` ASC, mbr_id DESC ASC'Resolved

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #28156
    Stefan GrassbergerStefan Grassberger
    Participant

    Hello,
    I'm using versions:

    Meta Box 5.4.0
    Meta Box AIO 1.13.9

    and I'm trying to setup a reciprocal relationship between two terms of a custom taxonomy:

     MB_Relationships_API::register( [
            'id'         => 'rbi_neighboring_countries',
            'reciprocal' => true,
            'from'       => [
                'object_type' => 'term',
                'taxonomy'    => 'rbi_country',
                'meta_box'    => [
                    'title' => 'Neighboring countries',
                ],
            ],
            'to'         => [
                'object_type' => 'term',
                'taxonomy'    => 'rbi_country',
            ],
        ] );

    The code on the archive page:

     <?php
        $terms = get_terms(
            array(
                'taxonomy'     => 'rbi_country',
                'hide_empty'   => false,
                'relationship' => array(
                    'id' => 'rbi_neighboring_countries',
                    'to' => get_queried_object()->term_id,
                ),
            )
        );
        foreach ( $terms as $t ) {
            echo esc_html( $t->name );
        }
        ?>

    This error is displayed in the frontend:
    WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'mbr_orderASC, mbr_id DESC ASC' at line 1]
    SELECT t.*, tt.* , mbr.from AS mbr_from, mbr.to AS mbr_to, mbr.ID AS mbr_id, CASE WHEN mbr.to = t.term_id THEN mbr.order_from WHEN mbr.from = t.term_id THEN mbr.order_to END AS &lt;code&gt;mbr_order&lt;/code&gt; FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_mb_relationships AS mbr ON (mbr.type = 'rbi_neighboring_countries' AND ((mbr.from = t.term_id AND mbr.to IN (1)) OR (mbr.to = t.term_id AND mbr.from IN (1)))) WHERE tt.taxonomy IN ('rbi_country') &lt;code&gt;mbr_order&lt;/code&gt; ASC, mbr_id DESC ASC

    Seems to me like DESC ASC is the issue?

    #28177
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Thank you for your feedback.

    I'm going to check this issue and get back to you later.

    #28182
    Stefan GrassbergerStefan Grassberger
    Participant

    Thanks!

    #28389
    Stefan GrassbergerStefan Grassberger
    Participant

    Hi Long,
    were you able to reproduce the issue?

    #28399
    Long NguyenLong Nguyen
    Moderator

    Hi Stefan,

    It was an issue of reciprocal option when using the term object. I've escalated it to the development team to fix it in the next update.

    #28408
    Stefan GrassbergerStefan Grassberger
    Participant

    Great news, thank you so much!

    #29154
    Long NguyenLong Nguyen
    Moderator

    Hi,

    This issue has been fixed on this commit. Can you please check it and let me know if it works?

    #29219
    Stefan GrassbergerStefan Grassberger
    Participant

    I tested with the plugin at the commit and I can confirm it fixes the issue!

    Thank you, looking forward to the next release 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.