Okay
  Public Ticket #2876503
Updating SQL Query to add a column errors out
Closed

Comments

  • Bradley Thornhill started the conversation

    I have a query, then I tried to add in a new column to that query and it errored out. I have the query below. I am pulling data from Views I have created in the DB.

    I was trying to add:

    AVG(NULLIF(t1.traineeColumnNameRating, 0)),

    AVG(NULLIF(t2.doctorColumnNameRating, 0)),


    SELECT
        t1.traineeName, 
        t1.procedureDate, 
        t1.surgeryID,
        AVG(NULLIF(t1.traineeRemovesFatAdrenalRating, 0)),
        AVG(NULLIF(t1.traineeSkeletonizesRenalVeinRating, 0)),
        AVG(NULLIF(t1.traineeSkeletonizesArteryRating, 0)),
        AVG(NULLIF(t1.traineeDonorArteriesRating, 0)),
        AVG(NULLIF(t1.traineeRenalVeinAugmentationRating, 0)),
        AVG(NULLIF(t1.traineeOverallPerformanceRating, 0)),
        AVG(NULLIF(t2.doctorRemovesFatAdrenalRating, 0)),
        AVG(NULLIF(t2.doctorSkeletonizesRenalVeinRating, 0)),
        AVG(NULLIF(t2.doctorSkeletonizesArteryRating, 0)),
        AVG(NULLIF(t2.doctorDonorArteriesRating, 0)),
        AVG(NULLIF(t2.doctorRenalVeinAugmentationRating, 0)),
        AVG(NULLIF(t2.doctorOverallPerformanceRating, 0))
    FROM
        BackbenchKidneyChartTrainee t1
    JOIN
        BackbenchKidneyChartDoctor t2 
    ON
         t1.traineeName = t2.traineeName
    WHERE
        t1.surgeryID = t2.surgeryID
    AND 
        (t1.traineeName = "Trainee" AND t2.traineeName = "Trainee")
    ORDER BY t1.procedureDate ASC


    Here is the error code sent to me:


    When seeking help with this issue, you may be asked for some of the following information:
    WordPress version 5.8.1
    Current theme: Pro – Child Theme (version 1.0.0)
    Current plugin: wpDataTables (version 3.6)
    PHP version 7.4.9



    Error Details
    =============
    An error of type E_ERROR was caused in line 3465 of the file /var/www/html/wp-content/plugins/wpdatatables/source/class.wpdatatable.php. Error message: Uncaught Error: Call to a member function setFilterType() on bool in /var/www/html/wp-content/plugins/wpdatatables/source/class.wpdatatable.php:3465
    Stack trace:
    #0 /var/www/html/wp-content/plugins/wpdatatables/source/class.wpdatatable.php(3442): WPDataTable->prepareRenderingRules()
    #1 /var/www/html/wp-content/plugins/wpdatatables/source/class.wpdatatable.php(4234): WPDataTable->fillFromData()
    #2 /var/www/html/wp-content/plugins/wpdatatables/source/class.wdtconfigcontroller.php(106): WPDataTable::loadWpDataTable()
    #3 /var/www/html/wp-content/plugins/wpdatatables/controllers/wdt_admin.php(569): WDTConfigController::loadTableConfig()
    #4 /var/www/html/wp-content/plugins/wpdatatables/controllers/wdt_admin.php(639): wdtEdit()
    #5 /var/www/html/wp-includes/class-wp-hook.php(303): wdtConstructor()
    #6 /var/www/html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
    #7 /var/www/html/wp-includes/plugin.php(470): WP_Hook->do_action()
    #8 /var/www/html/wp-admin/admin.php(259): do_action()
    #9 {main}
    thrown

  • [deleted] replied

    Hi Bradley

    Thank you for reaching out to us.

    If your MySQL-query based wpDataTable doesn’t work correctly with server-side processing, probably this is happening because wpDataTables server has problems with parsing of the query and building new queries dynamically (rarely happens, but does sometimes). To avoid this please prepare a MySQL view (a stored query), which will return the data that you need, call it e.g. “view1” and then build a wpDataTabled based on a simple query like “SELECT * FROM view1″.

    Please note some this when working with the server-side processing feature:

    • Please do not use “LIMIT” in the SELECT statement. wpDataTables adds it automatically and it will be overridden.
    • Please do not use “ORDER BY” in the SELECT statement. wpDataTables has its own sorting engine so it makes no sense to use MySQL’s sorting, since it will be overridden. Also, server-side processing feature adds this part of statement automatically when users trigger the sorting on the front-end, and having it in initial statement may cause the table to crash.