Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/postgres_dynamic/pgd_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def get_one(cls, connection_string: dict, main_table: dict, where: list, j
where_query=''
for w in where:
where_query += f' {w["column_name"]} {w["operator"]} %s' if w.get('operator') else f' {w["column_name"]} = %s'
where_query += f' {w["conjuntion"]}' if w.get('conjuntion') else ' '
where_query += f' {w["conjunction"]}' if w.get('conjunction') else ' '
join_query = ''
for i in join_table:
join_query += ' INNER JOIN' if i['join_method'] == 'INNER' else ' LEFT JOIN' if i['join_method'] == 'LEFT' else ' RIGHT JOIN'
Expand Down Expand Up @@ -42,7 +42,7 @@ async def get_all(cls, connection_string: dict, main_table: dict, where: list, j
where_query=''
for w in where:
where_query += f' {w["column_name"]} {w["operator"]} %s' if w.get('operator') else f' {w["column_name"]} = %s'
where_query += f' {w["conjuntion"]}' if w.get('conjuntion') else ' '
where_query += f' {w["conjunction"]}' if w.get('conjunction') else ' '
order_query = 'ORDER BY ' + ''.join([key + f' {order[key]}' for key in order.keys()]) if len(order) == 1 else ' , '.join([key + f' {order[key]}' for key in order.keys()])
join_query = ''
for i in join_table:
Expand Down Expand Up @@ -73,13 +73,13 @@ async def get_count(cls, connection_string: dict, main_table: dict, where: list,
where_query=''
for w in where:
where_query += f' {w["column_name"]} {w["operator"]} %s' if w.get('operator') else f' {w["column_name"]} = %s'
where_query += f' {w["conjuntion"]}' if w.get('conjuntion') else ' '
where_query += f' {w["conjunction"]}' if w.get('conjunction') else ' '
join_query = ''
for i in join_table:
join_query += ' INNER JOIN' if i['join_method'] == 'INNER' else ' LEFT JOIN' if i['join_method'] == 'LEFT' else ' RIGHT JOIN'
join_query += f' {i["table"]} {i["alias"]} ON {i["on"]}'
query = query.format(main_table=main_table['table'], main_table_alias=main_table['alias'] if main_table.get('alias') else '', join_table=join_query, where_query=where_query)
where_values = tuple(wv['value'] for wv in where)
where_values = tuple(wv['value'] if isinstance(wv['value'], str) else tuple(wv['value']) for wv in where )
values = where_values
with PGDConnection(connection_string, query, values) as cursor:
result = cursor.fetchone()[0]
Expand Down
4 changes: 2 additions & 2 deletions src/postgres_dynamic/pgd_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def update(cls, connection_object: any, main_table: str, column_and_value:
where_query=''
for w in where:
where_query += f' {w["column_name"]} {w["operator"]} %s' if w.get('operator') else f' {w["column_name"]} = %s'
where_query += f' {w["conjuntion"]}' if w.get('conjuntion') else ' '
where_query += f' {w["conjunction"]}' if w.get('conjunction') else ' '

query_template = """
UPDATE {main_table} SET {columns} WHERE {where_query}
Expand Down Expand Up @@ -65,7 +65,7 @@ async def delete(cls, connection_object: any, main_table: str, where: list, comm
where_query=''
for w in where:
where_query += f' {w["column_name"]} {w["operator"]} %s' if w.get('operator') else f' {w["column_name"]} = %s'
where_query += f' {w["conjuntion"]}' if w.get('conjuntion') else ' '
where_query += f' {w["conjunction"]}' if w.get('conjunction') else ' '

query_template = """
DELETE FROM {main_table} WHERE {where_query}
Expand Down