|
1 | 1 | Changes |
2 | 2 | ======= |
3 | 3 |
|
| 4 | +1.36.0 |
| 5 | +------ |
| 6 | + |
| 7 | +Advanced Constraints |
| 8 | +~~~~~~~~~~~~~~~~~~~~ |
| 9 | + |
| 10 | +Added support for composite unique constraints. Many thanks to @atkei for this. |
| 11 | + |
| 12 | +For example: |
| 13 | + |
| 14 | +.. code-block:: python |
| 15 | +
|
| 16 | + from piccolo.constraints import Unique |
| 17 | +
|
| 18 | + class Album(Table): |
| 19 | + name = Varchar() |
| 20 | + band = ForeignKey(Band) |
| 21 | +
|
| 22 | + unique_name_band = Unique([name, band]) |
| 23 | +
|
| 24 | +And check constraints: |
| 25 | + |
| 26 | +.. code-block:: python |
| 27 | +
|
| 28 | + from piccolo.constraints import Check |
| 29 | +
|
| 30 | + class Ticket(Table): |
| 31 | + price = Decimal() |
| 32 | +
|
| 33 | + check_price_positive = Check(price >= 0) |
| 34 | +
|
| 35 | +Replaced ``SelectRaw``, ``GroupByRaw`` and ``OrderByRaw`` with ``QueryString`` |
| 36 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 37 | + |
| 38 | +In certain situations we allow the user to modify Piccolo queries using |
| 39 | +custom SQL. This is for advanced situations not covered natively by the ORM. |
| 40 | + |
| 41 | +In the past we used custom classes for this - ``SelectRaw``, ``OrderByRaw`` |
| 42 | +etc. |
| 43 | + |
| 44 | +These classes still work, but you can now just pass in a ``QueryString`` |
| 45 | +instead (the building block of queries in Piccolo). |
| 46 | + |
| 47 | +.. code-block:: python |
| 48 | +
|
| 49 | + from piccolo.querystring import QueryString |
| 50 | +
|
| 51 | + await Band.select(Band.name).order_by( |
| 52 | + QueryString('random()'), |
| 53 | + ) |
| 54 | +
|
| 55 | +Other changes |
| 56 | +~~~~~~~~~~~~~ |
| 57 | + |
| 58 | +* Improved error messages when running migrations (thanks to @pctablet505 and |
| 59 | + @AnayGarodia for this). |
| 60 | +* Upgraded ``colorama``, so Piccolo works nicer with other libraries also |
| 61 | + using ``colorama`` (thanks to @laravioli for reporting this issue). |
| 62 | +* Fixed a bug using ``load_json`` and ``prefetch`` together, when the JSON |
| 63 | + column contains an array value (thanks to @Mekagojira8 for reporting this |
| 64 | + issue). |
| 65 | +* Fixed bugs with title case column names (thanks to @devzzzero for reporting |
| 66 | + this). |
| 67 | + |
| 68 | +------------------------------------------------------------------------------- |
| 69 | + |
4 | 70 | 1.35.0 |
5 | 71 | ------ |
6 | 72 |
|
@@ -68,6 +134,7 @@ Convert ``Timestamptz`` columns from UTC to another timezone: |
68 | 134 | Similar to ``Varchar`` - useful if the strings are a fixed width. |
69 | 135 |
|
70 | 136 | .. code-block:: python |
| 137 | +
|
71 | 138 | class Venue(Table): |
72 | 139 | country_code = Char(length=2) |
73 | 140 |
|
|
0 commit comments