ehmpathy / sql-dao-generator

Generate data-access-objects from your domain-objects
MIT License
0 stars 0 forks source link

support higher granularity of sql schema datatypes specified #1

Open uladkasach opened 3 years ago

uladkasach commented 3 years ago

for specifying the types of the generated entities / tables more granularly, we'll need to add supplemental info:

note: none of the above are critical for mvp, since:

however, we need to have an idea of how we could handle this long term

options:


this will not be done for MVP, but is something to keep in mind for the future.

goals are:

uladkasach commented 3 years ago

note: we will not be supporting this soon, since it is an extreme optimization:

select pg_column_size('80.1234'::numeric(7, 5)); -- 10 select pg_column_size('80.1234'::numeric); -- 10


- int vs numeric has huge size difference
    - but this will only be really helpful for _large_ tables
```sql
select pg_column_size('821'::numeric); -- 8
select pg_column_size('821'::int); -- 4

select pg_column_size('821721'::numeric); -- 10
select pg_column_size('821721'::int); -- 4

so from the above, it looks like the only cases we'd really need to change the type to optimize storage size is if its an integer.... that can be derived pretty easily from schema (i.e., Joi.number().integer().min().max() -> where .min().max() tell us whether its a bigint, medint, smallint, etc)

folks can manually make the changes in these cases in the meantime, since this is such an easy optimization to do manually and would be a lot of lift automatically (i.e., domain-objects-metadata would have to be able to introspect Joi/Yup schemas to figure this out)