def include_forward_references(table, head, consumed, include, exclude, indent, opts): found = False for col in filter( lambda col: (not is_excluded(col.name, exclude) or is_included(col.name, include)), table.columns()): logger.debug('col.name %s not in exclude %s', col.name, exclude) fk = table.foreign_key(col.name) # logger.debug('consumed=%s', consumed) if not fk: if opts.include_columns: # Add column head.append(ColumnNode(col, indent)) elif fk.a.table.name == table.name: # Collects the forward references logger.debug('adds forward reference: fk=%s, include=%s', fk, include) head.append(ForeignKeyNode(fk, table, indent)) if (is_included(fk.a.name, include) or (opts.recursive and fk.b.table.name not in consumed)): # logger.debug('adds table=%s', fk.b.table) head.append( TableNode(fk.b.table, include=selection(fk.a.name, include), exclude=selection(fk.a.name, exclude), indent=indent + 1)) found = True return found
def include_forward_references( table, head, consumed, include, exclude, indent, opts): found = False for col in filter( lambda col: ( not is_excluded(col.name, exclude) or is_included(col.name, include)), table.columns()): logger.debug('col.name %s not in exclude %s', col.name, exclude) fk = table.foreign_key(col.name) # logger.debug('consumed=%s', consumed) if not fk: if opts.include_columns: # Add column head.append(ColumnNode(col, indent)) elif fk.a.table.name == table.name: # Collects the forward references logger.debug( 'adds forward reference: fk=%s, include=%s', fk, include) head.append(ForeignKeyNode(fk, table, indent)) if (is_included(fk.a.name, include) or (opts.recursive and fk.b.table.name not in consumed)): # logger.debug('adds table=%s', fk.b.table) head.append(TableNode( fk.b.table, include=selection(fk.a.name, include), exclude=selection(fk.a.name, exclude), indent=indent + 1)) found = True return found
def include_back_references(table, head, consumed, include, exclude, indent, opts): found = False for _, fk in filter( lambda (key, fk): (fk.b.table.name == table.name and (not is_excluded(fk.a.table.name, exclude) or is_included( fk.a.table.name, include))), table.foreign_keys().iteritems()): logger.debug('adds back reference: fk=%s, include=%s', fk, include) head.append(ForeignKeyNode(fk, table, indent)) if (is_included(fk.a.table.name, include) or (opts.recursive and fk.a.table.name not in consumed)): # Collects the back references # logger.debug('adds table=%s', fk.a.table) head.append( TableNode(fk.a.table, include=selection(fk.a.table.name, include), exclude=selection(fk.a.table.name, exclude), indent=indent + 1)) found = True
def include_back_references( table, head, consumed, include, exclude, indent, opts): found = False for _, fk in filter( lambda (key, fk): ( fk.b.table.name == table.name and ( not is_excluded(fk.a.table.name, exclude) or is_included(fk.a.table.name, include))), table.foreign_keys().iteritems()): logger.debug( 'adds back reference: fk=%s, include=%s', fk, include) head.append(ForeignKeyNode(fk, table, indent)) if (is_included(fk.a.table.name, include) or (opts.recursive and fk.a.table.name not in consumed)): # Collects the back references # logger.debug('adds table=%s', fk.a.table) head.append(TableNode( fk.a.table, include=selection(fk.a.table.name, include), exclude=selection(fk.a.table.name, exclude), indent=indent + 1)) found = True
def test_is_included(self): """Tests the utils.is_included function""" d = { 'a': { 'b': False, 'c': None }, 'd': None, 'e': { 'f': { 'g': None } } } self.assertEqual(False, utils.is_included('a', {})) self.assertEqual(True, utils.is_included('a', None)) self.assertEqual(True, utils.is_included('a', d)) self.assertEqual(False, utils.is_included('b', d)) self.assertEqual(False, utils.is_included('c', d)) self.assertEqual(True, utils.is_included('d', d)) self.assertEqual(True, utils.is_included('e', d)) self.assertEqual(False, utils.is_included('f', d)) self.assertEqual(False, utils.is_included('g', d)) self.assertEqual(False, utils.is_included('b', d['a'])) self.assertEqual(True, utils.is_included('c', d['a'])) self.assertEqual(True, utils.is_included('f', d['e'])) self.assertEqual(True, utils.is_included('g', d['e']['f'])) self.assertEqual(False, utils.is_included('g', True)) self.assertEqual(True, utils.is_included('g', {'*': None}))