Wrong field alias in query conditions for bookable_calendar smart date fields

Created on 24 March 2023, over 1 year ago
Updated 5 May 2023, about 1 year ago

Problem/Motivation

\Drupal\calendar_view\Plugin\views\style\CalendarViewBase::query adds the conditions for the date fields but the field alias is wrong for smart dates.

Proposed resolution

Not sure how to determine the correct field value. I'm just going to provide a quick fix for smart dates, but that should be made dynamic somehow.

πŸ› Bug report
Status

Closed: won't fix

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jurgenhaas
  • @jurgenhaas opened merge request.
  • Status changed to Needs work over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen
  • Status changed to Postponed: needs info over 1 year ago
  • I can't reproduce this issue.

    I have tested with a regular smart date field and with a recurring smart date field on a new node type.

    The alias is returned correctly for both (e.g. $alias = "node__field_smart_date.field_smart_date_value" or $alias = "node__field_recurring_date.field_recurring_date_value").

    Could you please give me more details about your configuration?

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I'm using bookable_calendar with the attached view and without adding __value to the field name, I'm getting this error:

    SQLSTATE[42S22]: Column not found: 1054 Unknown column 'bookable_calendar_opening_inst.date' in 'where clause'

    The SQL statement looks like this:

    SELECT "bookable_calendar_opening_inst"."id"                                      AS "id",
           "bookable_calendar_opening_field_data_bookable_calendar_opening_inst"."id" AS "bookable_calendar_opening_field_data_bookable_calendar_openi",
           "bookable_calendar_field_data_bookable_calendar_opening_field_data"."id"   AS "bookable_calendar_field_data_bookable_calendar_opening_field"
    FROM "bookable_calendar_opening_inst" "bookable_calendar_opening_inst"
             INNER JOIN "bookable_calendar_opening_field_data" "bookable_calendar_opening_field_data_bookable_calendar_opening_inst"
                        ON bookable_calendar_opening_inst.booking_opening =
                           bookable_calendar_opening_field_data_bookable_calendar_opening_inst.id
             INNER JOIN "bookable_calendar_field_data" "bookable_calendar_field_data_bookable_calendar_opening_field_data"
                        ON bookable_calendar_opening_field_data_bookable_calendar_opening_inst.bookable_calendar =
                           bookable_calendar_field_data_bookable_calendar_opening_field_data.id
    WHERE (((bookable_calendar_field_data_bookable_calendar_opening_field_data.id = :bookable_calendar_field_data_id)) AND
           (("bookable_calendar_opening_inst"."date" > :db_condition_placeholder_0) AND
            ("bookable_calendar_opening_inst"."date" < :db_condition_placeholder_1)))
      AND ((bookable_calendar_opening_inst.date__value > 1679612400));
    Array
    ( [:bookable_calendar_field_data_id] => 1 [:db_condition_placeholder_0] => 1677106799 [:db_condition_placeholder_1] => 1680818400 )
    
  • Status changed to Needs review over 1 year ago
  • Just pushed a one-liner on 2.0.x which I hope would fix the situtation.

    @jurgenhaas could you try and let me know? 🀷

  • Status changed to Needs work over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Unfortunately, this one doesn't make any difference. Looks like realField also only returns date instead of date__value

  • Status changed to Needs review over 1 year ago
  • Latest commit (above) should fix the situation on a bookable_calendar view for opening instances.

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    The quick fix does work, thanks @matthieuscarset - let's hope we get the real fix in place when we found out how to fix πŸ› Broken Views Field for Date field on Opening Inst Fixed .

    I'm really thankful that both of you @matthieuscarset and @josh.fabean are caring that much about all this!

  • Status changed to Closed: won't fix about 1 year ago
  • Closing issue and won't fix because we don't alter query any more from the Calendar plugin.

    Thank you very much for your help on this issue anyway @fabean @jurgenhaas.

    It has been very insightful for me to dig into the View query.

Production build 0.69.0 2024