Problem/Motivation
Postgresql 'to_char' function expects that first argument is a timestamp in order to convert the date to a string. Currently, date fields are stored as integer.
- Create a new Content view output using fields
- Add a date field such as Authored on date
- Use date/time formatting ?????
- ...Fail condition
Proposed resolution
I see to options to resolve this issue:
- keep the database field definition unchanged and use the 'to_timestamp' function on the field.
- change the database field definition to use DATE type.
The attached patch resolves the issue by using the first approach.
Comment | File | Size | Author |
---|---|---|---|
#14 | interdiff_11-14.txt | 627 bytes | ridhimaabrol24 |
#14 | 2822607-14.patch | 1.39 KB | ridhimaabrol24 |
#11 | 2822607-11.patch | 610 bytes | Hardik_Patel_12 |
Comments
Comment #2
mickaelperrin CreditAttribution: mickaelperrin as a volunteer commentedComment #9
Kristen PolPatch does not apply to 9.1.x and needs reroll.
Comment #10
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedComment #11
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedRe-rolling against 9.1.x , kindly review a patch.
Comment #12
Kristen PolComment #14
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedFixing failed test case! Please review!
Comment #15
Kristen PolThanks for the updates.
1) Patch applies cleanly.
2) Change is straightforward.
3) Tests pass.
4) Searching for TO_CHAR in core code only brings up this places covered by the patch.
5) Since this is in views, it seems like this could be tested manually via the UI so marking for testing.
Comment #16
mradcliffeI added the global2020 tag, and updated the issue summary with some steps to reproduce the issue in the user interface. I'm going off of memory here. So please double-check this and update the issue summary.
Comment #17
mradcliffeAdded the PostgreSQL tag which we sometimes use to track pgsql driver issues.
Comment #18
LendudeWe should add an automated test that fails on PostgreSQL
Comment #19
mindbet CreditAttribution: mindbet as a volunteer commentedI think this could actually be closed, without patching.
Either as 'cannot reproduce' or 'outdated'
I installed, on my local, Drupal 9.1.0-dev using PHP 7.3.20 and PostgresSQL 10.12
I did not implement any of the patches above.
I was able to add Timestamp and Date fields to a content type.
I created several nodes, and could enter values in both of these fields.
Then I created a simple view, and found that I could display these values, sort on these values, and change the date format of these values.
I also used the 'Authored on' field as part of the view, and could change the date format and sort on that value.
Comment #20
Kristen PolThanks @mindbet! Based on your testing in #19, closing this as cannot reproduce. The manual testing you did seems to cover the issue summary notes and more.