Skip to content

Commit 2dd6c08

Browse files
committed
delete tweaks
1 parent 2c26744 commit 2dd6c08

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

aragorm/columns/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ def __gt__(self, value) -> Where:
6363
def __ge__(self, value) -> Where:
6464
return Where(column=self, value=value, operator=GreaterEqualThan)
6565

66-
def __eq__(self, value) -> Where:
66+
def __eq__(self, value) -> Where: # type: ignore
6767
return Where(column=self, value=value, operator=Equal)
6868

69-
def __ne__(self, value) -> Where:
69+
def __ne__(self, value) -> Where: # type: ignore
7070
return Where(column=self, value=value, operator=NotEqual)
7171

7272
def __str__(self):

aragorm/query/query_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Select(
2727
OutputMixin,
2828
WhereMixin,
2929
):
30-
def __init__(self, table: 'Table', column_names: t.List[str]) -> None:
30+
def __init__(self, table: 'Table', column_names: t.Iterable[str]) -> None:
3131
self.column_names = column_names
3232
super().__init__(table=table, base='')
3333

aragorm/table.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ class Database(object):
2424
async def run(*queries):
2525
"""
2626
Use asyncio.gather here ...
27+
28+
I think I'll call it Engine instead ...
2729
"""
2830
pass
2931

@@ -110,14 +112,19 @@ def save(self):
110112
else:
111113
return cls.insert().add(self)
112114

113-
def delete(self):
115+
def remove(self):
114116
"""
115117
A proxy to a delete query.
116118
"""
117-
if type(self.id) != int:
119+
_id = self.id
120+
121+
if type(_id) != int:
118122
raise ValueError('Can only delete pre-existing rows with an id.')
123+
124+
self.id = None
125+
119126
return self.__class__.delete().where(
120-
self.__class__.id == self.id
127+
self.__class__.id == _id
121128
)
122129

123130
def get_related(self):
@@ -255,7 +262,7 @@ def update(cls, **columns) -> Update:
255262
)
256263

257264
@classmethod
258-
def delete(cls, **columns) -> Delete:
265+
def delete(cls) -> Delete:
259266
"""
260267
await Pokemon.delete().where(Pokemon.name='weedle').run()
261268

tests/table/test_join.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
from ..example_project.tables import Pokemon, Stadium, Match
44

55

6-
# class TestCreateJoin():
6+
class TestCreateJoin():
77

8-
# def test_create_join(self):
8+
def test_create_join(self):
99

10-
# Pokemon.create().run_sync()
11-
# Stadium.create().run_sync()
12-
# Match.create().run_sync()
10+
Pokemon.create().run_sync()
11+
Stadium.create().run_sync()
12+
Match.create().run_sync()
1313

14-
# Match.drop().run_sync()
15-
# Pokemon.drop().run_sync()
16-
# Stadium.drop().run_sync()
14+
Match.drop().run_sync()
15+
Pokemon.drop().run_sync()
16+
Stadium.drop().run_sync()
1717

1818

1919
class TestJoin(TestCase):
@@ -59,7 +59,6 @@ def test_join(self):
5959
response = select_query.run_sync()
6060
print(response)
6161

62-
6362
# def _test_ref(self):
6463
# """
6564
# Match.select().count().where(

0 commit comments

Comments
 (0)