Pegase745 / sqlalchemy-datatables

SQLAlchemy integration of jQuery DataTables >= 1.10.x (Pyramid and Flask examples)
MIT License
159 stars 67 forks source link

Unable to sort by hybrid properties #36

Closed patrickyan closed 7 years ago

patrickyan commented 8 years ago

I have a basic setup

    columns = []
    columns.append(ColumnDT('id'))
    columns.append(ColumnDT('name'))
    columns.append(ColumnDT('address'))
    columns.append(ColumnDT('child.date'))
    columns.append(ColumnDT('created_at'))

When trying to sort on name or address which is a hybrid property, I get

OperationalError: (OperationalError) (1054, "Unknown column 'obj.address' in 'order clause'")

How the hybrid property is defined

    @hybrid_property
    def name(self):
        return utils.join([self.first_name, self.last_name])

    @name.expression
    def name(cls):
        return cls.first_name + ' ' + ls.last_name
Pegase745 commented 8 years ago

Could you possibly create an example here in a branch, so that I can look at it from the same point of view as you?

ufoczek commented 8 years ago

Example created

tdamsma commented 7 years ago

@Pegase745, think this can be closed as it should be solved now

Pegase745 commented 7 years ago

@tdamsma I didn't rebase his example onto the latest code evolution in order to confirm that yet