When creating DDL statements, you can't parameterise them - you can only pass a string to the database.
This means we have to stringify some values in Piccolo (most notably column defaults).
For example:
def get_default():
return [datetime.time(hour=8, minute=0)]
class MyTable(Table):
times = Array(Time(), default=get_default)
To create this table, we need the following DDL statement:
CREATE TABLE "my_table" ("id" SERIAL PRIMARY KEY NOT NULL, "times" TIME[] NOT NULL DEFAULT '{"08:00:00"}';
Note how we had to serialise [datetime.time(hour=8, minute=0)] to '{"08:00:00"}'. This is where we have some issues at the moment - certain types of arrays aren't serialising correctly (e.g. nested arrays).
When creating DDL statements, you can't parameterise them - you can only pass a string to the database.
This means we have to stringify some values in Piccolo (most notably column defaults).
For example:
To create this table, we need the following DDL statement:
Note how we had to serialise
[datetime.time(hour=8, minute=0)]
to'{"08:00:00"}'
. This is where we have some issues at the moment - certain types of arrays aren't serialising correctly (e.g. nested arrays).