Skip to content

Commit

Permalink
Merge pull request #118 from ProdPerfect/empty-paren-query-fix
Browse files Browse the repository at this point in the history
Empty parens are no longer supported
  • Loading branch information
pevner-p2 authored Nov 29, 2023
2 parents 6998697 + 0c936eb commit db0e662
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion monday/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '2.0.0-pre'
__version__ = '2.0.0rc1'
__author__ = 'Christina D\'Astolfo'
__email__ = '[email protected], [email protected], [email protected]'
17 changes: 9 additions & 8 deletions monday/query_joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,13 +357,13 @@ def get_tags_query(tags):
def get_board_items_query(board_id: Union[str, int], limit: Optional[int] = None, page: Optional[int] = None) -> str:
raw_params = locals().items()
item_params = gather_params(raw_params, exclusion_list=["board_id", "item_ids"])
joined_params = ', '.join(item_params)
joined_params = f"({', '.join(item_params)})" if item_params else ""

query = '''query{
boards(ids: %s){
name
items_page (){
items(%s) {
items_page {
items %s {
group {
id
title
Expand Down Expand Up @@ -393,12 +393,12 @@ def get_boards_query(limit: int = None, page: int = None, ids: List[int] = None,
value = v
if isinstance(v, Enum):
value = v.value

query_params.append("%s: %s" % (k, value))
joined_params = f"({', '.join(query_params)})" if query_params else ""

query = '''query
{
boards (%s) {
boards %s {
id
name
permissions
Expand All @@ -416,7 +416,7 @@ def get_boards_query(limit: int = None, page: int = None, ids: List[int] = None,
type
}
}
}''' % ', '.join(query_params)
}''' % joined_params

return query

Expand Down Expand Up @@ -486,9 +486,10 @@ def create_board_by_workspace_query(board_name: str, board_kind: BoardKind, work

# USER RESOURCE QUERIES
def get_users_query(**kwargs):
joined_params = f"({', '.join(['%s: %s' % (arg, kwargs.get(arg)) for arg in kwargs])})" if kwargs else ""
query = '''query
{
users (%s) {
users %s {
id
name
email
Expand All @@ -498,7 +499,7 @@ def get_users_query(**kwargs):
name
}
}
}''' % ', '.join(["%s: %s" % (arg, kwargs.get(arg)) for arg in kwargs])
}''' % joined_params
return query


Expand Down
4 changes: 2 additions & 2 deletions monday/tests/test_board_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def test_get_boards_by_id_query(self):
def test_get_board_items_query(self):
query = get_board_items_query(board_id=self.board_id)
self.assertIn(str(self.board_id), query)
items_line = 'items()'
items_line = 'items'
self.assertIn(items_line, query)

def test_get_board_items_query_with_limit_and_pages(self):
limit = 100
page = 1
query = get_board_items_query(board_id=self.board_id, limit=limit, page=page)
items_line = f'items(limit: {limit}, page: {page})'
items_line = f'items (limit: {limit}, page: {page})'
self.assertIn(items_line, query)

def test_get_columns_by_board_query(self):
Expand Down

0 comments on commit db0e662

Please sign in to comment.