A little fix to calculate over the same table

Skip to first unread message

Fabio Lenzarini

Apr 16, 2024, 11:34:07 AMApr 16
to Jam.py Users Mailing List
hello everyone, I would like to share a small modification to the db.py file to be able to perform calculation functions on the subtable when the table is the same; for example if on the task table I have subtasks, but the table is still the same:

    def calculated_sql(self, item, field):
    # sem.so
    #    result = 'SELECT %s("%s") FROM "%s" WHERE %s.%s=%s' % \
    #        (field._calc_op, field._calc_field.db_field_name, field._calc_item.table_name,
    #        self.table_alias(item), field._calc_item._primary_key_db_field_name, field._calc_on_field.db_field_name)
    # sem.eo
    # sem.sn
        result = 'SELECT %s("%s") FROM "%s" AS "%s" WHERE %s.%s=%s' % \
            (field._calc_op, field._calc_field.db_field_name, field._calc_item.table_name, field._calc_item.table_name + "_calc",
            self.table_alias(item), field._calc_item._primary_key_db_field_name, field._calc_on_field.db_field_name)
    # sem.en
        if field._calc_item._deleted_flag:
            result = '%s AND "%s"=0' % (result, field._calc_item._deleted_flag_db_field_name)
        result = '(%s) %s %s' % (result, self.FIELD_AS, self.identifier_case(field.field_name))
        return result
Reply all
Reply to author
0 new messages