default attributes on db object are now queries
This commit is contained in:
parent
12c643c542
commit
5ec27e9344
|
@ -85,10 +85,7 @@ class SQLDatabaseManager:
|
||||||
return json.dumps(results, indent=2, cls=AlchemyEncoder)
|
return json.dumps(results, indent=2, cls=AlchemyEncoder)
|
||||||
|
|
||||||
def __getattr__(self, name: str):
|
def __getattr__(self, name: str):
|
||||||
try:
|
return self.query(getattr(ttfrog.db.schema, name))
|
||||||
return self.tables[name]
|
|
||||||
except KeyError:
|
|
||||||
raise AttributeError(f"{self} does not contain the attribute '{name}'.")
|
|
||||||
|
|
||||||
|
|
||||||
db = SQLDatabaseManager()
|
db = SQLDatabaseManager()
|
||||||
|
|
|
@ -8,7 +8,7 @@ def test_manage_character(db, classes_factory, ancestries_factory):
|
||||||
# load the fixtures so they are bound to the current session
|
# load the fixtures so they are bound to the current session
|
||||||
classes = classes_factory()
|
classes = classes_factory()
|
||||||
ancestries = ancestries_factory()
|
ancestries = ancestries_factory()
|
||||||
darkvision = db.session.query(schema.AncestryTrait).filter_by(name="Darkvision")[0]
|
darkvision = db.AncestryTrait.filter_by(name="Darkvision")[0]
|
||||||
|
|
||||||
# create a human character (the default)
|
# create a human character (the default)
|
||||||
char = schema.Character(name="Test Character")
|
char = schema.Character(name="Test Character")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user