Skip to content

Commit

Permalink
fix: shorten the table name
Browse files Browse the repository at this point in the history
  • Loading branch information
kod-kristoff committed Mar 28, 2022
1 parent 663d37a commit 564c4e4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions karp/lex_infrastructure/repositories/sql_entries.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
"""SQL repositories for entries."""
import inspect
import logging
import typing
from typing import Dict, List, Optional, Tuple, Generic, TypeVar
from uuid import UUID
from typing import Dict, List, Optional, Generic, TypeVar

import injector
import regex
import sqlalchemy as sa
from sqlalchemy import sql
from sqlalchemy.orm import sessionmaker
import logging
import ulid

from karp.foundation.value_objects import UniqueId
from karp.foundation.events import EventBus
Expand Down Expand Up @@ -190,7 +188,7 @@ def _save(self, entry: Entry):
{
'entry_by_entry_id': entry_by_entry_id,
'entry_by_entity_id': entry_by_entity_id,
'entry': entry.dict(),
'entry': entry.dict(),
}
)
raise RuntimeError(f'entry = {entry.dict()}')
Expand Down Expand Up @@ -619,7 +617,9 @@ class SqlEntryUnitOfWorkV2(SqlEntryUnitOfWork):
repository_type: str = 'sql_entries_v2'

def table_name(self) -> str:
return f"{self.name}_{self.entity_id.hex}"
u = ulid.from_uuid(self.entity_id)
random_part = u.randomness().str
return f"{self.name}_{random_part}"

# ===== Value objects =====
# class SqlEntryRepositorySettings(EntryRepositorySettings):
Expand Down

0 comments on commit 564c4e4

Please sign in to comment.