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

add wrapper/utils to help build paramters #273

Open
wey-gu opened this issue May 4, 2023 · 2 comments
Open

add wrapper/utils to help build paramters #273

wey-gu opened this issue May 4, 2023 · 2 comments
Labels

Comments

@wey-gu
Copy link
Contributor

wey-gu commented May 4, 2023

i.e., it took me some time to figure out how to build a proper Nlist of strings to be passed to session_pool.execute_parameter(), I will wrap it as a utils later.

def prepare_subjs_param(subjs: Optional[List[str]]) -> dict:
    """Prepare parameters for query."""
    if subjs is None:
        return {}
    from nebula3.common import ttypes

    subjs_list = []
    subjs_byte = ttypes.Value()
    for subj in subjs:
        if not isinstance(subj, str):
            raise TypeError(f"Subject should be str, but got {type(subj).__name__}.")
        subj_byte = ttypes.Value()
        subj_byte.set_sVal(subj)
        subjs_list.append(subj_byte)
    subjs_nlist = ttypes.NList(values=subjs_list)
    subjs_byte.set_lVal(subjs_nlist)
    return {"subjs": subjs_byte}
@wey-gu
Copy link
Contributor Author

wey-gu commented Sep 25, 2023

For anyone who would like to impl. this, I will reassign to you.

@wey-gu wey-gu removed their assignment Sep 25, 2023
wey-gu added a commit that referenced this issue May 27, 2024
@wey-gu wey-gu mentioned this issue May 27, 2024
3 tasks
@wey-gu
Copy link
Contributor Author

wey-gu commented May 28, 2024

done with #349

Nicole00 pushed a commit that referenced this issue May 29, 2024
* feat: cast params

#273

* handle None of params

* lint: make black happy

* docs and example added with UT coverage

* docs of result set as primitive

* fix structure to make the cast non-breaking (#350)

* make linter happy

* minor fix

* remove list cast

* fix NList usage

* fix test

* chore: polish readme

---------

Co-authored-by: 盐粒 Yanli <[email protected]>
wey-gu added a commit that referenced this issue Jul 16, 2024
* feat: cast params

#273

* handle None of params

* lint: make black happy

* docs and example added with UT coverage

* docs of result set as primitive

* fix structure to make the cast non-breaking (#350)

* make linter happy

* minor fix

* remove list cast

* fix NList usage

* fix test

* chore: polish readme

---------

Co-authored-by: 盐粒 Yanli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant