piccolo 1.7.0__tar.gz → 1.8.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.8.0}/PKG-INFO +1 -1
- piccolo-1.8.0/piccolo/__init__.py +1 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/base.py +4 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/functions/__init__.py +2 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/functions/aggregate.py +12 -12
- piccolo-1.8.0/piccolo/query/functions/type_conversion.py +82 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/querystring.py +12 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/PKG-INFO +1 -1
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/SOURCES.txt +1 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/integration/test_migrations.py +28 -5
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/test_migration_manager.py +15 -15
- piccolo-1.8.0/tests/query/test_functions.py +238 -0
- piccolo-1.7.0/piccolo/__init__.py +0 -1
- piccolo-1.7.0/tests/query/test_functions.py +0 -102
- {piccolo-1.7.0 → piccolo-1.8.0}/LICENSE +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/README.md +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/commands/show_all.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/app/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/_esmerald_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/commands/load.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/meta/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/meta/commands/version.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/meta/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/operations.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/check.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/clean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/migrations/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/playground/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/playground/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/playground/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/playground/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/project/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/project/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/project/commands/new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/project/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/commands/generate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/commands/graph.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/schema/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/shell/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/shell/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/tester/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/tester/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/tester/commands/run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/tester/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/commands/change_password.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/commands/create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/commands/list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/apps/user/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/choices.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/column_types.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/combination.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/date.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/interval.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/time.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/timestamp.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/timestamptz.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/defaults/uuid.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/m2m.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/operators/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/operators/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/operators/comparison.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/operators/math.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/operators/string.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/columns/reference.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/conf/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/conf/apps.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/custom_types.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/cockroach.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/exceptions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/finder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/postgres.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/engine/sqlite.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/main.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/py.typed +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/functions/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/functions/string.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/alter.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/count.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/create_index.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/delete.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/drop_index.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/insert.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/raw.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/refresh.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/select.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/table_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/methods/update.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/mixins.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/query/proxy.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/schema.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/table_reflection.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/testing/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/testing/model_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/testing/random_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/dictionary.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/encoding.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/graphlib/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/lazy_loader.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/naming.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/printing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/pydantic.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/repr.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/sql_values.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/sync.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo/utils/warnings.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/dependency_links.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/entry_points.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/requires.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/piccolo.egg-info/top_level.txt +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/profiling/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/profiling/run_profile.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/pyproject.toml +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/setup.cfg +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/setup.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/app/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/app/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/app/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/app/commands/test_show_all.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/asgi/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/asgi/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/fixtures/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/meta/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/meta/commands/test_version.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_check.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_clean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/migrations/test_migration.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/project/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/project/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/project/commands/test_new.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/schema/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/shell/commands/test_run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/tester/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/commands/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/commands/test_change_password.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/commands/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/commands/test_list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/apps/user/test_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/m2m/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/m2m/base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/m2m/test_m2m.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/m2m/test_m2m_schema.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_array.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_base.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_bigint.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_boolean.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_bytea.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_choices.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_combination.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_date.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_db_column_name.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_defaults.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_double_precision.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_interval.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_json.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_jsonb.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_numeric.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_primary_key.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_real.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_reference.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_reserved_column_names.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_smallint.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_time.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_timestamp.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_timestamptz.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_uuid.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/columns/test_varchar.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/conf/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/conf/example.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/conf/test_apps.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_extra_nodes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_logging.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_nested_transaction.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_pool.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_transaction.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/engine/test_version_parsing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/mega/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/mega/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/mega/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/music/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/music/piccolo_app.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/music/tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/example_apps/music/tables_detailed.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/mixins/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/mixins/test_columns_delegate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_await.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_camelcase.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_freeze.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_gather.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_querystring.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/query/test_slots.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_get_related.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_get_related_readable.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_instantiate.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_remove.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_save.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/instance/test_to_dict.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_all_columns.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_alter.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_batch.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_callback.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_constructor.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_count.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_create.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_create_db_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_create_table_class.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_delete.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_drop_db_tables.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_from_dict.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_indexes.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_inheritance.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_insert.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_join.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_join_on.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_metaclass.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_objects.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_output.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_raw.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_ref.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_refresh.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_repr.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_select.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_str.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_table_exists.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/table/test_update.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/test_main.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/test_schema.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/testing/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/testing/test_model_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/testing/test_random_builder.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/__init__.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_dictionary.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_encoding.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_lazy_loader.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_list.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_naming.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_printing.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_pydantic.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_sql_values.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_sync.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_table_reflection.py +0 -0
- {piccolo-1.7.0 → piccolo-1.8.0}/tests/utils/test_warnings.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__VERSION__ = "1.8.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:
|
@@ -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,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,6 +270,18 @@ 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
|
+
|
273
285
|
def is_in(self, value) -> QueryString:
|
274
286
|
return QueryString("{} IN {}", self, value)
|
275
287
|
|
@@ -163,6 +163,7 @@ piccolo/query/functions/__init__.py
|
|
163
163
|
piccolo/query/functions/aggregate.py
|
164
164
|
piccolo/query/functions/base.py
|
165
165
|
piccolo/query/functions/string.py
|
166
|
+
piccolo/query/functions/type_conversion.py
|
166
167
|
piccolo/query/methods/__init__.py
|
167
168
|
piccolo/query/methods/alter.py
|
168
169
|
piccolo/query/methods/count.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))
|
@@ -0,0 +1,238 @@
|
|
1
|
+
from unittest import TestCase
|
2
|
+
|
3
|
+
from piccolo.columns import Integer, Text, Varchar
|
4
|
+
from piccolo.query.functions import Cast, Length, Reverse, Upper
|
5
|
+
from piccolo.querystring import QueryString
|
6
|
+
from piccolo.table import create_db_tables_sync, drop_db_tables_sync
|
7
|
+
from tests.base import engines_skip
|
8
|
+
from tests.example_apps.music.tables import Band, Manager
|
9
|
+
|
10
|
+
|
11
|
+
class FunctionTest(TestCase):
|
12
|
+
tables = (Band, Manager)
|
13
|
+
|
14
|
+
def setUp(self) -> None:
|
15
|
+
create_db_tables_sync(*self.tables)
|
16
|
+
|
17
|
+
manager = Manager({Manager.name: "Guido"})
|
18
|
+
manager.save().run_sync()
|
19
|
+
|
20
|
+
band = Band(
|
21
|
+
{
|
22
|
+
Band.name: "Pythonistas",
|
23
|
+
Band.manager: manager,
|
24
|
+
Band.popularity: 1000,
|
25
|
+
}
|
26
|
+
)
|
27
|
+
band.save().run_sync()
|
28
|
+
|
29
|
+
def tearDown(self) -> None:
|
30
|
+
drop_db_tables_sync(*self.tables)
|
31
|
+
|
32
|
+
|
33
|
+
class TestUpperFunction(FunctionTest):
|
34
|
+
|
35
|
+
def test_column(self):
|
36
|
+
"""
|
37
|
+
Make sure we can uppercase a column's value.
|
38
|
+
"""
|
39
|
+
response = Band.select(Upper(Band.name)).run_sync()
|
40
|
+
self.assertListEqual(response, [{"upper": "PYTHONISTAS"}])
|
41
|
+
|
42
|
+
def test_alias(self):
|
43
|
+
response = Band.select(Upper(Band.name, alias="name")).run_sync()
|
44
|
+
self.assertListEqual(response, [{"name": "PYTHONISTAS"}])
|
45
|
+
|
46
|
+
def test_joined_column(self):
|
47
|
+
"""
|
48
|
+
Make sure we can uppercase a column's value from a joined table.
|
49
|
+
"""
|
50
|
+
response = Band.select(Upper(Band.manager._.name)).run_sync()
|
51
|
+
self.assertListEqual(response, [{"upper": "GUIDO"}])
|
52
|
+
|
53
|
+
|
54
|
+
@engines_skip("sqlite")
|
55
|
+
class TestNested(FunctionTest):
|
56
|
+
"""
|
57
|
+
Skip the the test for SQLite, as it doesn't support ``Reverse``.
|
58
|
+
"""
|
59
|
+
|
60
|
+
def test_nested(self):
|
61
|
+
"""
|
62
|
+
Make sure we can nest functions.
|
63
|
+
"""
|
64
|
+
response = Band.select(Upper(Reverse(Band.name))).run_sync()
|
65
|
+
self.assertListEqual(response, [{"upper": "SATSINOHTYP"}])
|
66
|
+
|
67
|
+
def test_nested_with_joined_column(self):
|
68
|
+
"""
|
69
|
+
Make sure nested functions can be used on a column from a joined table.
|
70
|
+
"""
|
71
|
+
response = Band.select(Upper(Reverse(Band.manager._.name))).run_sync()
|
72
|
+
self.assertListEqual(response, [{"upper": "ODIUG"}])
|
73
|
+
|
74
|
+
def test_nested_within_querystring(self):
|
75
|
+
"""
|
76
|
+
If we wrap a function in a custom QueryString - make sure the columns
|
77
|
+
are still accessible, so joins are successful.
|
78
|
+
"""
|
79
|
+
response = Band.select(
|
80
|
+
QueryString("CONCAT({}, '!')", Upper(Band.manager._.name)),
|
81
|
+
).run_sync()
|
82
|
+
|
83
|
+
self.assertListEqual(response, [{"concat": "GUIDO!"}])
|
84
|
+
|
85
|
+
|
86
|
+
class TestWhereClause(FunctionTest):
|
87
|
+
|
88
|
+
def test_where(self):
|
89
|
+
"""
|
90
|
+
Make sure where clauses work with functions.
|
91
|
+
"""
|
92
|
+
response = (
|
93
|
+
Band.select(Band.name)
|
94
|
+
.where(Upper(Band.name) == "PYTHONISTAS")
|
95
|
+
.run_sync()
|
96
|
+
)
|
97
|
+
self.assertListEqual(response, [{"name": "Pythonistas"}])
|
98
|
+
|
99
|
+
def test_where_with_joined_column(self):
|
100
|
+
"""
|
101
|
+
Make sure where clauses work with functions, when a joined column is
|
102
|
+
used.
|
103
|
+
"""
|
104
|
+
response = (
|
105
|
+
Band.select(Band.name)
|
106
|
+
.where(Upper(Band.manager._.name) == "GUIDO")
|
107
|
+
.run_sync()
|
108
|
+
)
|
109
|
+
self.assertListEqual(response, [{"name": "Pythonistas"}])
|
110
|
+
|
111
|
+
|
112
|
+
class TestCast(FunctionTest):
|
113
|
+
def test_varchar(self):
|
114
|
+
"""
|
115
|
+
Make sure that casting to ``Varchar`` works.
|
116
|
+
"""
|
117
|
+
response = Band.select(
|
118
|
+
Cast(
|
119
|
+
Band.popularity,
|
120
|
+
as_type=Varchar(),
|
121
|
+
)
|
122
|
+
).run_sync()
|
123
|
+
|
124
|
+
self.assertListEqual(
|
125
|
+
response,
|
126
|
+
[{"popularity": "1000"}],
|
127
|
+
)
|
128
|
+
|
129
|
+
def test_text(self):
|
130
|
+
"""
|
131
|
+
Make sure that casting to ``Text`` works.
|
132
|
+
"""
|
133
|
+
response = Band.select(
|
134
|
+
Cast(
|
135
|
+
Band.popularity,
|
136
|
+
as_type=Text(),
|
137
|
+
)
|
138
|
+
).run_sync()
|
139
|
+
|
140
|
+
self.assertListEqual(
|
141
|
+
response,
|
142
|
+
[{"popularity": "1000"}],
|
143
|
+
)
|
144
|
+
|
145
|
+
def test_integer(self):
|
146
|
+
"""
|
147
|
+
Make sure that casting to ``Integer`` works.
|
148
|
+
"""
|
149
|
+
Band.update({Band.name: "1111"}, force=True).run_sync()
|
150
|
+
|
151
|
+
response = Band.select(
|
152
|
+
Cast(
|
153
|
+
Band.name,
|
154
|
+
as_type=Integer(),
|
155
|
+
)
|
156
|
+
).run_sync()
|
157
|
+
|
158
|
+
self.assertListEqual(
|
159
|
+
response,
|
160
|
+
[{"name": 1111}],
|
161
|
+
)
|
162
|
+
|
163
|
+
def test_join(self):
|
164
|
+
"""
|
165
|
+
Make sure that casting works with joins.
|
166
|
+
"""
|
167
|
+
Manager.update({Manager.name: "1111"}, force=True).run_sync()
|
168
|
+
|
169
|
+
response = Band.select(
|
170
|
+
Band.name,
|
171
|
+
Cast(
|
172
|
+
Band.manager.name,
|
173
|
+
as_type=Integer(),
|
174
|
+
),
|
175
|
+
).run_sync()
|
176
|
+
|
177
|
+
self.assertListEqual(
|
178
|
+
response,
|
179
|
+
[
|
180
|
+
{
|
181
|
+
"name": "Pythonistas",
|
182
|
+
"manager.name": 1111,
|
183
|
+
}
|
184
|
+
],
|
185
|
+
)
|
186
|
+
|
187
|
+
def test_nested_inner(self):
|
188
|
+
"""
|
189
|
+
Make sure ``Cast`` can be passed into other functions.
|
190
|
+
"""
|
191
|
+
Band.update({Band.name: "1111"}, force=True).run_sync()
|
192
|
+
|
193
|
+
response = Band.select(
|
194
|
+
Length(
|
195
|
+
Cast(
|
196
|
+
Band.popularity,
|
197
|
+
as_type=Varchar(),
|
198
|
+
)
|
199
|
+
)
|
200
|
+
).run_sync()
|
201
|
+
|
202
|
+
self.assertListEqual(
|
203
|
+
response,
|
204
|
+
[{"length": 4}],
|
205
|
+
)
|
206
|
+
|
207
|
+
def test_nested_outer(self):
|
208
|
+
"""
|
209
|
+
Make sure a querystring can be passed into ``Cast`` (meaning it can be
|
210
|
+
nested).
|
211
|
+
"""
|
212
|
+
response = Band.select(
|
213
|
+
Cast(
|
214
|
+
Length(Band.name),
|
215
|
+
as_type=Varchar(),
|
216
|
+
alias="length",
|
217
|
+
)
|
218
|
+
).run_sync()
|
219
|
+
|
220
|
+
self.assertListEqual(
|
221
|
+
response,
|
222
|
+
[{"length": str(len("Pythonistas"))}],
|
223
|
+
)
|
224
|
+
|
225
|
+
def test_where_clause(self):
|
226
|
+
"""
|
227
|
+
Make sure ``Cast`` works in a where clause.
|
228
|
+
"""
|
229
|
+
response = (
|
230
|
+
Band.select(Band.name, Band.popularity)
|
231
|
+
.where(Cast(Band.popularity, Varchar()) == "1000")
|
232
|
+
.run_sync()
|
233
|
+
)
|
234
|
+
|
235
|
+
self.assertListEqual(
|
236
|
+
response,
|
237
|
+
[{"name": "Pythonistas", "popularity": 1000}],
|
238
|
+
)
|
@@ -1 +0,0 @@
|
|
1
|
-
__VERSION__ = "1.7.0"
|