Ecto schema text and string difference

I have several different Ecto schema modules and in them are fields mapped both to text and string fields in the db. In the Ecto schema, both string and text fields are mapped to a string. I’m wondering how/if I could infer what fields in an Ecto schema are mapped to a db text field vs string?

Hi @BillBryson!

Ecto doesn’t do this inference for you. If you want to make them distinct, you can define a custom Ecto type (see the Ecto.Type module). If you want to lift this information from the database, you will need to consult your database documentation and see how to perform reflection queries to get metadata from tables.

Is there a particular problem you are facing that you believe this could be a solution for?

Thank you for your reply!

Basically my problem is I am dynamically looking at different schema/tables and need to display different outputs for text vs string columns. It looks like querying the DB may be the best solution for my problem, was just curious if there was another way that I was missing. Thanks again for your help :slight_smile: