MicroStrategy / mstrio-py

Python integration for MicroStrategy
Apache License 2.0
90 stars 60 forks source link

Unable to alter the description of Logical Tables and OLAP Cubes #201

Open jonjones76 opened 3 weeks ago

jonjones76 commented 3 weeks ago

When trying to alter the description of logical tables and cubes, nothing happens. Other objects are working fine, e.g. attributes, metrics, Grids etc. No errors are thrown, in fact below shows an example confirmation message in the output

OlapCube 'Intelligent Cube' has been modified on the server. Your changes are saved locally.

Below is a snippet of the code used

objects = list_olap_cubes(connection=mstr_connection, project_id=mstr_connection.project_id,
                                 name=row['Name'], search_pattern=SearchPattern.EXACTLY)
        if len(objects) > 1:
            for obj in objects:
                if obj.location == row_path_normalised:
                    update_description(mstr_connection, obj, ado_num)
                    break
        else:
            update_description(mstr_connection, objects[0], ado_num)

def update_description(mstr_connection, obj, ado_num):
    # Objects like transformations don't have a location property for some reason
    try:
        location = getattr(obj, 'location', 'unknown')
    except TypeError:
        location = 'unknown'

    print(f"{obj.__class__.__name__} Name: {obj.name} - ID: {obj.id} - Location: {location}")
    if obj.description:
        # some objects won't change if the description is blank so replace with space
        new_obj_desc = obj.description.replace(f"[{ado_num}]", " ")
        obj.__class__(connection=mstr_connection, id=obj.id, name=obj.name).alter(description=new_obj_desc)
    else:
        print(f"Warning: {obj.name} has no description to update.")

Is this a bug or am I approaching it wrong for these object types?

mstrio-py 11.4.6.101 Python 3.11.6

apiotrowskiMicroStrategy commented 3 weeks ago

Hi @jonjones76

This seems like a potential bug, but we need to look into it further to confirm.

I'll get back to you when I have something more concrete.