Skip to content

Commit c1fd0ae

Browse files
committed
Not using Pokemon examples anymore
1 parent f41467e commit c1fd0ae

23 files changed

+155
-155
lines changed

docs/src/piccolo/design-decisions.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ At any time you can access the __str__ method of a query, to see the underlying
2424

2525
.. code-block:: python
2626
27-
query = Pokemon.select('name').where(Pokemon.power >= 100)
27+
query = Band.select('name').where(Band.power >= 100)
2828
2929
print(query)
30-
'SELECT name from pokemon where power > 100'
30+
'SELECT name from band where power > 100'

docs/src/piccolo/transactions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Usage
1111

1212
.. code-block:: python
1313
14-
transaction = Pokemon.Meta.db.transaction()
14+
transaction = Band.Meta.db.transaction()
1515
transaction.add(Trainer.create())
1616
transaction.add(Match.create())
1717
await transaction.run()

piccolo/columns/column_types.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,32 @@ class ForeignKey(Integer):
7575
7676
http://www.postgresqltutorial.com/postgresql-foreign-key/
7777
78-
some_pokemon.trainer
78+
some_band.trainer
7979
>>> 1
80-
Pokemon.select('name', 'trainer.name')
80+
Band.select('name', 'trainer.name')
8181
8282
I'm not sure about explicit joins ... only useful if we want to specify
8383
inner and outer joins.
8484
85-
Join(Pokemon, User)
85+
Join(Band, User)
8686
8787
To get the actual User object.
8888
89-
User.object().where(User.id == some_pokemon.trainer)
89+
User.object().where(User.id == some_band.trainer)
9090
9191
OR
9292
93-
some_pokemon.related_object('trainer')
93+
some_band.related_object('trainer')
9494
> is just a proxy to the above
9595
96-
class Pokemon(Table):
96+
class Band(Table):
9797
trainer = ForeignKey(User)
9898
9999
To change the trainer:
100-
some_pokemon.trainer = some_trainer_id
101-
some_pokemon.save()
100+
some_band.trainer = some_trainer_id
101+
some_band.save()
102102
Or:
103-
some_pokemon.set_related_object('trainer', some_trainer)
103+
some_band.set_related_object('trainer', some_trainer)
104104
105105
"""
106106

piccolo/query/methods/alter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@dataclasses.dataclass
88
class Rename():
99
"""
10-
Pokemon.alter().rename(Pokemon.power, ‘rating’)
10+
Band.alter().rename(Band.power, ‘rating’)
1111
"""
1212
column: Column
1313
new_name: str
@@ -19,7 +19,7 @@ def __str__(self):
1919
@dataclasses.dataclass
2020
class Drop():
2121
"""
22-
Pokemon.alter().drop('power')
22+
Band.alter().drop('power')
2323
"""
2424
column: Column
2525

@@ -30,7 +30,7 @@ def __str__(self):
3030
@dataclasses.dataclass
3131
class Add():
3232
"""
33-
Pokemon.alter().add(‘color’, Varchar(length=20))
33+
Band.alter().add(‘color’, Varchar(length=20))
3434
"""
3535
name: str
3636
column: Column

piccolo/table.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def remove(self):
120120

121121
def get_related(self, column_name: str):
122122
"""
123-
some_pokemon.get_related('trainer')
123+
some_band.get_related('trainer')
124124
"""
125125
cls = self.__class__
126126

@@ -204,8 +204,8 @@ def select(cls, *column_names: str) -> Select:
204204
@classmethod
205205
def insert(cls, *rows: 'Table') -> Insert:
206206
"""
207-
await Pokemon.insert(
208-
Pokemon(name="jigglypuff", power=500, trainer="florence")
207+
await Band.insert(
208+
Band(name="jigglypuff", power=500, trainer="florence")
209209
).run()
210210
"""
211211
query = Insert(
@@ -218,8 +218,8 @@ def insert(cls, *rows: 'Table') -> Insert:
218218
@classmethod
219219
def update(cls, **columns) -> Update:
220220
"""
221-
await Pokemon.update(name='raichu').where(
222-
Pokemon.name='pikachu'
221+
await Band.update(name='raichu').where(
222+
Band.name='pikachu'
223223
).run()
224224
"""
225225
columns_str = ', '.join([
@@ -235,7 +235,7 @@ def update(cls, **columns) -> Update:
235235
@classmethod
236236
def delete(cls) -> Delete:
237237
"""
238-
await Pokemon.delete().where(Pokemon.name == 'weedle').run()
238+
await Band.delete().where(Band.name == 'weedle').run()
239239
"""
240240
return Delete(
241241
table=cls
@@ -246,7 +246,7 @@ def create(cls) -> Create:
246246
"""
247247
Create table, along with all columns.
248248
249-
await Pokemon.create().run()
249+
await Band.create().run()
250250
"""
251251
return Create(
252252
table=cls,
@@ -257,7 +257,7 @@ def create_without_columns(cls) -> Raw:
257257
"""
258258
Create the table, but with no columns (useful for migrations).
259259
260-
await Pokemon.create().run()
260+
await Band.create().run()
261261
"""
262262
return Raw(
263263
table=cls,
@@ -269,7 +269,7 @@ def drop(cls) -> Drop:
269269
"""
270270
Drops the table.
271271
272-
await Pokemon.drop().run()
272+
await Band.drop().run()
273273
"""
274274
return Drop(
275275
table=cls,
@@ -278,7 +278,7 @@ def drop(cls) -> Drop:
278278
@classmethod
279279
def raw(cls, sql: str) -> Raw:
280280
"""
281-
await Pokemon.raw('select * from foo')
281+
await Band.raw('select * from foo')
282282
"""
283283
return Raw(
284284
table=cls,
@@ -288,7 +288,7 @@ def raw(cls, sql: str) -> Raw:
288288
@classmethod
289289
def alter(cls) -> Alter:
290290
"""
291-
await Pokemon.alter().rename(Pokemon.power, 'rating')
291+
await Band.alter().rename(Band.power, 'rating')
292292
"""
293293
return Alter(
294294
table=cls,

tests/base.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33

44
import asyncpg
55

6-
from .example_project.tables import Pokemon
6+
from .example_project.tables import Band
77

88

99
class DBTestCase(TestCase):
1010

1111
def run_sync(self, query):
1212
async def _run():
13-
connection = await asyncpg.connect(**Pokemon.Meta.db.config)
13+
connection = await asyncpg.connect(**Band.Meta.db.config)
1414
await connection.execute(query)
1515
await connection.close()
1616

1717
asyncio.run(_run())
1818

1919
def create_table(self):
2020
self.run_sync('''
21-
CREATE TABLE pokemon (
21+
CREATE TABLE band (
2222
id SERIAL PRIMARY KEY,
2323
name VARCHAR(50),
2424
trainer VARCHAR(20),
@@ -27,7 +27,7 @@ def create_table(self):
2727

2828
def insert_row(self):
2929
self.run_sync('''
30-
INSERT INTO pokemon (
30+
INSERT INTO band (
3131
name,
3232
trainer,
3333
power
@@ -39,7 +39,7 @@ def insert_row(self):
3939

4040
def insert_rows(self):
4141
self.run_sync('''
42-
INSERT INTO pokemon (
42+
INSERT INTO band (
4343
name,
4444
trainer,
4545
power
@@ -58,7 +58,7 @@ def insert_rows(self):
5858
);''')
5959

6060
def drop_table(self):
61-
self.run_sync('DROP TABLE pokemon;')
61+
self.run_sync('DROP TABLE band;')
6262

6363
def setUp(self):
6464
self.create_table()

tests/engine/test_transaction.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest import TestCase
22

3-
from ..example_project.tables import Pokemon, Trainer
3+
from ..example_project.tables import Band, Trainer
44

55

66
class TestTransaction(TestCase):
@@ -9,40 +9,40 @@ def test_error(self):
99
"""
1010
Make sure queries in a transaction aren't committed if a query fails.
1111
"""
12-
transaction = Pokemon.Meta.db.transaction()
12+
transaction = Band.Meta.db.transaction()
1313
transaction.add(
14-
Pokemon.create(),
14+
Band.create(),
1515
Trainer.create(),
16-
Pokemon.raw('MALFORMED QUERY ... SHOULD ERROR')
16+
Band.raw('MALFORMED QUERY ... SHOULD ERROR')
1717
)
1818
try:
1919
transaction.run_sync()
2020
except Exception as error:
2121
pass
2222
self.assertTrue(
23-
not Pokemon.table_exists().run_sync()
23+
not Band.table_exists().run_sync()
2424
)
2525
self.assertTrue(
2626
not Trainer.table_exists().run_sync()
2727
)
2828

2929
def test_succeeds(self):
30-
transaction = Pokemon.Meta.db.transaction()
30+
transaction = Band.Meta.db.transaction()
3131
transaction.add(
32-
Pokemon.create(),
32+
Band.create(),
3333
Trainer.create()
3434
)
3535
transaction.run_sync()
3636

3737
self.assertTrue(
38-
Pokemon.table_exists().run_sync()
38+
Band.table_exists().run_sync()
3939
)
4040
self.assertTrue(
4141
Trainer.table_exists().run_sync()
4242
)
4343

4444
transaction.add(
45-
Pokemon.drop(),
45+
Band.drop(),
4646
Trainer.drop()
4747
)
4848
transaction.run_sync()

tests/example_project/tables.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
###############################################################################
1515
# Simple example
1616

17-
class Pokemon(table.Table):
17+
class Band(table.Table):
1818
name = columns.Varchar(length=50)
1919
trainer = columns.Varchar(length=20)
2020
power = columns.Integer()
@@ -42,8 +42,8 @@ class Meta():
4242

4343

4444
class Match(table.Table):
45-
pokemon_1 = columns.ForeignKey(Pokemon)
46-
pokemon_2 = columns.ForeignKey(Pokemon)
45+
band_1 = columns.ForeignKey(Band)
46+
band_2 = columns.ForeignKey(Band)
4747
stadium = columns.ForeignKey(Stadium)
4848

4949
class Meta():
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
from tests.example_project.tables import Pokemon
1+
from tests.example_project.tables import Band
22
from tests.base import DBTestCase
33

44

55
class TestDelete(DBTestCase):
66

77
def setUp(self):
8-
Pokemon.create().run_sync()
8+
Band.create().run_sync()
99

1010
def tearDown(self):
11-
Pokemon.drop().run_sync()
11+
Band.drop().run_sync()
1212

1313
def test_delete(self):
1414

15-
squirtle = Pokemon(
15+
squirtle = Band(
1616
name='squirtle',
1717
trainer='Misty',
1818
power=300
@@ -22,6 +22,6 @@ def test_delete(self):
2222
squirtle.remove().run_sync()
2323

2424
# how can I implement 'flat=True'
25-
# Pokemon.select('name').output(as_list=True).run_sync()
25+
# Band.select('name').output(as_list=True).run_sync()
2626
#
27-
Pokemon.select('name').run_sync()
27+
Band.select('name').run_sync()

tests/table/instance/test_get_related.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
from unittest import TestCase
22

3-
from tests.example_project.tables import Pokemon, Stadium, Match
3+
from tests.example_project.tables import Band, Stadium, Match
44

55

66
class TestGetRelated(TestCase):
77

88
def setUp(self):
9-
Pokemon.create().run_sync()
9+
Band.create().run_sync()
1010
Stadium.create().run_sync()
1111
Match.create().run_sync()
1212

1313
def tearDown(self):
1414
Match.drop().run_sync()
15-
Pokemon.drop().run_sync()
15+
Band.drop().run_sync()
1616
Stadium.drop().run_sync()
1717

1818
def test_get_related(self):
1919
"""
2020
Make sure you can get a related object from another object instance.
2121
"""
22-
pikachu = Pokemon(
22+
pikachu = Band(
2323
name='pikachu'
2424
)
2525
pikachu.save().run_sync()
2626

27-
squirtle = Pokemon(
27+
squirtle = Band(
2828
name='squirtle'
2929
)
3030
squirtle.save().run_sync()
@@ -35,8 +35,8 @@ def test_get_related(self):
3535
stadium.save().run_sync()
3636

3737
match = Match(
38-
pokemon_1=pikachu.id,
39-
pokemon_2=squirtle.id,
38+
band_1=pikachu.id,
39+
band_2=squirtle.id,
4040
stadium=stadium.id
4141
)
4242
match.save().run_sync()

0 commit comments

Comments
 (0)