Hacker News new | past | comments | ask | show | jobs | submit login

  > This doesn't seem like an insoluble problem; rather than use an ORM to generate an impenetrable glue layer, it would be better to use code generation tools to create a clean database model and a glue layer that can be easily overloaded as required.
Glad you brought that up. I too thought about this as a middle ground solution between "boring your self to death by writing dozens of SQL queries and hand mapping to your model" and "black box ORM that generates crazy SQL queries".

I'm not sure it would work though. One of the problems I see is inherent with code generation approach: what happens when you had to modify the generated code and then changed your meta-model and want to regenerate the model again ?

Besides, the problem of "fitting square pigs in a round hole" would remain: SQL is much more versatile and flexible than objects/structs: you simply can't just work with the a table=an object abstraction, which tends to yield inefficient database queries and/or headaches from the developers side. Example:

    update table set one_field=value where some_condition_on_another_field.
How would you expect an ORM to generate a "dense" query like this with it's simplistic view of things ?

The same applies for the select queries, especially for reporting and data aggregation needs, where you would select some columns from multiple tables, possibly with formulas and computed columns.




> SQL is much more versatile and flexible than objects/structs

SQL isn't even turing complete. How can it be more versatile and flexible than your programming language of choice?

> How would you expect an ORM to generate a "dense" query like this with it's simplistic view of things ?

In SQLAlchemy,

    cls.query.filter(<some_condition_on_another_field>).update(dict(one_field=value))




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: