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

Refactor query functions with return in a for-loop #60

Open
goodmami opened this issue Mar 14, 2019 · 0 comments
Open

Refactor query functions with return in a for-loop #60

goodmami opened this issue Mar 14, 2019 · 0 comments

Comments

@goodmami
Copy link
Member

For example:

    def f_src_id_by_proj_ver(proj, version):
        for r in query_omw("""SELECT src.id 
                              FROM src JOIN proj
                              ON src.proj_id=proj.id 
                              WHERE proj.code= ? AND src.version = ?""",
                           [proj, version]):
            return r['id']

Besides being confusing, it is a source of bugs. In one case (#48), the for loop iterated over an empty list, so the function returned None instead of r['id'].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant