Do not use strings as attributes for loader
With SQLalchemy 2.0 strings are no longer accepted as attributes for the loader and attributes must be used instead directly. This also fixes DB migrations by removing deprecated subtransactions. Change-Id: I94865b90701e5a51f69187d9e790386e29ad7b5a
This commit is contained in:
parent
c05fe096cd
commit
2681091ffa
@ -92,8 +92,7 @@ def update_existing_records():
|
|||||||
nullable=True))
|
nullable=True))
|
||||||
|
|
||||||
# perform data migration between tables
|
# perform data migration between tables
|
||||||
session = sa.orm.Session(bind=op.get_bind())
|
with sa.orm.Session(bind=op.get_bind()) as session:
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
for row in session.query(VOLUME_MAPPING_TABLE):
|
for row in session.query(VOLUME_MAPPING_TABLE):
|
||||||
res = session.execute(
|
res = session.execute(
|
||||||
VOLUME_TABLE.insert().values(
|
VOLUME_TABLE.insert().values(
|
||||||
|
@ -43,8 +43,7 @@ TABLE_MODEL = sa.Table(
|
|||||||
def upgrade():
|
def upgrade():
|
||||||
op.alter_column('container', 'command', type_=sa.Text())
|
op.alter_column('container', 'command', type_=sa.Text())
|
||||||
# Convert 'command' from string to json-encoded list
|
# Convert 'command' from string to json-encoded list
|
||||||
session = sa.orm.Session(bind=op.get_bind())
|
with sa.orm.Session(bind=op.get_bind()) as session:
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
for row in session.query(TABLE_MODEL):
|
for row in session.query(TABLE_MODEL):
|
||||||
if row[1]:
|
if row[1]:
|
||||||
command = shlex.split(row[1])
|
command = shlex.split(row[1])
|
||||||
|
@ -41,8 +41,7 @@ def upgrade():
|
|||||||
'compute_node', ['rp_uuid'])
|
'compute_node', ['rp_uuid'])
|
||||||
|
|
||||||
# perform data migration between tables
|
# perform data migration between tables
|
||||||
session = sa.orm.Session(bind=op.get_bind())
|
with sa.orm.Session(bind=op.get_bind()) as session:
|
||||||
with session.begin(subtransactions=True):
|
|
||||||
for row in session.query(COMPUTE_NODE_TABLE):
|
for row in session.query(COMPUTE_NODE_TABLE):
|
||||||
session.execute(
|
session.execute(
|
||||||
COMPUTE_NODE_TABLE.update().values(
|
COMPUTE_NODE_TABLE.update().values(
|
||||||
|
@ -760,7 +760,8 @@ class Connection(object):
|
|||||||
query = model_query(models.Inventory, session=session)
|
query = model_query(models.Inventory, session=session)
|
||||||
query = self._add_inventories_filters(query, filters)
|
query = self._add_inventories_filters(query, filters)
|
||||||
query = query.join(models.Inventory.resource_provider)
|
query = query.join(models.Inventory.resource_provider)
|
||||||
query = query.options(contains_eager('resource_provider'))
|
query = query.options(
|
||||||
|
contains_eager(models.Inventory.resource_provider))
|
||||||
return _paginate_query(models.Inventory, limit, marker,
|
return _paginate_query(models.Inventory, limit, marker,
|
||||||
sort_key, sort_dir, query)
|
sort_key, sort_dir, query)
|
||||||
|
|
||||||
@ -783,7 +784,8 @@ class Connection(object):
|
|||||||
session = get_session()
|
session = get_session()
|
||||||
query = model_query(models.Inventory, session=session)
|
query = model_query(models.Inventory, session=session)
|
||||||
query = query.join(models.Inventory.resource_provider)
|
query = query.join(models.Inventory.resource_provider)
|
||||||
query = query.options(contains_eager('resource_provider'))
|
query = query.options(
|
||||||
|
contains_eager(models.Inventory.resource_provider))
|
||||||
query = query.filter_by(id=inventory_id)
|
query = query.filter_by(id=inventory_id)
|
||||||
try:
|
try:
|
||||||
return query.one()
|
return query.one()
|
||||||
@ -825,7 +827,8 @@ class Connection(object):
|
|||||||
query = model_query(models.Allocation, session=session)
|
query = model_query(models.Allocation, session=session)
|
||||||
query = self._add_allocations_filters(query, filters)
|
query = self._add_allocations_filters(query, filters)
|
||||||
query = query.join(models.Allocation.resource_provider)
|
query = query.join(models.Allocation.resource_provider)
|
||||||
query = query.options(contains_eager('resource_provider'))
|
query = query.options(
|
||||||
|
contains_eager(models.Allocation.resource_provider))
|
||||||
return _paginate_query(models.Allocation, limit, marker,
|
return _paginate_query(models.Allocation, limit, marker,
|
||||||
sort_key, sort_dir, query)
|
sort_key, sort_dir, query)
|
||||||
|
|
||||||
@ -846,7 +849,8 @@ class Connection(object):
|
|||||||
with session.begin():
|
with session.begin():
|
||||||
query = model_query(models.Allocation, session=session)
|
query = model_query(models.Allocation, session=session)
|
||||||
query = query.join(models.Allocation.resource_provider)
|
query = query.join(models.Allocation.resource_provider)
|
||||||
query = query.options(contains_eager('resource_provider'))
|
query = query.options(
|
||||||
|
contains_eager(models.Allocation.resource_provider))
|
||||||
query = query.filter_by(id=allocation_id)
|
query = query.filter_by(id=allocation_id)
|
||||||
try:
|
try:
|
||||||
return query.one()
|
return query.one()
|
||||||
|
Loading…
Reference in New Issue
Block a user