View Issue Details

IDProjectCategoryView StatusLast Update
0006102SOGoBackend Address Bookpublic2025-03-25 15:51
Reporterzhb Assigned Toqhivert  
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionopen 
Product Version5.11.2 
Summary0006102: How can i map a DATE type SQL column to birthday?
Description

Dear developers,

I create VIEW for sogo user authentication and address book, there's a DATE type SQL column birthday, how can i map it to the VIEW so that SOGo can display the birthday on contact card?

For example, the SQL table:

CREATE TABLE IF NOT EXISTS mailbox (
    birthday DATE NOT NULL DEFAULT '0001-01-01',
    -- Omit other columns here
);

Create VIEW for SOGo:

CREATE OR REPLACE VIEW users (
    birthday,
    -- Omit other columns here
    )
    AS SELECT
              birthday,
              -- Omit other columns here
         FROM vmail.mailbox
        WHERE ...;

In debug mode, SOGo reports error like this:

2025-03-22 11:23:15.653 sogod[4079:4079] ERROR(-[MySQL4Channel primaryFetchAttributes:withZone:]): <MySQL4Channel[0x0xaaaada60cd40] connection=0x0xaaaada4a1cb0>: got no value for column: attribute=birthday
valueClass=NSCalendarDate
type=DATE

If i create the VIEW with DATE_FORMAT(birthday, '%Y-%m-%d'), no error reported by SOGo, but it doesn't display the birthday too:

CREATE OR REPLACE VIEW users (
    birthday,
    -- Omit other columns here
    )
    AS SELECT
              DATE_FORMAT(birthday, '%Y-%m-%d'),
              -- Omit other columns here
         FROM vmail.mailbox
        WHERE ...;

So, how can i correctly map a DATE type column to birthday in SOGo?

TagsNo tags attached.

Activities

zhb

zhb

2025-03-22 15:31

reporter   ~0018138

By the way, i inserted correct birthday for testing, for example, '2025-03-22'.

zhb

zhb

2025-03-22 15:33

reporter   ~0018139

Sorry i missed one log line, the full log with DATE type column is:

2025-03-22 11:23:14.657 sogod[4076:4076] WARNING(-[NSCalendarDate(MySQL4Values) initWithMySQL4Field:value:length:]): got no value for string '1999-02-03' format '%y%m%d%H%M'.
2025-03-22 11:23:14.657 sogod[4076:4076] ERROR(-[MySQL4Channel primaryFetchAttributes:withZone:]): <MySQL4Channel[0x0xaaaada4c6520] connection=0x0xaaaada44a060>: got no value for column: attribute=birthday
valueClass=NSCalendarDate
type=DATE

zhb

zhb

2025-03-22 15:42

reporter   ~0018140

Also, it doesn't display first name and last name too.

SQL table:

CREATE TABLE IF NOT EXISTS mailbox (
    first_name VARCHAR(255) NOT NULL DEFAULT '',
    last_name VARCHAR(255) NOT NULL DEFAULT '',
    birthday DATE NOT NULL DEFAULT '0001-01-01',
    -- Omit other columns here
);

Create VIEW for SOGo:

CREATE OR REPLACE VIEW users (
givenname,
sn,
birthday,
-- Omit other columns here
)
AS SELECT
first_name,
last_name,
birthday,
-- Omit other columns here
FROM vmail.mailbox
WHERE ...;

qhivert

qhivert

2025-03-25 13:02

administrator   ~0018152

Hello, its seems that with a sql usersource you will need three int columns:

  • birthyear
  • birthmonth
  • birthday
zhb

zhb

2025-03-25 15:51

reporter   ~0018153

Hi @qhivert,

Thanks for helping. You're correct.

For MariaDB, i have to create view with sql command like below:

CREATE OR REPLACE VIEW users (
    ...,
    birthyear,
    birthmonth,
    birthday
    )
    AS SELECT 
              ...,
              DATE_FORMAT(birthday, &quot;%Y&quot;),
              DATE_FORMAT(birthday, &quot;%m&quot;),
              DATE_FORMAT(birthday, &quot;%d&quot;)
         FROM ...
        WHERE ...

For PostgreSQL:

CREATE OR REPLACE VIEW users AS
     SELECT
            ...,
            to_char(birthday, 'YYYY')::integer AS birthyear,
            to_char(birthday, 'MM')::integer AS birthmonth,
            to_char(birthday, 'DD')::integer AS birthday
       FROM ...
      WHERE ...

Issue History

Date Modified Username Field Change
2025-03-22 15:30 zhb New Issue
2025-03-22 15:31 zhb Note Added: 0018138
2025-03-22 15:33 zhb Note Added: 0018139
2025-03-22 15:42 zhb Note Added: 0018140
2025-03-25 13:02 qhivert Note Added: 0018152
2025-03-25 13:02 qhivert Assigned To => qhivert
2025-03-25 13:02 qhivert Status new => feedback
2025-03-25 15:51 zhb Note Added: 0018153
2025-03-25 15:51 zhb Status feedback => assigned