Skip to content

Commit 2d21899

Browse files
2 parents 958fb44 + f41d474 commit 2d21899

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

datajoint/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def query(self, query, args=(), as_dict=False, suppress_warnings=True, reconnect
147147
cur.execute(query, args)
148148
except (err.InterfaceError, err.OperationalError) as e:
149149
if is_connection_error(e) and reconnect:
150-
warnings.warn("Mysql server has gone away. Reconnectting to the server.")
150+
warnings.warn("Mysql server has gone away. Reconnecting to the server.")
151151
self.connect()
152152
if self._in_transaction:
153153
self.cancel_transaction()

datajoint/erd.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,17 @@ def __init__(self, source, context=None):
121121
if node.startswith('`%s`' % database):
122122
self.nodes_to_show.add(node)
123123

124+
for full_table_name in self.nodes_to_show:
125+
#one entry per parent
126+
parents = connection.dependencies.parents(full_table_name,True)
127+
128+
# all the foreign primary keys
129+
# set because multiple foreign constraints can be applied on the same local attribute
130+
foreign_primary_attributes = set(attr for parent in parents.values() for attr in parent['attr_map'].keys())
131+
132+
#distinguished table if table introduces atleast one primary key in the schema
133+
self.nodes._nodes[full_table_name]['distinguished'] = foreign_primary_attributes < self.nodes._nodes[full_table_name]['primary_key']
134+
124135
@classmethod
125136
def from_sequence(cls, sequence):
126137
"""
@@ -260,7 +271,7 @@ def make_dot(self):
260271
'-'*30 if q.startswith('---') else q.replace('->', '&#8594;') if '->' in q else q.split(':')[0]
261272
for q in description if not q.startswith('#'))
262273
node.set_tooltip('&#13;'.join(description))
263-
node.set_label(name)
274+
node.set_label("<<u>"+name+"</u>>" if node.get('distinguished') == 'True' else name)
264275
node.set_color(props['color'])
265276
node.set_style('filled')
266277

datajoint/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def insert(self, rows, replace=False, skip_duplicates=False, ignore_extra_fields
170170
# prohibit direct inserts into auto-populated tables
171171
if not (allow_direct_insert or getattr(self, '_allow_insert', True)): # _allow_insert is only present in AutoPopulate
172172
raise DataJointError(
173-
'Auto-populate tables can only be inserted into from their make methods during populate calls.')
173+
'Auto-populate tables can only be inserted into from their make methods during populate calls. (see allow_direct_insert)')
174174

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

0 commit comments

Comments
 (0)