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
7 changes: 7 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.12.2] -- 2025-03-27
- Fixed links between schema and project

## [0.12.1] -- 2025-03-27
- Added alembic to the project
- Fixed errors in methods getting user stars


## [0.12.0] -- 2025-03-27
- New database model for schemas
Expand Down
2 changes: 1 addition & 1 deletion pepdbagent/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.12.1"
__version__ = "0.12.2"
61 changes: 44 additions & 17 deletions pepdbagent/modules/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
NAME_KEY,
PEPHUB_SAMPLE_ID_KEY,
PKG_NAME,
LATEST_SCHEMA_VERSION,
)
from pepdbagent.db_utils import (
BaseEngine,
Expand Down Expand Up @@ -369,17 +370,29 @@ def create(
schema_namespace, schema_name, schema_version = schema_path_converter(pep_schema)
with Session(self._sa_engine) as session:

schema_mapping = session.scalar(
select(SchemaVersions)
.join(SchemaRecords, SchemaRecords.id == SchemaVersions.schema_id)
.where(
and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
SchemaVersions.version == schema_version,
if schema_version == LATEST_SCHEMA_VERSION:
schema_mapping = session.scalar(
select(SchemaVersions)
.join(SchemaRecords, SchemaRecords.id == SchemaVersions.schema_id)
.where(
and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
)
)
.order_by(SchemaVersions.version.desc())
)

else:
where_clause = and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
SchemaVersions.version == schema_version,
)

schema_mapping = session.scalar(
select(SchemaVersions).join(SchemaRecords).where(where_clause)
)
)
if not schema_mapping:
raise SchemaDoesNotExistError(
f"Schema {schema_namespace}/{schema_name} does not exist. "
Expand Down Expand Up @@ -698,15 +711,29 @@ def _convert_update_schema_id(session: Session, update_values: dict):
schema_namespace, schema_name, schema_version = schema_path_converter(
update_values["pep_schema"]
)
where_clause = and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
SchemaVersions.version == schema_version,
)
if schema_version == LATEST_SCHEMA_VERSION:
schema_mapping = session.scalar(
select(SchemaVersions)
.join(SchemaRecords, SchemaRecords.id == SchemaVersions.schema_id)
.where(
and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
)
)
.order_by(SchemaVersions.version.desc())
)

schema_mapping = session.scalar(
select(SchemaVersions).join(SchemaRecords).where(where_clause)
)
else:
where_clause = and_(
SchemaRecords.namespace == schema_namespace,
SchemaRecords.name == schema_name,
SchemaVersions.version == schema_version,
)

schema_mapping = session.scalar(
select(SchemaVersions).join(SchemaRecords).where(where_clause)
)
if not schema_mapping:
raise SchemaDoesNotExistError(
f"Schema {schema_namespace}/{schema_name} does not exist. "
Expand Down
Loading