Skip to content

Releases: piccolo-orm/piccolo

1.5.0

22 Mar 16:59
Compare
Choose a tag to compare

Lots of internal improvements, mostly to support new functionality in Piccolo Admin.

  • docs: Update code example of prefetching related objects by @jrycw in #952
  • 953 Add array_columns to Table._meta by @dantownsend in #954
  • 955 Add a method to the Array column for getting the number of dimensions of the array by @dantownsend in #956
  • 962 Make it clearer how multiple where clauses work in the docs by @dantownsend in #963
  • 964 Remove banner from docs saying about Piccolo v1 by @dantownsend in #965
  • 966 Bump black version by @dantownsend in #967
  • add a unique argument to the column extra by @sinisaos in #968
  • 969 Add a utility method for getting the innermost type of an Array column by @dantownsend in #970
  • update readme for Esmerald by @sinisaos in #972

New Contributors

Full Changelog: 1.4.2...1.5.0

1.4.2

13 Mar 01:07
Compare
Choose a tag to compare

Improved how ModelBuilder handles recursive foreign keys.

1.4.1

12 Mar 22:15
Compare
Choose a tag to compare

Fixed an edge case with auto migrations.

If starting from a table like this, with a custom primary key column:

class MyTable(Table):
    id = UUID(primary_key=True)

When a foreign key is added to the table which references itself:

class MyTable(Table):
    id = UUID(primary_key=True)
    fk = ForeignKey("self")

The auto migrations could fail in some situations.

1.4.0

11 Mar 21:55
Compare
Choose a tag to compare

Improved how create_pydantic_model handles Array columns:

  • Multidimensional arrays (e.g. Array(Array(Integer))) have more accurate types.
  • Array(Email()) now validates that each item in the list is an email address.
  • Array(Varchar(length=10)) now validates that each item is the correct length (i.e. 10 in this example).

Other changes

Some Pylance errors were fixed in the codebase.

1.3.2

04 Mar 12:04
Compare
Choose a tag to compare

Fixed a bug with nested array columns containing BigInt. For example:

class MyTable(Table):
    my_column = Array(Array(BigInt))

Thanks to @AmazingAkai for reporting this issue.

1.3.1

25 Feb 22:42
Compare
Choose a tag to compare

Fixed a bug with foreign keys which reference BigSerial primary keys. Thanks to @Abdelhadi92 for reporting this issue.

1.3.0

23 Jan 23:06
Compare
Choose a tag to compare

Added the piccolo user list command - a quick and convenient way of listing Piccolo Admin users from the command line.

ModelBuilder now creates timezone aware datetime objects for Timestamptz columns.

Updated the ASGI templates.

SQLite auto migrations are now allowed. We used to raise an exception, but now we output a warning instead. While SQLite auto migrations aren't as feature rich as Postgres, they work fine for simple use cases.

1.2.0

23 Dec 12:41
Compare
Choose a tag to compare

There's now an alternative syntax for joins, which works really well with static type checkers like Mypy and Pylance.

The traditional syntax (which continues to work as before):

# Get the band name, and the manager's name from a related table
await Band.select(Band.name, Band.manager.name)

The alternative syntax is as follows:

await Band.select(Band.name, Band.manager._.name)

Note how we use ._. instead of . after a ForeignKey.

This offers a considerably better static typing experience. In the above example, type checkers know that Band.manager._.name refers to the name column on the Manager table. This means typos can be detected, and code navigation is easier.

Other changes

  • Improve static typing for get_related.
  • Added support for the esmerald ASGI framework.

1.1.1

10 Nov 17:30
Compare
Choose a tag to compare

Piccolo allows the user to specify savepoint names which are used in transactions. For example:

async with DB.transaction() as transaction:
    await Band.insert(Band(name='Pythonistas'))

    # Passing in a savepoint name is optional:
    savepoint_1 = await transaction.savepoint('savepoint_1')

    await Band.insert(Band(name='Terrible band'))

    # Oops, I made a mistake!
    await savepoint_1.rollback_to()

Postgres doesn't allow us to parameterise savepoint names, which means there's a small chance of SQL injection, if for some reason the savepoint names were generated from end-user input. Even though the likelihood is very low, it's best to be safe. We now validate the savepoint name, to make sure it can only contain certain safe characters. Thanks to @Skelmis for making this change.

1.1.0

03 Nov 15:11
Compare
Choose a tag to compare

Added support for Python 3.12.

Modified create_pydantic_model, so additional information is returned in the JSON schema to distinguish between Timestamp and Timestamptz columns. This will be used for future Piccolo Admin enhancements.