sqlclojurekorma

Exclude fields from entities in Korma


I have some tables with a lot of columns where I sometimes need to just exclude 5-6 out of 50-60. Yes my tables are 3NF normalised, yes some have even more than 60 columns, if this sounds weird to you dear reader, try modelling biological entities.

To my question:

Is it possible to exclude fields by default in selects in Korma instead of specifying tens of columns in entity-fields at entity definition?


Solution

  • Use sql to get all columns and generate entity-fields:

    select column_name, data_type, character_maximum_length
    from INFORMATION_SCHEMA.COLUMNS where table_name = '<name of table>';
    

    It's better to not select unused fields than filter them later.