data type for grafted fields

18 views
Skip to first unread message

Gianluca Morlacchi

unread,
Feb 1, 2024, 12:51:54 PMFeb 1
to Xataface
Hi everyone, I'm using grafted fields within my __sql__ declaration in fields.ini file. The grafted field is handled as a varchar field but I need it to be a date field. The field declaration in mysql db is date. Is there a way to force the field type to be date? Thanks

Gianluca Morlacchi

unread,
Feb 1, 2024, 12:55:44 PMFeb 1
to Xataface
Sorry I didn't mention that I'm using the 2.2.5 version of xataface. I read the "date_format directive not working" discussion but it's not clear to me where to apply the declaration Type=DATE  

Patrick Reinhard

unread,
Feb 3, 2024, 8:44:24 AMFeb 3
to Xataface
Hi.
Did you try putting Type=date in the fields.ini of the table with the grafted field?
Like this:

fields.ini in the /tables/tableA folder:

__sql__ = "
SELECT
  A.*
, '2024-02-03' AS grafted_field
FROM
  tableA A
"

[grafted_field]
Type=date

Without Type=date the field is rendered as '2024-02-03', while with Type=date it is rendered as '02/03/24' implying that the grafted field had been converted to a date and formatted consequently.

Gianluca Morlacchi

unread,
Feb 3, 2024, 8:57:28 AMFeb 3
to Xataface
Great! You saved my day! I tried everything but the fields.ini and now it's working as expected. Thank you very much!
Reply all
Reply to author
Forward
0 new messages