Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dimitri-yatsenko committed Feb 4, 2019
2 parents 958fb44 + f41d474 commit 2d21899
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion datajoint/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def query(self, query, args=(), as_dict=False, suppress_warnings=True, reconnect
cur.execute(query, args)
except (err.InterfaceError, err.OperationalError) as e:
if is_connection_error(e) and reconnect:
warnings.warn("Mysql server has gone away. Reconnectting to the server.")
warnings.warn("Mysql server has gone away. Reconnecting to the server.")
self.connect()
if self._in_transaction:
self.cancel_transaction()
Expand Down
13 changes: 12 additions & 1 deletion datajoint/erd.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ def __init__(self, source, context=None):
if node.startswith('`%s`' % database):
self.nodes_to_show.add(node)

for full_table_name in self.nodes_to_show:
#one entry per parent
parents = connection.dependencies.parents(full_table_name,True)

# all the foreign primary keys
# set because multiple foreign constraints can be applied on the same local attribute
foreign_primary_attributes = set(attr for parent in parents.values() for attr in parent['attr_map'].keys())

#distinguished table if table introduces atleast one primary key in the schema
self.nodes._nodes[full_table_name]['distinguished'] = foreign_primary_attributes < self.nodes._nodes[full_table_name]['primary_key']

@classmethod
def from_sequence(cls, sequence):
"""
Expand Down Expand Up @@ -260,7 +271,7 @@ def make_dot(self):
'-'*30 if q.startswith('---') else q.replace('->', '&#8594;') if '->' in q else q.split(':')[0]
for q in description if not q.startswith('#'))
node.set_tooltip('&#13;'.join(description))
node.set_label(name)
node.set_label("<<u>"+name+"</u>>" if node.get('distinguished') == 'True' else name)
node.set_color(props['color'])
node.set_style('filled')

Expand Down
2 changes: 1 addition & 1 deletion datajoint/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def insert(self, rows, replace=False, skip_duplicates=False, ignore_extra_fields
# prohibit direct inserts into auto-populated tables
if not (allow_direct_insert or getattr(self, '_allow_insert', True)): # _allow_insert is only present in AutoPopulate
raise DataJointError(
'Auto-populate tables can only be inserted into from their make methods during populate calls.')
'Auto-populate tables can only be inserted into from their make methods during populate calls. (see allow_direct_insert)')

heading = self.heading
if inspect.isclass(rows) and issubclass(rows, QueryExpression): # instantiate if a class
Expand Down

0 comments on commit 2d21899

Please sign in to comment.