cubes_lite/sql/mapping.py
def _required_tables(self, attributes, root_table_object=None):
        """Get all tables that are required to be joined to get `attributes`.
        `attributes` is a list of `Mapper` attributes (or objects with
        same kind of attributes).
        """

        root_table_object = root_table_object or self.root_table_object

        attributes = [attr for attr in attributes if attr.is_base]
        relevant_tables = set(
            self.get_table_object(self.get_column_object_by_attribute(a).table_key)
            for a in attributes
        )

        # now we have to resolve all dependencies
        required = {}
        while relevant_tables:
            table = relevant_tables.pop()
            required[table.key] = table

            if not table.join:
                continue

            master = table.join.master.table_key
            if master not in required:
                relevant_tables.add(self.get_table_object(master))

            detail = table.join.detail.table_key
            if table.join.alias:
                detail = (detail[0], table.join.alias)
            if detail not in required:
                relevant_tables.add(self.get_table_object(detail))

        # plain_dimensions = {a.dimension for a in attributes if a.dimension.is_plain}
        # if not plain_dimensions:
        #     required.pop(self.root_table_object.key, None)
        required.pop(self.root_table_object.key, None)
        required = {
            key: table
            for key, table in required.items()
            if (
                table.join.master.table is not None or
                table == root_table_object
            )
        }

        if root_table_object.key in required:
            masters = {root_table_object.key: root_table_object}
            sorted_tables = [root_table_object]
        else:
            details = [
                table for table in required.values()
                if table.join.method == 'detail'
            ]
            if details:
                first = details[0]
            else:
                first = required.values()[0]

            sorted_tables = [first]
            masters = {first.key: first}

        while required:
            details = [
                table for table in required.values()
                if table.join and table.join.master.table_key in masters
            ]

            if not details:
                break

            for detail in details:
                masters[detail.key] = detail
                sorted_tables.append(detail)

                del required[detail.key]

        if len(required) > 1:
            keys = [
                str(table)
                for table in required.values()
                if table.key != self.root_table_object.key
            ]

            raise ModelError(
                'Some tables are not joined: {}'
                .format(', '.join(keys))
            )

        return sorted_tables
Get all tables that are required to be joined to get `attributes`.
        `attributes` is a list of `Mapper` attributes (or objects with
        same kind of attributes).
        
Get all tables that are required to be joined to get `attributes`.
`attributes` is a list of `Mapper` attributes (or objects with
same kind of attributes).
Get all tables that are required to be joined to get ` attributes ` . ` attributes ` is a list of ` Mapper ` attributes ( or objects with same kind of attributes ) .
def _required_tables(self, attributes, root_table_object=None):
        root_table_object = root_table_object or self.root_table_object
        attributes = [attr for attr in attributes if attr.is_base]
        relevant_tables = set(
            self.get_table_object(self.get_column_object_by_attribute(a).table_key)
            for a in attributes
        )
        required = {}
        while relevant_tables:
            table = relevant_tables.pop()
            required[table.key] = table
            if not table.join:
                continue
            master = table.join.master.table_key
            if master not in required:
                relevant_tables.add(self.get_table_object(master))
            detail = table.join.detail.table_key
            if table.join.alias:
                detail = (detail[0], table.join.alias)
            if detail not in required:
                relevant_tables.add(self.get_table_object(detail))
        required.pop(self.root_table_object.key, None)
        required = {
            key: table
            for key, table in required.items()
            if (
                table.join.master.table is not None or
                table == root_table_object
            )
        }
        if root_table_object.key in required:
            masters = {root_table_object.key: root_table_object}
            sorted_tables = [root_table_object]
        else:
            details = [
                table for table in required.values()
                if table.join.method == 'detail'
            ]
            if details:
                first = details[0]
            else:
                first = required.values()[0]
            sorted_tables = [first]
            masters = {first.key: first}
        while required:
            details = [
                table for table in required.values()
                if table.join and table.join.master.table_key in masters
            ]
            if not details:
                break
            for detail in details:
                masters[detail.key] = detail
                sorted_tables.append(detail)
                del required[detail.key]
        if len(required) > 1:
            keys = [
                str(table)
                for table in required.values()
                if table.key != self.root_table_object.key
            ]
            raise ModelError(
                'Some tables are not joined: {}'
                .format(', '.join(keys))
            )
        return sorted_tables
def _required_tables ( self , attributes , root_table_object = None ) : root_table_object = root_table_object or self . root_table_object attributes = [ attr for attr in attributes if attr . is_base ] relevant_tables = set ( self . get_table_object ( self . get_column_object_by_attribute ( a ) . table_key ) for a in attributes ) required = { } while relevant_tables : table = relevant_tables . pop ( ) required [ table . key ] = table if not table . join : continue master = table . join . master . table_key if master not in required : relevant_tables . add ( self . get_table_object ( master ) ) detail = table . join . detail . table_key if table . join . alias : detail = ( detail [ 0 ] , table . join . alias ) if detail not in required : relevant_tables . add ( self . get_table_object ( detail ) ) required . pop ( self . root_table_object . key , None ) required = { key : table for key , table in required . items ( ) if ( table . join . master . table is not None or table == root_table_object ) } if root_table_object . key in required : masters = { root_table_object . key : root_table_object } sorted_tables = [ root_table_object ] else : details = [ table for table in required . values ( ) if table . join . method == 'detail' ] if details : first = details [ 0 ] else : first = required . values ( ) [ 0 ] sorted_tables = [ first ] masters = { first . key : first } while required : details = [ table for table in required . values ( ) if table . join and table . join . master . table_key in masters ] if not details : break for detail in details : masters [ detail . key ] = detail sorted_tables . append ( detail ) del required [ detail . key ] if len ( required ) > 1 : keys = [ str ( table ) for table in required . values ( ) if table . key != self . root_table_object . key ] raise ModelError ( 'Some tables are not joined: {}' . format ( ', ' . join ( keys ) ) ) return sorted_tables
Get all tables that are required to be joined to get `attributes`.
Get all tables that are required to be joined to get ` attributes ` .
"""Get all tables that are required to be joined to get `attributes`.
        `attributes` is a list of `Mapper` attributes (or objects with
        same kind of attributes).
        """ # now we have to resolve all dependencies # plain_dimensions = {a.dimension for a in attributes if a.dimension.is_plain} # if not plain_dimensions: #     required.pop(self.root_table_object.key, None)
self
attributes
root_table_object