[sqlalchemy-20] Use a ``TextClause`` object for the empty strings in the DB model definitions

Bug #2020050 reported by Rodolfo Alonso
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Rodolfo Alonso

Bug Description

The alembic comparator between the DB models and the loaded metadata in the database, cannot compare an empty string clause with a ``TextClause``. For example:
[( 'modify_default',
      None,
      'ml2_port_bindings',
      'vif_details',
      { 'existing_comment': None,
        'existing_nullable': False,
        'existing_type': VARCHAR(length=4095)},
      DefaultClause(<sqlalchemy.sql.elements.TextClause object at 0x7fbadc92ada0>, for_update=False),
      DefaultClause('', for_update=False))],

This is happening because in the DB model definitions we are using an empty string. For example, from the error presented, the "vif_details" column definition in the "ml2_port_bindings" table is [1]. The "server_default" parameter should be a ``TextClause`` object instead.

[1]https://github.com/openstack/neutron/blob/a26e957d346c79ce96680b437460c9a9c4b80447/neutron/plugins/ml2/models.py#L50-L51

Tags: db
Changed in neutron:
assignee: nobody → Rodolfo Alonso (rodolfo-alonso-hernandez)
Changed in neutron:
status: New → In Progress
tags: added: db
Changed in neutron:
importance: Undecided → High
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/883421
Committed: https://opendev.org/openstack/neutron/commit/6fa3d8019ffd416ad3eb90e6e9a364d4b6e23e80
Submitter: "Zuul (22348)"
Branch: master

commit 6fa3d8019ffd416ad3eb90e6e9a364d4b6e23e80
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Wed May 17 19:26:50 2023 +0200

    Use ``TextClause`` to define the DB model "server_default"

    The alembic comparator needs the same class to compare the
    database model with the loaded SQL schema.

    Closes-Bug: #2020050
    Change-Id: I4feab3e55f2e38a9eca70d4ca755b4c2974346d5

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 23.0.0.0b3

This issue was fixed in the openstack/neutron 23.0.0.0b3 development milestone.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.