Selection filter
This commit is contained in:
parent
0e03594e54
commit
b784422e69
3 changed files with 7 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[metadata]
|
||||
name = based
|
||||
version = 0.2.0
|
||||
version = 0.2.1
|
||||
description = A simple, fast (maybe), and reliable (I hope) PostgreSQL ORM oriented for dynamic models.
|
||||
author = nuark
|
||||
author_email = me@nuark.xyz
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
__version__ = "0.2.0"
|
||||
__version__ = "0.2.1"
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class DBConnector:
|
|||
conn.execute(stmt)
|
||||
|
||||
def selectFromTable(
|
||||
self, table_name: str, columns: list[str]
|
||||
self, table_name: str, columns: list[str], where: list[ColumnCondition] = []
|
||||
) -> list[dict[str, Any]]:
|
||||
if len(columns) == 1 and columns[0] == "*":
|
||||
stmt = SQL("SELECT * FROM {}").format(Identifier(table_name))
|
||||
|
|
@ -221,6 +221,10 @@ class DBConnector:
|
|||
SQL(", ").join(map(lambda c: Identifier(c), columns)),
|
||||
Identifier(table_name),
|
||||
)
|
||||
if len(where) > 0:
|
||||
stmt += SQL(" WHERE {}").format(
|
||||
SQL(" AND ").join(map(lambda cp: cp.sql(), where))
|
||||
)
|
||||
with self.connection as conn:
|
||||
return conn.execute(stmt).fetchall()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue