As almost everything in our world ORMs has advantages and disadvantages. The main criticism about ORMs is that they are leaky abstractions, that means they leaks details that it is supposed to abstract away, because there are times when you just need to use, for example, SQL directly or work with raw rows when making complex queries or improving performance because that is one of the ORMs disadvantages, they include an extra logical layer that, depending on the implementation can affect performance more or less.

But there are lot of people out there using ORMs and this is because they have advantages, compared with PyDAL, mostly when you are using big models, for example, compare this PyDAL model:

    def _get_somethig_plus_age(row, extra):
        return row.person.age + extra

    db.define_table('person',
        Field('name')
        Field('age', 'integer')
        Field.Method('get_somethig_plus_age', _get_somethig_plus_age)
    )

against this ORM-style model:

    class Person(Model):
        name = Field()
        age = Field('integer')

        def get_somethig_plus_age(self, extra):
            return self.age + extra

In an ORM, a model class represents a table, and when you query the DB, you get the class instance objects representing rows. Using this approach you can directly benefit from the advantages of the OOP and the code readability and organization improves a lot, mostly when models starts grow big.

Greetings.


El 19/4/19 a las 2:44 a.m., Dave S escribió:
On Thursday, April 18, 2019 at 3:48:09 PM UTC-7, Carlos Cesar Caballero wrote:

    Hi Massimo, here is it: https://github.com/cccaballero/pydal-orm
    <https://github.com/cccaballero/pydal-orm>. I
    think including something like this with pydal will be a really good
    improvement.

    Greetings.


As someone who had some SQL training (but not proficiency) before  using Web2Py, and who has rarely had an issue with using the DAL (but then, I don't have complicated projects, either),
I could use some info on what makes an ORM great.

I know that Massimo has said in the past that it was a deliberate choice to do the DAL instead of an ORM
(is the DAL a DAO?),
and I see the contributors to Wikipedia have listed some concerns
along with the advantages
(client code gets to stick with working with objects ++
 high level of abstraction obscures what is happening --
 heavy reliance on ORM cited as major factor in poorly designed DBs --)

The third approach appears to be OODBMS where the store actually is built around objects via ODMs
rather than translating tables.  This gets into NoSQL territory, it seems.

So, educate me!

/dps

    El 12/4/19 a las 4:33 p.m., Massimo Di Pierro escribió:
    > Can you make it a module on pypi? Or should we include it in pydal?
    >

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com <mailto:web2py+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to