Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on Invalid References During Table Import #82

Open
pasetti opened this issue Sep 11, 2022 · 0 comments
Open

Exception on Invalid References During Table Import #82

pasetti opened this issue Sep 11, 2022 · 0 comments
Assignees

Comments

@pasetti
Copy link
Contributor

pasetti commented Sep 11, 2022

Consider the following function in convert.py:

def convert_exp_to_db(project, s):
    """
    The argument is a plain reference field in export representation 
    (the reference is represented by the string domain:name). 
    The function converts it to database representation.
    Invalid references raise an exception which must be handled by the caller.
    """
    if s == '':
        return None
    m = pattern_ref_exp.match(s)
    ref = m.group().split(':')
    return SpecItem.objects.exclude(status='OBS').exclude(status='DEL').\
                        get(project_id=project.id, domain=ref[0], name=ref[1])

If I export a table where there are reference fields which are empty, the csv will have a value of 'None' for such cells. If I then import the same table, the function above will throw an exception when processing the cell with the 'None' value.

More generally, I need to modify this function to handle cases where there are invalid references.

@pasetti pasetti self-assigned this Sep 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant