forked from piccolo-orm/piccolo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHANGES
1582 lines (1118 loc) · 47.1 KB
/
CHANGES
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Changes
=======
0.57.0
------
Added Python 3.10 support (courtesy @kennethcheo).
-------------------------------------------------------------------------------
0.56.0
------
Fixed schema generation bug
~~~~~~~~~~~~~~~~~~~~~~~~~~~
When using ``piccolo schema generate`` to auto generate Piccolo ``Table``
classes from an existing database, it would fail in this situation:
* A table has a column with an index.
* The column name clashed with a Postgres type.
For example, we couldn't auto generate this ``Table`` class:
.. code-block:: python
class MyTable(Table):
time = Timestamp(index=True)
This is because ``time`` is a builtin Postgres type, and the ``CREATE INDEX``
statement being inspected in the database wrapped the column name in quotes,
which broke our regex.
Thanks to @knguyen5 for fixing this.
Improved testing docs
~~~~~~~~~~~~~~~~~~~~~
A convenience method called ``get_table_classes`` was added to ``Finder``.
``Finder`` is the main class in Piccolo for dynamically importing projects /
apps / tables / migrations etc.
``get_table_classes`` lets us easily get the ``Table`` classes for a project.
This makes writing unit tests easier, when we need to setup a schema.
.. code-block:: python
from unittest import TestCase
from piccolo.table import create_tables, drop_tables
from piccolo.conf.apps import Finder
TABLES = Finder().get_table_classes()
class TestApp(TestCase):
def setUp(self):
create_tables(*TABLES)
def tearDown(self):
drop_tables(*TABLES)
def test_app(self):
# Do some testing ...
pass
The docs were updated to reflect this.
When dropping tables in a unit test, remember to use ``piccolo tester run``, to
make sure the test database is used.
get_output_schema
~~~~~~~~~~~~~~~~~
``get_output_schema`` is the main entrypoint for database reflection in
Piccolo. It has been modified to accept an optional ``Engine`` argument, which
makes it more flexible.
-------------------------------------------------------------------------------
0.55.0
------
Table._meta.refresh_db
~~~~~~~~~~~~~~~~~~~~~~
Added the ability to refresh the database engine.
.. code-block:: python
MyTable._meta.refresh_db()
This causes the ``Table`` to fetch the ``Engine`` again from your
``piccolo_conf.py`` file. The reason this is useful, is you might change the
``PICCOLO_CONF`` environment variable, and some ``Table`` classes have
already imported an engine. This is now used by the ``piccolo tester run``
command to ensure all ``Table`` classes have the correct engine.
ColumnMeta edge cases
~~~~~~~~~~~~~~~~~~~~~
Fixed an edge case where ``ColumnMeta`` couldn't be copied if it had extra
attributes added to it.
Improved column type conversion
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When running migrations which change column types, Piccolo now provides the
``USING`` clause to the ``ALTER COLUMN`` DDL statement, which makes it more
likely that type conversion will be successful.
For example, if there is an ``Integer`` column, and it's converted to a
``Varchar`` column, the migration will run fine. In the past, running this in
reverse would fail. Now Postgres will try and cast the values back to integers,
which makes reversing migrations more likely to succeed.
Added drop_tables
~~~~~~~~~~~~~~~~~
There is now a convenience function for dropping several tables in one go. If
the database doesn't support ``CASCADE``, then the tables are sorted based on
their ``ForeignKey`` columns, so they're dropped in the correct order. It all
runs inside a transaction.
.. code-block:: python
from piccolo.table import drop_tables
drop_tables(Band, Manager)
This is a useful tool in unit tests.
Index support in schema generation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When using ``piccolo schema generate``, Piccolo will now reflect the indexes
from the database into the generated ``Table`` classes. Thanks to @wmshort for
this.
-------------------------------------------------------------------------------
0.54.0
------
Added the ``db_column_name`` option to columns. This is for edge cases where
a legacy database is being used, with problematic column names. For example,
if a column is called ``class``, this clashes with a Python builtin, so the
following isn't possible:
.. code-block:: text
class MyTable(Table):
class = Varchar() # Syntax error!
You can now do the following:
.. code-block:: python
class MyTable(Table):
class_ = Varchar(db_column_name='class')
Here are some example queries using it:
.. code-block:: python
# Create - both work as expected
MyTable(class_='Test').save().run_sync()
MyTable.objects().create(class_='Test').run_sync()
# Objects
row = MyTable.objects().first().where(MyTable.class_ == 'Test').run_sync()
>>> row.class_
'Test'
# Select
>>> MyTable.select().first().where(MyTable.class_ == 'Test').run_sync()
{'id': 1, 'class': 'Test'}
-------------------------------------------------------------------------------
0.53.0
------
An internal code clean up (courtesy @yezz123).
Dramatically improved CLI appearance when running migrations (courtesy
@wmshort).
Added a runtime reflection feature, where ``Table`` classes can be generated
on the fly from existing database tables (courtesy @AliSayyah). This is useful
when dealing with very dynamic databases, where tables are frequently being
added / modified, so hard coding them in a ``tables.py`` is impractical. Also,
for exploring databases on the command line. It currently just supports
Postgres.
Here's an example:
.. code-block:: python
from piccolo.table_reflection import TableStorage
storage = TableStorage()
Band = await storage.get_table('band')
>>> await Band.select().run()
[{'id': 1, 'name': 'Pythonistas', 'manager': 1}, ...]
-------------------------------------------------------------------------------
0.52.0
------
Lots of improvements to ``piccolo schema generate``:
* Dramatically improved performance, by executing more queries in parallel
(courtesy @AliSayyah).
* If a table in the database has a foreign key to a table in another
schema, this will now work (courtesy @AliSayyah).
* The column defaults are now extracted from the database (courtesy @wmshort).
* The ``scale`` and ``precision`` values for ``Numeric`` / ``Decimal`` column
types are extracted from the database (courtesy @wmshort).
* The ``ON DELETE`` and ``ON UPDATE`` values for ``ForeignKey`` columns are
now extracted from the database (courtesy @wmshort).
Added ``BigSerial`` column type (courtesy @aliereno).
Added GitHub issue templates (courtesy @AbhijithGanesh).
-------------------------------------------------------------------------------
0.51.1
------
Fixing a bug with ``on_delete`` and ``on_update`` not being set correctly.
Thanks to @wmshort for discovering this.
-------------------------------------------------------------------------------
0.51.0
------
Modified ``create_pydantic_model``, so ``JSON`` and ``JSONB`` columns have a
``format`` attribute of ``'json'``. This will be used by Piccolo Admin for
improved JSON support. Courtesy @sinisaos.
Fixing a bug where the ``piccolo fixtures load`` command wasn't registered
with the Piccolo CLI.
-------------------------------------------------------------------------------
0.50.0
------
The ``where`` clause can now accept multiple arguments (courtesy @AliSayyah):
.. code-block:: python
Concert.select().where(
Concert.venue.name == 'Royal Albert Hall',
Concert.band_1.name == 'Pythonistas'
).run_sync()
It's another way of expressing `AND`. It's equivalent to both of these:
.. code-block:: python
Concert.select().where(
Concert.venue.name == 'Royal Albert Hall'
).where(
Concert.band_1.name == 'Pythonistas'
).run_sync()
Concert.select().where(
(Concert.venue.name == 'Royal Albert Hall') & (Concert.band_1.name == 'Pythonistas')
).run_sync()
Added a ``create`` method, which is an easier way of creating objects (courtesy
@AliSayyah).
.. code-block:: python
# This still works:
band = Band(name="C-Sharps", popularity=100)
band.save().run_sync()
# But now we can do it in a single line using `create`:
band = Band.objects().create(name="C-Sharps", popularity=100).run_sync()
Fixed a bug with ``piccolo schema generate`` where columns with unrecognised
column types were omitted from the output (courtesy @AliSayyah).
Added docs for the ``--trace`` argument, which can be used with Piccolo
commands to get a traceback if the command fails (courtesy @hipertracker).
Added ``DoublePrecision`` column type, which is similar to ``Real`` in that
it stores ``float`` values. However, those values are stored at greater
precision (courtesy @AliSayyah).
Improved ``AppRegistry``, so if a user only adds the app name (e.g. ``blog``),
instead of ``blog.piccolo_app``, it will now emit a warning, and will try to
import ``blog.piccolo_app`` (courtesy @aliereno).
-------------------------------------------------------------------------------
0.49.0
------
Fixed a bug with ``create_pydantic_model`` when used with a ``Decimal`` /
``Numeric`` column when no ``digits`` arguments was set (courtesy @AliSayyah).
Added the ``create_tables`` function, which accepts a sequence of ``Table``
subclasses, then sorts them based on their ``ForeignKey`` columns, and creates
them. This is really useful for people who aren't using migrations (for
example, when using Piccolo in a simple data science script). Courtesy
@AliSayyah.
.. code-block:: python
from piccolo.tables import create_tables
create_tables(Band, Manager, if_not_exists=True)
# Equivalent to:
Manager.create_table(if_not_exists=True).run_sync()
Band.create_table(if_not_exists=True).run_sync()
Fixed typos with the new fixtures app - sometimes it was referred to as
``fixture`` and other times ``fixtures``. It's now standardised as
``fixtures`` (courtesy @hipertracker).
-------------------------------------------------------------------------------
0.48.0
------
The ``piccolo user create`` command can now be used by passing in command line
arguments, instead of using the interactive prompt (courtesy @AliSayyah).
For example ``piccolo user create --username=bob ...``.
This is useful when you want to create users in a script.
-------------------------------------------------------------------------------
0.47.0
------
You can now use ``pip install piccolo[all]``, which will install all optional
requirements.
-------------------------------------------------------------------------------
0.46.0
------
Added the fixtures app. This is used to dump data from a database to a JSON
file, and then reload it again. It's useful for seeding a database with
essential data, whether that's a colleague setting up their local environment,
or deploying to production.
To create a fixture:
.. code-block:: bash
piccolo fixtures dump --apps=blog > fixture.json
To load a fixture:
.. code-block:: bash
piccolo fixtures load fixture.json
As part of this change, Piccolo's Pydantic support was brought into this
library (prior to this it only existed within the ``piccolo_api`` library). At
a later date, the ``piccolo_api`` library will be updated, so it's Pydantic
code just proxies to what's within the main ``piccolo`` library.
-------------------------------------------------------------------------------
0.45.1
------
Improvements to ``piccolo schema generate``. It's now smarter about which
imports to include. Also, the ``Table`` classes output will now be sorted based
on their ``ForeignKey`` columns. Internally the sorting algorithm has been
changed to use the ``graphlib`` module, which was added in Python 3.9.
-------------------------------------------------------------------------------
0.45.0
------
Added the ``piccolo schema graph`` command for visualising your database
structure, which outputs a Graphviz file. It can then be turned into an
image, for example:
.. code-block:: bash
piccolo schema map | dot -Tpdf -o graph.pdf
Also made some minor changes to the ASGI templates, to reduce MyPy errors.
-------------------------------------------------------------------------------
0.44.1
------
Updated ``to_dict`` so it works with nested objects, as introduced by the
``prefetch`` functionality.
For example:
.. code-block:: python
band = Band.objects(Band.manager).first().run_sync()
>>> band.to_dict()
{'id': 1, 'name': 'Pythonistas', 'manager': {'id': 1, 'name': 'Guido'}}
It also works with filtering:
.. code-block:: python
>>> band.to_dict(Band.name, Band.manager.name)
{'name': 'Pythonistas', 'manager': {'name': 'Guido'}}
-------------------------------------------------------------------------------
0.44.0
------
Added the ability to prefetch related objects. Here's an example:
.. code-block:: python
band = await Band.objects(Band.manager).run()
>>> band.manager
<Manager: 1>
If a table has a lot of ``ForeignKey`` columns, there's a useful shortcut,
which will return all of the related rows as objects.
.. code-block:: python
concert = await Concert.objects(Concert.all_related()).run()
>>> concert.band_1
<Band: 1>
>>> concert.band_2
<Band: 2>
>>> concert.venue
<Venue: 1>
Thanks to @wmshort for all the input.
-------------------------------------------------------------------------------
0.43.0
------
Migrations containing ``Array``, ``JSON`` and ``JSONB`` columns should be
more reliable now. More unit tests were added to cover edge cases.
-------------------------------------------------------------------------------
0.42.0
------
You can now use ``all_columns`` at the root. For example:
.. code-block:: python
await Band.select(
Band.all_columns(),
Band.manager.all_columns()
).run()
You can also exclude certain columns if you like:
.. code-block:: python
await Band.select(
Band.all_columns(exclude=[Band.id]),
Band.manager.all_columns(exclude=[Band.manager.id])
).run()
-------------------------------------------------------------------------------
0.41.1
------
Fix a regression where if multiple tables are created in a single migration
file, it could potentially fail by applying them in the wrong order.
-------------------------------------------------------------------------------
0.41.0
------
Fixed a bug where if ``all_columns`` was used two or more levels deep, it would
fail. Thanks to @wmshort for reporting this issue.
Here's an example:
.. code-block:: python
Concert.select(
Concert.venue.name,
*Concert.band_1.manager.all_columns()
).run_sync()
Also, the ``ColumnsDelegate`` has now been tweaked, so unpacking of
``all_columns`` is optional.
.. code-block:: python
# This now works the same as the code above (we have omitted the *)
Concert.select(
Concert.venue.name,
Concert.band_1.manager.all_columns()
).run_sync()
-------------------------------------------------------------------------------
0.40.1
------
Loosen the ``typing-extensions`` requirement, as it was causing issues when
installing ``asyncpg``.
-------------------------------------------------------------------------------
0.40.0
------
Added ``nested`` output option, which makes the response from a ``select``
query use nested dictionaries:
.. code-block:: python
>>> await Band.select(Band.name, *Band.manager.all_columns()).output(nested=True).run()
[{'name': 'Pythonistas', 'manager': {'id': 1, 'name': 'Guido'}}]
Thanks to @wmshort for the idea.
-------------------------------------------------------------------------------
0.39.0
------
Added ``to_dict`` method to ``Table``.
If you just use ``__dict__`` on a ``Table`` instance, you get some non-column
values. By using ``to_dict`` it's just the column values. Here's an example:
.. code-block:: python
class MyTable(Table):
name = Varchar()
instance = MyTable.objects().first().run_sync()
>>> instance.__dict__
{'_exists_in_db': True, 'id': 1, 'name': 'foo'}
>>> instance.to_dict()
{'id': 1, 'name': 'foo'}
Thanks to @wmshort for the idea, and @aminalaee and @sinisaos for investigating
edge cases.
-------------------------------------------------------------------------------
0.38.2
------
Removed problematic type hint which assumed pytest was installed.
-------------------------------------------------------------------------------
0.38.1
------
Minor changes to ``get_or_create`` to make sure it handles joins correctly.
.. code-block:: python
instance = (
Band.objects()
.get_or_create(
(Band.name == "My new band")
& (Band.manager.name == "Excellent manager")
)
.run_sync()
)
In this situation, there are two columns called ``name`` - we need to make sure
the correct value is applied if the row doesn't exist.
-------------------------------------------------------------------------------
0.38.0
------
``get_or_create`` now supports more complex where clauses. For example:
.. code-block:: python
row = await Band.objects().get_or_create(
(Band.name == 'Pythonistas') & (Band.popularity == 1000)
).run()
And you can find out whether the row was created or not using
``row._was_created``.
Thanks to @wmshort for reporting this issue.
-------------------------------------------------------------------------------
0.37.0
------
Added ``ModelBuilder``, which can be used to generate data for tests (courtesy
@aminalaee).
-------------------------------------------------------------------------------
0.36.0
------
Fixed an issue where ``like`` and ``ilike`` clauses required a wildcard. For
example:
.. code-block:: python
await Manager.select().where(Manager.name.ilike('Guido%')).run()
You can now omit wildcards if you like:
.. code-block:: python
await Manager.select().where(Manager.name.ilike('Guido')).run()
Which would match on ``'guido'`` and ``'Guido'``, but not ``'Guidoxyz'``.
Thanks to @wmshort for reporting this issue.
-------------------------------------------------------------------------------
0.35.0
------
* Improved ``PrimaryKey`` deprecation warning (courtesy @tonybaloney).
* Added ``piccolo schema generate`` which creates a Piccolo schema from an
existing database.
* Added ``piccolo tester run`` which is a wrapper around pytest, and
temporarily sets ``PICCOLO_CONF``, so a test database is used.
* Added the ``get`` convenience method (courtesy @aminalaee). It returns the
first matching record, or ``None`` if there's no match. For example:
.. code-block:: python
manager = await Manager.objects().get(Manager.name == 'Guido').run()
# This is equivalent to:
manager = await Manager.objects().where(Manager.name == 'Guido').first().run()
-------------------------------------------------------------------------------
0.34.0
------
Added the ``get_or_create`` convenience method (courtesy @aminalaee). Example
usage:
.. code-block:: python
manager = await Manager.objects().get_or_create(
Manager.name == 'Guido'
).run()
-------------------------------------------------------------------------------
0.33.1
------
* Bug fix, where ``compare_dicts`` was failing in migrations if any ``Column``
had an unhashable type as an argument. For example: ``Array(default=[])``.
Thanks to @hipertracker for reporting this problem.
* Increased the minimum version of orjson, so binaries are available for Macs
running on Apple silicon (courtesy @hipertracker).
-------------------------------------------------------------------------------
0.33.0
------
Fix for auto migrations when using custom primary keys (thanks to @adriangb and
@aminalaee for investigating this issue).
-------------------------------------------------------------------------------
0.32.0
------
Migrations can now have a description, which is shown when using
``piccolo migrations check``. This makes migrations easier to identify (thanks
to @davidolrik for the idea).
-------------------------------------------------------------------------------
0.31.0
------
Added an ``all_columns`` method, to make it easier to retrieve all related
columns when doing a join. For example:
.. code-block:: python
await Band.select(Band.name, *Band.manager.all_columns()).first().run()
Changed the instructions for installing additional dependencies, so they're
wrapped in quotes, to make sure it works on ZSH (i.e.
``pip install 'piccolo[postgres]'`` instead of
``pip install piccolo[postgres]``).
-------------------------------------------------------------------------------
0.30.0
------
The database drivers are now installed separately. For example:
``pip install piccolo[postgres]`` (courtesy @aminalaee).
For some users this might be a **breaking change** - please make sure that for
existing Piccolo projects, you have either ``asyncpg``, or
``piccolo[postgres]`` in your ``requirements.txt`` file.
-------------------------------------------------------------------------------
0.29.0
------
The user can now specify the primary key column (courtesy @aminalaee). For
example:
.. code-block:: python
class RecordingStudio(Table):
pk = UUID(primary_key=True)
The BlackSheep template generated by `piccolo asgi new` now supports mounting
of the Piccolo Admin (courtesy @sinisaos).
-------------------------------------------------------------------------------
0.28.0
------
Added aggregations functions, such as ``Sum``, ``Min``, ``Max`` and ``Avg``,
for use in select queries (courtesy @sinisaos).
-------------------------------------------------------------------------------
0.27.0
------
Added uvloop as an optional dependency, installed via `pip install piccolo[uvloop]`
(courtesy @aminalaee). uvloop is a faster implementation of the asyncio event
loop found in Python's standard library. When uvloop is installed, Piccolo will
use it to increase the performance of the Piccolo CLI, and web servers such as
Uvicorn will use it to increase the performance of your ASGI app.
-------------------------------------------------------------------------------
0.26.0
------
Added ``eq`` and ``ne`` methods to the ``Boolean`` column, which can be used
if linters complain about using ``SomeTable.some_column == True``.
-------------------------------------------------------------------------------
0.25.0
------
* Changed the migration IDs, so the timestamp now includes microseconds. This
is to make clashing migration IDs much less likely.
* Added a lot of end-to-end tests for migrations, which revealed some bugs
in ``Column`` defaults.
-------------------------------------------------------------------------------
0.24.1
------
A bug fix for migrations. See `issue 123 <https://github.com/piccolo-orm/piccolo/issues/123>`_
for more information.
-------------------------------------------------------------------------------
0.24.0
------
Lots of improvements to ``JSON`` and ``JSONB`` columns. Piccolo will now
automatically convert between Python types and JSON strings. For example, with
this schema:
.. code-block:: python
class RecordingStudio(Table):
name = Varchar()
facilities = JSON()
We can now do the following:
.. code-block:: python
RecordingStudio(
name="Abbey Road",
facilities={'mixing_desk': True} # Will automatically be converted to a JSON string
).save().run_sync()
Similarly, when fetching data from a JSON column, Piccolo can now automatically
deserialise it.
.. code-block:: python
>>> RecordingStudio.select().output(load_json=True).run_sync()
[{'id': 1, 'name': 'Abbey Road', 'facilities': {'mixing_desk': True}]
>>> studio = RecordingStudio.objects().first().output(load_json=True).run_sync()
>>> studio.facilities
{'mixing_desk': True}
-------------------------------------------------------------------------------
0.23.0
------
Added the ``create_table_class`` function, which can be used to create
``Table`` subclasses at runtime. This was required to fix an existing bug,
which was effecting migrations (see `issue 111 <https://github.com/piccolo-orm/piccolo/issues/111>`_
for more details).
-------------------------------------------------------------------------------
0.22.0
------
* An error is now raised if a user tries to create a Piccolo app using
``piccolo app new`` with the same name as a builtin Python module, as it
will cause strange bugs.
* Fixing a strange bug where using an expression such as
``Concert.band_1.manager.id`` in a query would cause an error. It only
happened if multiple joins were involved, and the last column in the chain
was ``id``.
* ``where`` clauses can now accept ``Table`` instances. For example:
``await Band.select().where(Band.manager == some_manager).run()``, instead
of having to explicity reference the ``id``.
-------------------------------------------------------------------------------
0.21.2
------
Fixing a bug with serialising ``Enum`` instances in migrations. For example:
``Varchar(default=Colour.red)``.
-------------------------------------------------------------------------------
0.21.1
------
Fix missing imports in FastAPI and Starlette app templates.
-------------------------------------------------------------------------------
0.21.0
------
* Added a ``freeze`` method to ``Query``.
* Added BlackSheep as an option to ``piccolo asgi new``.
-------------------------------------------------------------------------------
0.20.0
------
Added ``choices`` option to ``Column``.
-------------------------------------------------------------------------------
0.19.1
------
* Added ``piccolo user change_permissions`` command.
* Added aliases for CLI commands.
-------------------------------------------------------------------------------
0.19.0
------
Changes to the ``BaseUser`` table - added a ``superuser``, and ``last_login``
column. These are required for upgrades to Piccolo Admin.
If you're using migrations, then running ``piccolo migrations forwards all``
should add these new columns for you.
If not using migrations, the ``BaseUser`` table can be upgraded using the
following DDL statements:
.. code-block:: sql
ALTER TABLE piccolo_user ADD COLUMN "superuser" BOOLEAN NOT NULL DEFAULT false
ALTER TABLE piccolo_user ADD COLUMN "last_login" TIMESTAMP DEFAULT null
-------------------------------------------------------------------------------
0.18.4
------
* Fixed a bug when multiple tables inherit from the same mixin (thanks to
@brnosouza).
* Added a ``log_queries`` option to ``PostgresEngine``, which is useful during
debugging.
* Added the `inflection` library for converting ``Table`` class names to
database table names. Previously, a class called ``TableA`` would wrongly
have a table called ``table`` instead of ``table_a``.
* Fixed a bug with ``SerialisedBuiltin.__hash__`` not returning a number,
which could break migrations (thanks to @sinisaos).
-------------------------------------------------------------------------------
0.18.3
------
Improved ``Array`` column serialisation - needed to fix auto migrations.
-------------------------------------------------------------------------------
0.18.2
------
Added support for filtering ``Array`` columns.
-------------------------------------------------------------------------------
0.18.1
------
Add the ``Array`` column type as a top level import in ``piccolo.columns``.
-------------------------------------------------------------------------------
0.18.0
------
* Refactored ``forwards`` and ``backwards`` commands for migrations, to make
them easier to run programatically.
* Added a simple ``Array`` column type.
* ``table_finder`` now works if just a string is passed in, instead of having
to pass in an array of strings.
-------------------------------------------------------------------------------
0.17.5
------
Catching database connection exceptions when starting the default ASGI app
created with ``piccolo asgi new`` - these errors exist if the Postgres
database hasn't been created yet.
-------------------------------------------------------------------------------
0.17.4
------
Added a ``help_text`` option to the ``Table`` metaclass. This is used in
Piccolo Admin to show tooltips.
-------------------------------------------------------------------------------
0.17.3
------
Added a ``help_text`` option to the ``Column`` constructor. This is used in
Piccolo Admin to show tooltips.
-------------------------------------------------------------------------------
0.17.2
------
* Exposing ``index_type`` in the ``Column`` constructor.
* Fixing a typo with ``start_connection_pool` and ``close_connection_pool`` -
thanks to paolodina for finding this.
* Fixing a typo in the ``PostgresEngine`` docs - courtesy of paolodina.
-------------------------------------------------------------------------------
0.17.1
------
Fixing a bug with ``SchemaSnapshot`` if column types were changed in migrations
- the snapshot didn't reflect the changes.
-------------------------------------------------------------------------------
0.17.0
------
* Migrations now directly import ``Column`` classes - this allows users to
create custom ``Column`` subclasses. Migrations previously only worked with
the builtin column types.
* Migrations now detect if the column type has changed, and will try and
convert it automatically.
-------------------------------------------------------------------------------
0.16.5
------
The Postgres extensions that ``PostgresEngine`` tries to enable at startup
can now be configured.
-------------------------------------------------------------------------------
0.16.4
------
* Fixed a bug with ``MyTable.column != None``
* Added ``is_null`` and ``is_not_null`` methods, to avoid linting issues when
comparing with None.
-------------------------------------------------------------------------------
0.16.3
------
* Added ``WhereRaw``, so raw SQL can be used in where clauses.
* ``piccolo shell run`` now uses syntax highlighting - courtesy of Fingel.
-------------------------------------------------------------------------------
0.16.2
------
Reordering the dependencies in requirements.txt when using ``piccolo asgi new``
as the latest FastAPI and Starlette versions are incompatible.
-------------------------------------------------------------------------------
0.16.1
------
Added ``Timestamptz`` column type, for storing datetimes which are timezone
aware.
-------------------------------------------------------------------------------
0.16.0
------
* Fixed a bug with creating a ``ForeignKey`` column with ``references="self"``
in auto migrations.