piccolo 1.7.0__tar.gz → 1.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {piccolo-1.7.0 → piccolo-1.9.0}/PKG-INFO +1 -1
- piccolo-1.9.0/piccolo/__init__.py +1 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/base.py +59 -29
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/base.py +5 -3
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/functions/__init__.py +7 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/functions/aggregate.py +12 -12
- piccolo-1.9.0/piccolo/query/functions/math.py +48 -0
- piccolo-1.9.0/piccolo/query/functions/type_conversion.py +82 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/querystring.py +30 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/schema.py +2 -1
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/PKG-INFO +1 -1
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/SOURCES.txt +9 -1
- {piccolo-1.7.0 → piccolo-1.9.0}/pyproject.toml +2 -1
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/integration/test_migrations.py +28 -5
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_migration_manager.py +15 -15
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_array.py +63 -19
- piccolo-1.9.0/tests/columns/test_get_sql_value.py +66 -0
- piccolo-1.9.0/tests/query/functions/base.py +34 -0
- {piccolo-1.7.0/tests/query → piccolo-1.9.0/tests/query/functions}/test_functions.py +5 -43
- piccolo-1.9.0/tests/query/functions/test_math.py +39 -0
- piccolo-1.9.0/tests/query/functions/test_string.py +25 -0
- piccolo-1.9.0/tests/query/functions/test_type_conversion.py +134 -0
- piccolo-1.9.0/tests/query/test_querystring.py +166 -0
- piccolo-1.9.0/tests/utils/__init__.py +0 -0
- piccolo-1.7.0/piccolo/__init__.py +0 -1
- piccolo-1.7.0/tests/query/test_querystring.py +0 -30
- {piccolo-1.7.0 → piccolo-1.9.0}/LICENSE +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/README.md +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/commands/show_all.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/app/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_esmerald_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/load.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/meta/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/meta/commands/version.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/meta/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/operations.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/check.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/clean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/migrations/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/playground/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/playground/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/playground/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/playground/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/project/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/project/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/project/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/project/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/generate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/graph.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/schema/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/shell/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/shell/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/tester/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/tester/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/tester/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/tester/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/commands/change_password.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/commands/create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/commands/list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/apps/user/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/choices.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/column_types.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/combination.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/date.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/interval.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/time.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/timestamp.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/timestamptz.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/defaults/uuid.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/m2m.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/operators/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/operators/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/operators/comparison.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/operators/math.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/operators/string.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/columns/reference.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/conf/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/conf/apps.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/custom_types.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/cockroach.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/exceptions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/finder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/postgres.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/engine/sqlite.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/main.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/py.typed +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/functions/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/functions/string.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/alter.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/count.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/create_index.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/delete.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/drop_index.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/insert.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/raw.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/refresh.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/select.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/table_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/methods/update.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/mixins.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/query/proxy.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/table_reflection.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/testing/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/testing/model_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/testing/random_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/dictionary.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/encoding.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/graphlib/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/lazy_loader.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/naming.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/printing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/pydantic.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/repr.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/sql_values.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/sync.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo/utils/warnings.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/dependency_links.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/entry_points.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/requires.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/piccolo.egg-info/top_level.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/profiling/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/profiling/run_profile.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/setup.cfg +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/setup.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/app/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/app/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/app/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/app/commands/test_show_all.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/asgi/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/asgi/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/fixtures/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/meta/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/meta/commands/test_version.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_check.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_clean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/migrations/test_migration.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/project/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/project/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/project/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/schema/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/shell/commands/test_run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/tester/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/commands/test_change_password.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/commands/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/commands/test_list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/apps/user/test_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/m2m/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/m2m/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/m2m/test_m2m.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/m2m/test_m2m_schema.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_bigint.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_boolean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_bytea.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_choices.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_combination.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_date.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_db_column_name.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_defaults.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_double_precision.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_interval.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_json.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_jsonb.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_numeric.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_primary_key.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_real.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_reference.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_reserved_column_names.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_smallint.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_time.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_timestamp.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_timestamptz.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_uuid.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/columns/test_varchar.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/conf/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/conf/example.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/conf/test_apps.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_extra_nodes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_logging.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_nested_transaction.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_pool.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_transaction.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/engine/test_version_parsing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/mega/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/mega/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/music/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/music/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/music/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/example_apps/music/tables_detailed.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/__init__.py +0 -0
- {piccolo-1.7.0/tests/query/mixins → piccolo-1.9.0/tests/query/functions}/__init__.py +0 -0
- {piccolo-1.7.0/tests/table → piccolo-1.9.0/tests/query/mixins}/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/mixins/test_columns_delegate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/test_await.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/test_camelcase.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/test_freeze.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/test_gather.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/query/test_slots.py +0 -0
- {piccolo-1.7.0/tests/table/instance → piccolo-1.9.0/tests/table}/__init__.py +0 -0
- {piccolo-1.7.0/tests/testing → piccolo-1.9.0/tests/table/instance}/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_get_related.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_get_related_readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_instantiate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_remove.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_save.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/instance/test_to_dict.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_all_columns.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_alter.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_batch.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_callback.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_constructor.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_count.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_create_db_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_create_table_class.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_delete.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_drop_db_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_from_dict.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_inheritance.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_insert.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_join.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_join_on.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_metaclass.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_output.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_raw.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_ref.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_refresh.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_repr.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_select.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_str.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_table_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/table/test_update.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/test_main.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/test_schema.py +0 -0
- {piccolo-1.7.0/tests/utils → piccolo-1.9.0/tests/testing}/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/testing/test_model_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/testing/test_random_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_dictionary.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_encoding.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_lazy_loader.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_naming.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_printing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_pydantic.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_sql_values.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_sync.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_table_reflection.py +0 -0
- {piccolo-1.7.0 → piccolo-1.9.0}/tests/utils/test_warnings.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__VERSION__ = "1.9.0"
|
@@ -201,6 +201,10 @@ class ColumnMeta:
|
|
201
201
|
)
|
202
202
|
return self._table
|
203
203
|
|
204
|
+
@table.setter
|
205
|
+
def table(self, value: t.Type[Table]):
|
206
|
+
self._table = value
|
207
|
+
|
204
208
|
###########################################################################
|
205
209
|
|
206
210
|
# Used by Foreign Keys:
|
@@ -826,7 +830,11 @@ class Column(Selectable):
|
|
826
830
|
engine_type=engine_type, with_alias=False
|
827
831
|
)
|
828
832
|
|
829
|
-
def get_sql_value(
|
833
|
+
def get_sql_value(
|
834
|
+
self,
|
835
|
+
value: t.Any,
|
836
|
+
delimiter: str = "'",
|
837
|
+
) -> str:
|
830
838
|
"""
|
831
839
|
When using DDL statements, we can't parameterise the values. An example
|
832
840
|
is when setting the default for a column. So we have to convert from
|
@@ -835,11 +843,18 @@ class Column(Selectable):
|
|
835
843
|
|
836
844
|
:param value:
|
837
845
|
The Python value to convert to a string usable in a DDL statement
|
838
|
-
e.g. 1
|
846
|
+
e.g. ``1``.
|
847
|
+
:param delimiter:
|
848
|
+
The string returned by this function is wrapped in delimiters,
|
849
|
+
ready to be added to a DDL statement. For example:
|
850
|
+
``'hello world'``.
|
839
851
|
:returns:
|
840
|
-
The string usable in the DDL statement e.g. '1'
|
852
|
+
The string usable in the DDL statement e.g. ``'1'``.
|
841
853
|
|
842
854
|
"""
|
855
|
+
from piccolo.engine.sqlite import ADAPTERS as sqlite_adapters
|
856
|
+
|
857
|
+
# Common across all DB engines
|
843
858
|
if isinstance(value, Default):
|
844
859
|
return getattr(value, self._meta.engine_type)
|
845
860
|
elif value is None:
|
@@ -847,37 +862,52 @@ class Column(Selectable):
|
|
847
862
|
elif isinstance(value, (float, decimal.Decimal)):
|
848
863
|
return str(value)
|
849
864
|
elif isinstance(value, str):
|
850
|
-
return f"
|
865
|
+
return f"{delimiter}{value}{delimiter}"
|
851
866
|
elif isinstance(value, bool):
|
852
867
|
return str(value).lower()
|
853
|
-
elif isinstance(value, datetime.datetime):
|
854
|
-
return f"'{value.isoformat().replace('T', ' ')}'"
|
855
|
-
elif isinstance(value, datetime.date):
|
856
|
-
return f"'{value.isoformat()}'"
|
857
|
-
elif isinstance(value, datetime.time):
|
858
|
-
return f"'{value.isoformat()}'"
|
859
|
-
elif isinstance(value, datetime.timedelta):
|
860
|
-
interval = IntervalCustom.from_timedelta(value)
|
861
|
-
return getattr(interval, self._meta.engine_type)
|
862
868
|
elif isinstance(value, bytes):
|
863
|
-
return f"
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
(
|
872
|
-
|
873
|
-
|
874
|
-
|
869
|
+
return f"{delimiter}{value.hex()}{delimiter}"
|
870
|
+
|
871
|
+
# SQLite specific
|
872
|
+
if self._meta.engine_type == "sqlite":
|
873
|
+
if adapter := sqlite_adapters.get(type(value)):
|
874
|
+
sqlite_value = adapter(value)
|
875
|
+
return (
|
876
|
+
f"{delimiter}{sqlite_value}{delimiter}"
|
877
|
+
if isinstance(sqlite_value, str)
|
878
|
+
else sqlite_value
|
879
|
+
)
|
880
|
+
|
881
|
+
# Postgres and Cockroach
|
882
|
+
if self._meta.engine_type in ["postgres", "cockroach"]:
|
883
|
+
if isinstance(value, datetime.datetime):
|
884
|
+
return f"{delimiter}{value.isoformat().replace('T', ' ')}{delimiter}" # noqa: E501
|
885
|
+
elif isinstance(value, datetime.date):
|
886
|
+
return f"{delimiter}{value.isoformat()}{delimiter}"
|
887
|
+
elif isinstance(value, datetime.time):
|
888
|
+
return f"{delimiter}{value.isoformat()}{delimiter}"
|
889
|
+
elif isinstance(value, datetime.timedelta):
|
890
|
+
interval = IntervalCustom.from_timedelta(value)
|
891
|
+
return getattr(interval, self._meta.engine_type)
|
892
|
+
elif isinstance(value, uuid.UUID):
|
893
|
+
return f"{delimiter}{value}{delimiter}"
|
894
|
+
elif isinstance(value, list):
|
895
|
+
# Convert to the array syntax.
|
896
|
+
return (
|
897
|
+
delimiter
|
898
|
+
+ "{"
|
899
|
+
+ ",".join(
|
900
|
+
self.get_sql_value(
|
901
|
+
i,
|
902
|
+
delimiter="" if isinstance(i, list) else '"',
|
903
|
+
)
|
904
|
+
for i in value
|
875
905
|
)
|
876
|
-
|
906
|
+
+ "}"
|
907
|
+
+ delimiter
|
877
908
|
)
|
878
|
-
|
879
|
-
|
880
|
-
return value
|
909
|
+
|
910
|
+
return str(value)
|
881
911
|
|
882
912
|
@property
|
883
913
|
def column_type(self):
|
@@ -1,17 +1,19 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import typing as t
|
4
|
-
from abc import ABC, abstractmethod
|
4
|
+
from abc import ABC, abstractmethod
|
5
5
|
|
6
6
|
from piccolo.utils.repr import repr_class_instance
|
7
7
|
|
8
8
|
|
9
9
|
class Default(ABC):
|
10
|
-
@
|
10
|
+
@property
|
11
|
+
@abstractmethod
|
11
12
|
def postgres(self) -> str:
|
12
13
|
pass
|
13
14
|
|
14
|
-
@
|
15
|
+
@property
|
16
|
+
@abstractmethod
|
15
17
|
def sqlite(self) -> str:
|
16
18
|
pass
|
17
19
|
|
@@ -1,15 +1,22 @@
|
|
1
1
|
from .aggregate import Avg, Count, Max, Min, Sum
|
2
|
+
from .math import Abs, Ceil, Floor, Round
|
2
3
|
from .string import Length, Lower, Ltrim, Reverse, Rtrim, Upper
|
4
|
+
from .type_conversion import Cast
|
3
5
|
|
4
6
|
__all__ = (
|
7
|
+
"Abs",
|
5
8
|
"Avg",
|
9
|
+
"Cast",
|
10
|
+
"Ceil",
|
6
11
|
"Count",
|
12
|
+
"Floor",
|
7
13
|
"Length",
|
8
14
|
"Lower",
|
9
15
|
"Ltrim",
|
10
16
|
"Max",
|
11
17
|
"Min",
|
12
18
|
"Reverse",
|
19
|
+
"Round",
|
13
20
|
"Rtrim",
|
14
21
|
"Sum",
|
15
22
|
"Upper",
|
@@ -12,17 +12,17 @@ class Avg(Function):
|
|
12
12
|
|
13
13
|
.. code-block:: python
|
14
14
|
|
15
|
-
await Band.select(Avg(Band.popularity))
|
15
|
+
await Band.select(Avg(Band.popularity))
|
16
16
|
|
17
17
|
# We can use an alias. These two are equivalent:
|
18
18
|
|
19
19
|
await Band.select(
|
20
20
|
Avg(Band.popularity, alias="popularity_avg")
|
21
|
-
)
|
21
|
+
)
|
22
22
|
|
23
23
|
await Band.select(
|
24
24
|
Avg(Band.popularity).as_alias("popularity_avg")
|
25
|
-
)
|
25
|
+
)
|
26
26
|
|
27
27
|
"""
|
28
28
|
|
@@ -103,17 +103,17 @@ class Min(Function):
|
|
103
103
|
|
104
104
|
.. code-block:: python
|
105
105
|
|
106
|
-
await Band.select(Min(Band.popularity))
|
106
|
+
await Band.select(Min(Band.popularity))
|
107
107
|
|
108
108
|
# We can use an alias. These two are equivalent:
|
109
109
|
|
110
110
|
await Band.select(
|
111
111
|
Min(Band.popularity, alias="popularity_min")
|
112
|
-
)
|
112
|
+
)
|
113
113
|
|
114
114
|
await Band.select(
|
115
115
|
Min(Band.popularity).as_alias("popularity_min")
|
116
|
-
)
|
116
|
+
)
|
117
117
|
|
118
118
|
"""
|
119
119
|
|
@@ -128,17 +128,17 @@ class Max(Function):
|
|
128
128
|
|
129
129
|
await Band.select(
|
130
130
|
Max(Band.popularity)
|
131
|
-
)
|
131
|
+
)
|
132
132
|
|
133
133
|
# We can use an alias. These two are equivalent:
|
134
134
|
|
135
135
|
await Band.select(
|
136
136
|
Max(Band.popularity, alias="popularity_max")
|
137
|
-
)
|
137
|
+
)
|
138
138
|
|
139
139
|
await Band.select(
|
140
140
|
Max(Band.popularity).as_alias("popularity_max")
|
141
|
-
)
|
141
|
+
)
|
142
142
|
|
143
143
|
"""
|
144
144
|
|
@@ -153,17 +153,17 @@ class Sum(Function):
|
|
153
153
|
|
154
154
|
await Band.select(
|
155
155
|
Sum(Band.popularity)
|
156
|
-
)
|
156
|
+
)
|
157
157
|
|
158
158
|
# We can use an alias. These two are equivalent:
|
159
159
|
|
160
160
|
await Band.select(
|
161
161
|
Sum(Band.popularity, alias="popularity_sum")
|
162
|
-
)
|
162
|
+
)
|
163
163
|
|
164
164
|
await Band.select(
|
165
165
|
Sum(Band.popularity).as_alias("popularity_sum")
|
166
|
-
)
|
166
|
+
)
|
167
167
|
|
168
168
|
"""
|
169
169
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"""
|
2
|
+
These functions mirror their counterparts in the Postgresql docs:
|
3
|
+
|
4
|
+
https://www.postgresql.org/docs/current/functions-math.html
|
5
|
+
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .base import Function
|
9
|
+
|
10
|
+
|
11
|
+
class Abs(Function):
|
12
|
+
"""
|
13
|
+
Absolute value.
|
14
|
+
"""
|
15
|
+
|
16
|
+
function_name = "ABS"
|
17
|
+
|
18
|
+
|
19
|
+
class Ceil(Function):
|
20
|
+
"""
|
21
|
+
Nearest integer greater than or equal to argument.
|
22
|
+
"""
|
23
|
+
|
24
|
+
function_name = "CEIL"
|
25
|
+
|
26
|
+
|
27
|
+
class Floor(Function):
|
28
|
+
"""
|
29
|
+
Nearest integer less than or equal to argument.
|
30
|
+
"""
|
31
|
+
|
32
|
+
function_name = "FLOOR"
|
33
|
+
|
34
|
+
|
35
|
+
class Round(Function):
|
36
|
+
"""
|
37
|
+
Rounds to nearest integer.
|
38
|
+
"""
|
39
|
+
|
40
|
+
function_name = "ROUND"
|
41
|
+
|
42
|
+
|
43
|
+
__all__ = (
|
44
|
+
"Abs",
|
45
|
+
"Ceil",
|
46
|
+
"Floor",
|
47
|
+
"Round",
|
48
|
+
)
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import typing as t
|
2
|
+
|
3
|
+
from piccolo.columns.base import Column
|
4
|
+
from piccolo.querystring import QueryString
|
5
|
+
|
6
|
+
|
7
|
+
class Cast(QueryString):
|
8
|
+
def __init__(
|
9
|
+
self,
|
10
|
+
identifier: t.Union[Column, QueryString],
|
11
|
+
as_type: Column,
|
12
|
+
alias: t.Optional[str] = None,
|
13
|
+
):
|
14
|
+
"""
|
15
|
+
Cast a value to a different type. For example::
|
16
|
+
|
17
|
+
>>> from piccolo.query.functions import Cast
|
18
|
+
|
19
|
+
>>> await Concert.select(
|
20
|
+
... Cast(Concert.starts, Time(), "start_time")
|
21
|
+
... )
|
22
|
+
[{"start_time": datetime.time(19, 0)}]
|
23
|
+
|
24
|
+
:param identifier:
|
25
|
+
Identifies what is being converted (e.g. a column).
|
26
|
+
:param as_type:
|
27
|
+
The type to be converted to.
|
28
|
+
|
29
|
+
"""
|
30
|
+
# Make sure the identifier is a supported type.
|
31
|
+
|
32
|
+
if not isinstance(identifier, (Column, QueryString)):
|
33
|
+
raise ValueError(
|
34
|
+
"The identifier is an unsupported type - only Column and "
|
35
|
+
"QueryString instances are allowed."
|
36
|
+
)
|
37
|
+
|
38
|
+
#######################################################################
|
39
|
+
# Convert `as_type` to a string which can be used in the query.
|
40
|
+
|
41
|
+
if not isinstance(as_type, Column):
|
42
|
+
raise ValueError("The `as_type` value must be a Column instance.")
|
43
|
+
|
44
|
+
# We need to give the column a reference to a table, and hence
|
45
|
+
# the database engine, as the column type is sometimes dependent
|
46
|
+
# on which database is being used.
|
47
|
+
from piccolo.table import Table, create_table_class
|
48
|
+
|
49
|
+
table: t.Optional[t.Type[Table]] = None
|
50
|
+
|
51
|
+
if isinstance(identifier, Column):
|
52
|
+
table = identifier._meta.table
|
53
|
+
elif isinstance(identifier, QueryString):
|
54
|
+
table = (
|
55
|
+
identifier.columns[0]._meta.table
|
56
|
+
if identifier.columns
|
57
|
+
else None
|
58
|
+
)
|
59
|
+
|
60
|
+
as_type._meta.table = table or create_table_class("Table")
|
61
|
+
as_type_string = as_type.column_type
|
62
|
+
|
63
|
+
#######################################################################
|
64
|
+
# Preserve the original alias from the column.
|
65
|
+
|
66
|
+
if isinstance(identifier, Column):
|
67
|
+
alias = (
|
68
|
+
alias
|
69
|
+
or identifier._alias
|
70
|
+
or identifier._meta.get_default_alias()
|
71
|
+
)
|
72
|
+
|
73
|
+
#######################################################################
|
74
|
+
|
75
|
+
super().__init__(
|
76
|
+
f"CAST({{}} AS {as_type_string})",
|
77
|
+
identifier,
|
78
|
+
alias=alias,
|
79
|
+
)
|
80
|
+
|
81
|
+
|
82
|
+
__all__ = ("Cast",)
|
@@ -270,12 +270,42 @@ class QueryString(Selectable):
|
|
270
270
|
def __sub__(self, value) -> QueryString:
|
271
271
|
return QueryString("{} - {}", self, value)
|
272
272
|
|
273
|
+
def __gt__(self, value) -> QueryString:
|
274
|
+
return QueryString("{} > {}", self, value)
|
275
|
+
|
276
|
+
def __ge__(self, value) -> QueryString:
|
277
|
+
return QueryString("{} >= {}", self, value)
|
278
|
+
|
279
|
+
def __lt__(self, value) -> QueryString:
|
280
|
+
return QueryString("{} < {}", self, value)
|
281
|
+
|
282
|
+
def __le__(self, value) -> QueryString:
|
283
|
+
return QueryString("{} <= {}", self, value)
|
284
|
+
|
285
|
+
def __truediv__(self, value) -> QueryString:
|
286
|
+
return QueryString("{} / {}", self, value)
|
287
|
+
|
288
|
+
def __mul__(self, value) -> QueryString:
|
289
|
+
return QueryString("{} * {}", self, value)
|
290
|
+
|
291
|
+
def __pow__(self, value) -> QueryString:
|
292
|
+
return QueryString("{} ^ {}", self, value)
|
293
|
+
|
294
|
+
def __mod__(self, value) -> QueryString:
|
295
|
+
return QueryString("{} % {}", self, value)
|
296
|
+
|
273
297
|
def is_in(self, value) -> QueryString:
|
274
298
|
return QueryString("{} IN {}", self, value)
|
275
299
|
|
276
300
|
def not_in(self, value) -> QueryString:
|
277
301
|
return QueryString("{} NOT IN {}", self, value)
|
278
302
|
|
303
|
+
def like(self, value: str) -> QueryString:
|
304
|
+
return QueryString("{} LIKE {}", self, value)
|
305
|
+
|
306
|
+
def ilike(self, value: str) -> QueryString:
|
307
|
+
return QueryString("{} ILIKE {}", self, value)
|
308
|
+
|
279
309
|
|
280
310
|
class Unquoted(QueryString):
|
281
311
|
"""
|
@@ -162,7 +162,9 @@ piccolo/query/proxy.py
|
|
162
162
|
piccolo/query/functions/__init__.py
|
163
163
|
piccolo/query/functions/aggregate.py
|
164
164
|
piccolo/query/functions/base.py
|
165
|
+
piccolo/query/functions/math.py
|
165
166
|
piccolo/query/functions/string.py
|
167
|
+
piccolo/query/functions/type_conversion.py
|
166
168
|
piccolo/query/methods/__init__.py
|
167
169
|
piccolo/query/methods/alter.py
|
168
170
|
piccolo/query/methods/count.py
|
@@ -264,6 +266,7 @@ tests/columns/test_date.py
|
|
264
266
|
tests/columns/test_db_column_name.py
|
265
267
|
tests/columns/test_defaults.py
|
266
268
|
tests/columns/test_double_precision.py
|
269
|
+
tests/columns/test_get_sql_value.py
|
267
270
|
tests/columns/test_interval.py
|
268
271
|
tests/columns/test_json.py
|
269
272
|
tests/columns/test_jsonb.py
|
@@ -307,10 +310,15 @@ tests/query/__init__.py
|
|
307
310
|
tests/query/test_await.py
|
308
311
|
tests/query/test_camelcase.py
|
309
312
|
tests/query/test_freeze.py
|
310
|
-
tests/query/test_functions.py
|
311
313
|
tests/query/test_gather.py
|
312
314
|
tests/query/test_querystring.py
|
313
315
|
tests/query/test_slots.py
|
316
|
+
tests/query/functions/__init__.py
|
317
|
+
tests/query/functions/base.py
|
318
|
+
tests/query/functions/test_functions.py
|
319
|
+
tests/query/functions/test_math.py
|
320
|
+
tests/query/functions/test_string.py
|
321
|
+
tests/query/functions/test_type_conversion.py
|
314
322
|
tests/query/mixins/__init__.py
|
315
323
|
tests/query/mixins/test_columns_delegate.py
|
316
324
|
tests/query/mixins/test_order_by_delegate.py
|
@@ -288,7 +288,12 @@ class TestMigrations(MigrationTestCase):
|
|
288
288
|
[
|
289
289
|
x.data_type == "text",
|
290
290
|
x.is_nullable == "NO",
|
291
|
-
x.column_default
|
291
|
+
x.column_default
|
292
|
+
in (
|
293
|
+
"''",
|
294
|
+
"''::text",
|
295
|
+
"'':::STRING",
|
296
|
+
),
|
292
297
|
]
|
293
298
|
),
|
294
299
|
)
|
@@ -461,6 +466,7 @@ class TestMigrations(MigrationTestCase):
|
|
461
466
|
in (
|
462
467
|
"now()",
|
463
468
|
"CURRENT_TIMESTAMP",
|
469
|
+
"current_timestamp()::TIMESTAMP",
|
464
470
|
"current_timestamp():::TIMESTAMPTZ::TIMESTAMP",
|
465
471
|
),
|
466
472
|
]
|
@@ -541,7 +547,11 @@ class TestMigrations(MigrationTestCase):
|
|
541
547
|
x.data_type == "interval",
|
542
548
|
x.is_nullable == "NO",
|
543
549
|
x.column_default
|
544
|
-
in (
|
550
|
+
in (
|
551
|
+
"'00:00:00'",
|
552
|
+
"'00:00:00'::interval",
|
553
|
+
"'00:00:00':::INTERVAL",
|
554
|
+
),
|
545
555
|
]
|
546
556
|
),
|
547
557
|
)
|
@@ -743,7 +753,12 @@ class TestMigrations(MigrationTestCase):
|
|
743
753
|
[
|
744
754
|
x.data_type == "jsonb",
|
745
755
|
x.is_nullable == "NO",
|
746
|
-
x.column_default
|
756
|
+
x.column_default
|
757
|
+
in (
|
758
|
+
"'{}'",
|
759
|
+
"'{}'::jsonb",
|
760
|
+
"'{}':::JSONB",
|
761
|
+
),
|
747
762
|
]
|
748
763
|
),
|
749
764
|
)
|
@@ -766,7 +781,11 @@ class TestMigrations(MigrationTestCase):
|
|
766
781
|
x.data_type == "character varying",
|
767
782
|
x.is_nullable == "NO",
|
768
783
|
x.column_default
|
769
|
-
in (
|
784
|
+
in (
|
785
|
+
"''",
|
786
|
+
"''::character varying",
|
787
|
+
"'':::STRING",
|
788
|
+
),
|
770
789
|
]
|
771
790
|
),
|
772
791
|
)
|
@@ -788,7 +807,11 @@ class TestMigrations(MigrationTestCase):
|
|
788
807
|
x.data_type == "character varying",
|
789
808
|
x.is_nullable == "NO",
|
790
809
|
x.column_default
|
791
|
-
in (
|
810
|
+
in (
|
811
|
+
"''",
|
812
|
+
"''::character varying",
|
813
|
+
"'':::STRING",
|
814
|
+
),
|
792
815
|
]
|
793
816
|
),
|
794
817
|
)
|
@@ -768,15 +768,15 @@ class TestMigrationManager(DBTestCase):
|
|
768
768
|
)
|
769
769
|
|
770
770
|
asyncio.run(manager.run())
|
771
|
-
self.
|
772
|
-
self._get_column_default(),
|
773
|
-
[
|
771
|
+
self.assertIn(
|
772
|
+
self._get_column_default()[0]["column_default"],
|
773
|
+
["'Unknown'", "'Unknown':::STRING"],
|
774
774
|
)
|
775
775
|
|
776
776
|
asyncio.run(manager.run(backwards=True))
|
777
|
-
self.
|
778
|
-
self._get_column_default(),
|
779
|
-
[
|
777
|
+
self.assertIn(
|
778
|
+
self._get_column_default()[0]["column_default"],
|
779
|
+
["''", "'':::STRING"],
|
780
780
|
)
|
781
781
|
|
782
782
|
@engines_only("postgres")
|
@@ -856,9 +856,9 @@ class TestMigrationManager(DBTestCase):
|
|
856
856
|
old_params={"default": None},
|
857
857
|
)
|
858
858
|
asyncio.run(manager_1.run())
|
859
|
-
self.
|
860
|
-
self._get_column_default(),
|
861
|
-
[
|
859
|
+
self.assertIn(
|
860
|
+
self._get_column_default()[0]["column_default"],
|
861
|
+
["'Mr Manager'", "'Mr Manager':::STRING"],
|
862
862
|
)
|
863
863
|
|
864
864
|
# Drop the default.
|
@@ -879,9 +879,9 @@ class TestMigrationManager(DBTestCase):
|
|
879
879
|
# And add it back once more to be sure.
|
880
880
|
manager_3 = manager_1
|
881
881
|
asyncio.run(manager_3.run())
|
882
|
-
self.
|
883
|
-
self._get_column_default(),
|
884
|
-
[
|
882
|
+
self.assertIn(
|
883
|
+
self._get_column_default()[0]["column_default"],
|
884
|
+
["'Mr Manager'", "'Mr Manager':::STRING"],
|
885
885
|
)
|
886
886
|
|
887
887
|
# Run them all backwards
|
@@ -892,9 +892,9 @@ class TestMigrationManager(DBTestCase):
|
|
892
892
|
)
|
893
893
|
|
894
894
|
asyncio.run(manager_2.run(backwards=True))
|
895
|
-
self.
|
896
|
-
self._get_column_default(),
|
897
|
-
[
|
895
|
+
self.assertIn(
|
896
|
+
self._get_column_default()[0]["column_default"],
|
897
|
+
["'Mr Manager'", "'Mr Manager':::STRING"],
|
898
898
|
)
|
899
899
|
|
900
900
|
asyncio.run(manager_1.run(backwards=True))
|