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

v3.0.2 #40

Merged
merged 16 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
b52f2dd
models.reference_files:TActionType - remove "template"
MatteoCampinoti94 Aug 16, 2024
7c6b515
database.upgrade:upgrade - do not print versions
MatteoCampinoti94 Aug 19, 2024
870c48e
database.base:Table - add offset parameter to select methods
MatteoCampinoti94 Aug 20, 2024
2fbb10f
models.reference_files:TTemplateType - add "extracted-archive"
MatteoCampinoti94 Aug 20, 2024
0d42c55
database.upgrade - only use Connection methods to select and update d…
MatteoCampinoti94 Aug 20, 2024
ffecb9d
database.upgrade:is_latest - remove unneeded f-string
MatteoCampinoti94 Aug 20, 2024
946af91
database.base:View.create_statement - use * for select if view column…
MatteoCampinoti94 Aug 20, 2024
39cd76a
database.upgrade:set_db_version - fix incorrect parameter type
MatteoCampinoti94 Aug 20, 2024
d253b86
database.upgrade - ignore update statements without WHERE
MatteoCampinoti94 Aug 20, 2024
88f2612
database.upgrade:upgrade_3to3_0_2 - add function to upgrade from 3.0.…
MatteoCampinoti94 Aug 20, 2024
60b02bb
version - patch 3.0.1 > 3.0.2
MatteoCampinoti94 Aug 20, 2024
11e26c1
database.upgrade:upgrade_3to3_0_2 - fix WHERE for `_IdentificationWar…
MatteoCampinoti94 Aug 20, 2024
119e59f
database.upgrade:upgrade_2_0_2to3 - add `_IdentificationWarnings` reset
MatteoCampinoti94 Aug 20, 2024
35e8dcb
database.upgrade:get_upgrade_function - move below upgrade functions
MatteoCampinoti94 Aug 20, 2024
8334d38
database.upgrade:upgrade_last - remove unneeded function
MatteoCampinoti94 Aug 20, 2024
4320a15
database.files_db:FileDB.upgrade - run init after upgrade
MatteoCampinoti94 Aug 20, 2024
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
32 changes: 13 additions & 19 deletions acacore/database/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ def select(
columns: list[Column | SelectColumn] | None = None,
where: str | None = None,
order_by: list[tuple[str | Column, str]] | None = None,
offset: int | None = None,
limit: int | None = None,
parameters: list[Any | None] | None = None,
) -> Cursor:
Expand All @@ -293,6 +294,7 @@ def select(
:param where: A WHERE expression, defaults to None.
:param order_by: A list tuples containing one column (either as Column or string) and a sorting direction
("ASC", or "DESC"), defaults to None.
:param offset: The number of rows skip, defaults to None.
:param limit: The number of rows to limit the results to, defaults to None.
:param parameters: Values to substitute in the SELECT expression, both in the `where` and SelectColumn
statements, defaults to None.
Expand All @@ -316,6 +318,9 @@ def select(
order_statements = [f"{c.name if isinstance(c, Column) else c} {s}" for c, s in order_by]
statement += f" ORDER BY {','.join(order_statements)}"

if offset is not None:
statement += f" OFFSET {offset}"

if limit is not None:
statement += f" LIMIT {limit}"

Expand Down Expand Up @@ -432,6 +437,7 @@ def select(
model: Type[M] | None = None,
where: str | None = None,
order_by: list[tuple[str | Column, str]] | None = None,
offset: int | None = None,
limit: int | None = None,
parameters: list[Any] | None = None,
) -> ModelCursor[M]:
Expand All @@ -442,21 +448,14 @@ def select(
:param where: A WHERE expression, defaults to None.
:param order_by: A list tuples containing one column (either as Column or string) and a sorting direction
("ASC", or "DESC"), defaults to None.
:param offset: The number of rows skip, defaults to None.
:param limit: The number of rows to limit the results to, defaults to None.
:param parameters: Values to substitute in the SELECT expression, both in the `where` and SelectColumn
statements, defaults to None.
:return: A Cursor object wrapping the SQLite cursor returned by the SELECT transaction.
"""
return ModelCursor[M](
super()
.select(
model_to_columns(model or self.model),
where,
order_by,
limit,
parameters,
)
.cursor,
super().select(model_to_columns(model or self.model), where, order_by, offset, limit, parameters).cursor,
model or self.model,
self,
)
Expand Down Expand Up @@ -695,6 +694,7 @@ def select(
columns: list[Column | SelectColumn] | None = None,
where: str | None = None,
order_by: list[tuple[str | Column, str]] | None = None,
offset: int | None = None,
limit: int | None = None,
parameters: list[Any] | None = None,
) -> Cursor:
Expand All @@ -705,6 +705,7 @@ def select(
:param where: A WHERE expression, defaults to None.
:param order_by: A list tuples containing one column (either as Column or string) and a sorting direction
("ASC", or "DESC"), defaults to None.
:param offset: The number of rows skip, defaults to None.
:param limit: The number of rows to limit the results to, defaults to None.
:param parameters: Values to substitute in the SELECT expression, both in the `where` and SelectColumn
statements, defaults to None.
Expand All @@ -724,7 +725,7 @@ def select(
)
for c in map(SelectColumn.from_column, self.columns)
]
return super().select(columns, where, order_by, limit, parameters)
return super().select(columns, where, order_by, offset, limit, parameters)

def insert(self, *_args, **_kwargs):
"""
Expand Down Expand Up @@ -793,19 +794,12 @@ def select(
model: Type[M] | None = None,
where: str | None = None,
order_by: list[tuple[str | Column, str]] | None = None,
offset: int | None = None,
limit: int | None = None,
parameters: list[Any] | None = None,
) -> ModelCursor[M]:
return ModelCursor[M](
super()
.select(
model_to_columns(model or self.model),
where,
order_by,
limit,
parameters,
)
.cursor,
super().select(model_to_columns(model or self.model), where, order_by, offset, limit, parameters).cursor,
model or self.model,
self,
)
Expand Down
2 changes: 0 additions & 2 deletions acacore/database/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,4 @@ def upgrade(db: FileDB):

while current_version < latest_version:
update_function = get_upgrade_function(current_version, latest_version)
print(current_version, end=" ")
current_version = update_function(db)
print(current_version)
2 changes: 1 addition & 1 deletion acacore/models/reference_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
TActionType = Literal[
"convert",
"extract",
"template",
"manual",
"rename",
"ignore",
Expand All @@ -28,6 +27,7 @@
"duplicate",
"not-preservable",
"not-convertable",
"extracted-archive",
]

ActionTypeEnum: tuple[TActionType, ...] = get_type_args(TActionType)
Expand Down
Loading