When executing a query against a column mapped as a date field works fine and the date is formatted like the format in castDates method defined in the model. But if the query uses a alias for the column, the cast doesn’t work.
return ModelName.query().select('id', 'datefield').fetch()
works fine with the date format desired
return ModelName.query().select('id', 'datefield as date').fetch()
the date is returned without the cast
For simplicity I minimize the code but the real situation is that I have two columns with same and that’s why I need a cast to be made.
Maybe it’s somehow related to my other issue posted here? https://forum.adonisjs.com/t/same-date-with-more-than-one-format