Lock column updates
This commit is contained in:
parent
894819fe99
commit
a513888824
@ -56,6 +56,7 @@ class Table(object):
|
||||
"""Get a dictionary of all columns and their case mapping."""
|
||||
if not self.exists:
|
||||
return {}
|
||||
with self.db.lock:
|
||||
if self._columns is None:
|
||||
# Initialise the table if it doesn't exist
|
||||
table = self.table
|
||||
@ -68,6 +69,10 @@ class Table(object):
|
||||
self._columns[key] = name
|
||||
return self._columns
|
||||
|
||||
def _flush_metadata(self):
|
||||
with self.db.lock:
|
||||
self._columns = None
|
||||
|
||||
@property
|
||||
def columns(self):
|
||||
"""Get a listing of all columns that exist in the table."""
|
||||
@ -305,7 +310,7 @@ class Table(object):
|
||||
def _reflect_table(self):
|
||||
"""Load the tables definition from the database."""
|
||||
with self.db.lock:
|
||||
self._columns = None
|
||||
self._flush_metadata()
|
||||
try:
|
||||
self._table = SQLATable(self.name,
|
||||
self.db.metadata,
|
||||
@ -323,7 +328,7 @@ class Table(object):
|
||||
|
||||
def _sync_table(self, columns):
|
||||
"""Lazy load, create or adapt the table structure in the database."""
|
||||
self._columns = None
|
||||
self._flush_metadata()
|
||||
if self._table is None:
|
||||
# Load an existing table from the database.
|
||||
self._reflect_table()
|
||||
@ -520,7 +525,7 @@ class Table(object):
|
||||
self._threading_warn()
|
||||
self.table.drop(self.db.executable, checkfirst=True)
|
||||
self._table = None
|
||||
self._columns = None
|
||||
self._flush_metadata()
|
||||
|
||||
def has_index(self, columns):
|
||||
"""Check if an index exists to cover the given ``columns``."""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user