Piccolo

Latest version: v1.12.0

Safety actively analyzes 639658 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 13 of 50

0.80.2

Not secure
------

Fixed a bug with ``Combination.__str__``, which meant that when printing out a
query for debugging purposes it was wasn't showing correctly (courtesy
destos).

-------------------------------------------------------------------------------

0.80.1

Not secure
------

Fixed a bug with Piccolo Admin and ``_get_related_readable``, which is used
to show a human friendly identifier for a row, rather than just the ID.

Thanks to ethagnawl and sinisaos for their help with this.

-------------------------------------------------------------------------------

0.80.0

Not secure
------

There was a bug when doing joins with a ``JSONB`` column with ``as_alias``.

.. code-block:: python

class User(Table, tablename="my_user"):
name = Varchar(length=120)
config = JSONB(default={})


class Subscriber(Table, tablename="subscriber"):
name = Varchar(length=120)
user = ForeignKey(references=User)


async def main():
This was failing:
await Subscriber.select(
Subscriber.name,
Subscriber.user.config.as_alias("config")
)

Thanks to Anton-Karpenko for reporting this issue.

Even though this is a bug fix, the minor version number has been bumped because
the fix resulted in some refactoring of Piccolo's internals, so is a fairly big
change.

-------------------------------------------------------------------------------

0.79.0

Not secure
------

Added a custom ``__repr__`` method to ``Table``'s metaclass. It's needed to
improve the appearance of our Sphinx docs. See
`issue 549 <https://github.com/piccolo-orm/piccolo/issues/549>`_ for more
details.

-------------------------------------------------------------------------------

0.78.0

Not secure
------

Added the ``callback`` clause to ``select`` and ``objects`` queries (courtesy
backwardspy). For example:

.. code-block:: python

>>> await Band.select().callback(my_callback)

The callback can be a normal function or async function, which is called when
the query is successful. The callback can be used to modify the query's output.

It allows for some interesting and powerful code. Here's a very simple example
where we modify the query's output:

.. code-block:: python

>>> def get_uppercase_names() -> Select:
... def make_uppercase(response):
... return [{'name': i['name'].upper()} for i in response]
...
... return Band.select(Band.name).callback(make_uppercase)

>>> await get_uppercase_names().where(Band.manager.name == 'Guido')
[{'name': 'PYTHONISTAS'}]

Here's another example, where we perform validation on the query's output:

.. code-block:: python

>>> def get_concerts() -> Select:
... def check_length(response):
... if len(response) == 0:
... raise ValueError('No concerts!')
... return response
...
... return Concert.select().callback(check_length)

>>> await get_concerts().where(Concert.band_1.name == 'Terrible Band')
ValueError: No concerts!

At the moment, callbacks are just triggered when a query is successful, but in
the future other callbacks will be added, to hook into more of Piccolo's
internals.

-------------------------------------------------------------------------------

0.77.0

Not secure
------

Added the ``refresh`` method. If you have an object which has gotten stale, and
want to refresh it, so it has the latest data from the database, you can now do
this:

.. code-block:: python

If we have an instance:
band = await Band.objects().first()

And it has gotten stale, we can refresh it:
await band.refresh()

Thanks to trondhindenes for suggesting this feature.

-------------------------------------------------------------------------------

Page 13 of 50

Links

Releases

Has known vulnerabilities

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.