piccolo 1.5.2__tar.gz → 1.6.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.5.2 → piccolo-1.6.0}/PKG-INFO +1 -1
- piccolo-1.6.0/piccolo/__init__.py +1 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/base.py +31 -40
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/column_types.py +11 -8
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/m2m.py +16 -6
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/readable.py +9 -7
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/__init__.py +1 -4
- piccolo-1.6.0/piccolo/query/functions/__init__.py +16 -0
- piccolo-1.6.0/piccolo/query/functions/aggregate.py +179 -0
- piccolo-1.6.0/piccolo/query/functions/base.py +21 -0
- piccolo-1.6.0/piccolo/query/functions/string.py +73 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/__init__.py +18 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/count.py +3 -3
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/delete.py +1 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/exists.py +1 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/objects.py +1 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/select.py +17 -232
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/update.py +1 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/mixins.py +9 -2
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/querystring.py +101 -13
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/table.py +8 -24
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/PKG-INFO +1 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/SOURCES.txt +5 -0
- piccolo-1.6.0/tests/query/test_functions.py +102 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_select.py +2 -9
- piccolo-1.5.2/piccolo/__init__.py +0 -1
- {piccolo-1.5.2 → piccolo-1.6.0}/LICENSE +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/README.md +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/show_all.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/app/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_esmerald_endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/load.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/commands/version.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/meta/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/operations.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/check.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/clean.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/migrations/tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/commands/run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/playground/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/project/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/generate.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/graph.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/schema/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/commands/run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/shell/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/commands/run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/tester/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/change_password.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/create.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/commands/list.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/apps/user/tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/choices.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/combination.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/date.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/interval.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/time.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/timestamp.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/timestamptz.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/defaults/uuid.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/indexes.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/comparison.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/math.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/operators/string.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/columns/reference.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/conf/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/conf/apps.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/custom_types.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/cockroach.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/exceptions.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/finder.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/postgres.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/engine/sqlite.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/main.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/py.typed +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/alter.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/create.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/create_index.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/drop_index.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/indexes.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/insert.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/raw.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/refresh.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/methods/table_exists.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/query/proxy.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/schema.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/table_reflection.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/model_builder.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/testing/random_builder.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/dictionary.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/encoding.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/graphlib/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/lazy_loader.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/list.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/naming.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/objects.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/printing.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/pydantic.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/repr.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/sql_values.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/sync.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo/utils/warnings.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/dependency_links.txt +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/entry_points.txt +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/requires.txt +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/piccolo.egg-info/top_level.txt +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/profiling/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/profiling/run_profile.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/pyproject.toml +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/setup.cfg +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/setup.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/test_new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/app/commands/test_show_all.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/asgi/commands/test_new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/meta/commands/test_version.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/integration/test_migrations.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_migration_manager.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_check.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_clean.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/commands/test_new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/migrations/test_migration.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/project/commands/test_new.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/schema/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/shell/commands/test_run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/tester/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_change_password.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_create.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/commands/test_list.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/apps/user/test_tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/test_m2m.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/m2m/test_m2m_schema.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_array.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_base.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_bigint.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_boolean.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_bytea.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_choices.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_combination.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_date.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_db_column_name.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_defaults.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_double_precision.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_interval.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_json.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_jsonb.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_numeric.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_primary_key.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_readable.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_real.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_reference.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_reserved_column_names.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_smallint.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_time.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_timestamp.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_timestamptz.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_uuid.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/columns/test_varchar.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/example.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/conf/test_apps.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_extra_nodes.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_logging.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_nested_transaction.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_pool.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_transaction.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/engine/test_version_parsing.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/mega/tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/piccolo_app.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/example_apps/music/tables_detailed.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/test_columns_delegate.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_await.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_camelcase.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_freeze.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_gather.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_querystring.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/query/test_slots.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_create.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_get_related.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_get_related_readable.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_instantiate.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_remove.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_save.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/instance/test_to_dict.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_all_columns.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_alter.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_batch.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_callback.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_constructor.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_count.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create_db_tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_create_table_class.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_delete.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_drop_db_tables.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_exists.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_from_dict.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_indexes.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_inheritance.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_insert.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_join.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_join_on.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_metaclass.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_objects.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_output.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_raw.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_ref.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_refresh.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_repr.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_str.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_table_exists.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/table/test_update.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/test_main.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/test_schema.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/test_model_builder.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/testing/test_random_builder.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/__init__.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_dictionary.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_encoding.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_lazy_loader.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_list.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_naming.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_printing.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_pydantic.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_sql_values.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_sync.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_table_reflection.py +0 -0
- {piccolo-1.5.2 → piccolo-1.6.0}/tests/utils/test_warnings.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__VERSION__ = "1.6.0"
|
@@ -6,7 +6,6 @@ import decimal
|
|
6
6
|
import inspect
|
7
7
|
import typing as t
|
8
8
|
import uuid
|
9
|
-
from abc import ABCMeta, abstractmethod
|
10
9
|
from dataclasses import dataclass, field, fields
|
11
10
|
from enum import Enum
|
12
11
|
|
@@ -32,6 +31,7 @@ from piccolo.columns.operators.comparison import (
|
|
32
31
|
NotLike,
|
33
32
|
)
|
34
33
|
from piccolo.columns.reference import LazyTableReference
|
34
|
+
from piccolo.querystring import QueryString, Selectable
|
35
35
|
from piccolo.utils.warnings import colored_warning
|
36
36
|
|
37
37
|
if t.TYPE_CHECKING: # pragma: no cover
|
@@ -205,7 +205,6 @@ class ColumnMeta:
|
|
205
205
|
|
206
206
|
# Used by Foreign Keys:
|
207
207
|
call_chain: t.List["ForeignKey"] = field(default_factory=list)
|
208
|
-
table_alias: t.Optional[str] = None
|
209
208
|
|
210
209
|
###########################################################################
|
211
210
|
|
@@ -260,7 +259,7 @@ class ColumnMeta:
|
|
260
259
|
column_name = self.db_column_name
|
261
260
|
|
262
261
|
if self.call_chain:
|
263
|
-
table_alias = self.call_chain[-1].
|
262
|
+
table_alias = self.call_chain[-1].table_alias
|
264
263
|
if include_quotes:
|
265
264
|
return f'"{table_alias}"."{column_name}"'
|
266
265
|
else:
|
@@ -272,7 +271,9 @@ class ColumnMeta:
|
|
272
271
|
return f"{self.table._meta.tablename}.{column_name}"
|
273
272
|
|
274
273
|
def get_full_name(
|
275
|
-
self,
|
274
|
+
self,
|
275
|
+
with_alias: bool = True,
|
276
|
+
include_quotes: bool = True,
|
276
277
|
) -> str:
|
277
278
|
"""
|
278
279
|
Returns the full column name, taking into account joins.
|
@@ -302,11 +303,10 @@ class ColumnMeta:
|
|
302
303
|
>>> column._meta.get_full_name(include_quotes=False)
|
303
304
|
'my_table_name.my_column_name'
|
304
305
|
|
305
|
-
|
306
306
|
"""
|
307
307
|
full_name = self._get_path(include_quotes=include_quotes)
|
308
308
|
|
309
|
-
if with_alias
|
309
|
+
if with_alias:
|
310
310
|
alias = self.get_default_alias()
|
311
311
|
if include_quotes:
|
312
312
|
full_name += f' AS "{alias}"'
|
@@ -346,32 +346,6 @@ class ColumnMeta:
|
|
346
346
|
return self.copy()
|
347
347
|
|
348
348
|
|
349
|
-
class Selectable(metaclass=ABCMeta):
|
350
|
-
"""
|
351
|
-
Anything which inherits from this can be used in a select query.
|
352
|
-
"""
|
353
|
-
|
354
|
-
_alias: t.Optional[str]
|
355
|
-
|
356
|
-
@abstractmethod
|
357
|
-
def get_select_string(
|
358
|
-
self, engine_type: str, with_alias: bool = True
|
359
|
-
) -> str:
|
360
|
-
"""
|
361
|
-
In a query, what to output after the select statement - could be a
|
362
|
-
column name, a sub query, a function etc. For a column it will be the
|
363
|
-
column name.
|
364
|
-
"""
|
365
|
-
raise NotImplementedError()
|
366
|
-
|
367
|
-
def as_alias(self, alias: str) -> Selectable:
|
368
|
-
"""
|
369
|
-
Allows column names to be changed in the result of a select.
|
370
|
-
"""
|
371
|
-
self._alias = alias
|
372
|
-
return self
|
373
|
-
|
374
|
-
|
375
349
|
class Column(Selectable):
|
376
350
|
"""
|
377
351
|
All other columns inherit from ``Column``. Don't use it directly.
|
@@ -822,25 +796,32 @@ class Column(Selectable):
|
|
822
796
|
|
823
797
|
def get_select_string(
|
824
798
|
self, engine_type: str, with_alias: bool = True
|
825
|
-
) ->
|
799
|
+
) -> QueryString:
|
826
800
|
"""
|
827
801
|
How to refer to this column in a SQL query, taking account of any joins
|
828
802
|
and aliases.
|
829
803
|
"""
|
804
|
+
|
830
805
|
if with_alias:
|
831
806
|
if self._alias:
|
832
807
|
original_name = self._meta.get_full_name(
|
833
808
|
with_alias=False,
|
834
809
|
)
|
835
|
-
return f'{original_name} AS "{self._alias}"'
|
810
|
+
return QueryString(f'{original_name} AS "{self._alias}"')
|
836
811
|
else:
|
837
|
-
return
|
838
|
-
|
812
|
+
return QueryString(
|
813
|
+
self._meta.get_full_name(
|
814
|
+
with_alias=True,
|
815
|
+
)
|
839
816
|
)
|
840
817
|
|
841
|
-
return
|
818
|
+
return QueryString(
|
819
|
+
self._meta.get_full_name(
|
820
|
+
with_alias=False,
|
821
|
+
)
|
822
|
+
)
|
842
823
|
|
843
|
-
def get_where_string(self, engine_type: str) ->
|
824
|
+
def get_where_string(self, engine_type: str) -> QueryString:
|
844
825
|
return self.get_select_string(
|
845
826
|
engine_type=engine_type, with_alias=False
|
846
827
|
)
|
@@ -902,6 +883,13 @@ class Column(Selectable):
|
|
902
883
|
def column_type(self):
|
903
884
|
return self.__class__.__name__.upper()
|
904
885
|
|
886
|
+
@property
|
887
|
+
def table_alias(self) -> str:
|
888
|
+
return "$".join(
|
889
|
+
f"{_key._meta.table._meta.tablename}${_key._meta.name}"
|
890
|
+
for _key in [*self._meta.call_chain, self]
|
891
|
+
)
|
892
|
+
|
905
893
|
@property
|
906
894
|
def ddl(self) -> str:
|
907
895
|
"""
|
@@ -945,8 +933,8 @@ class Column(Selectable):
|
|
945
933
|
|
946
934
|
return query
|
947
935
|
|
948
|
-
def copy(self) ->
|
949
|
-
column
|
936
|
+
def copy(self: Self) -> Self:
|
937
|
+
column = copy.copy(self)
|
950
938
|
column._meta = self._meta.copy()
|
951
939
|
return column
|
952
940
|
|
@@ -971,3 +959,6 @@ class Column(Selectable):
|
|
971
959
|
f"{table_class_name}.{self._meta.name} - "
|
972
960
|
f"{self.__class__.__name__}"
|
973
961
|
)
|
962
|
+
|
963
|
+
|
964
|
+
Self = t.TypeVar("Self", bound=Column)
|
@@ -60,7 +60,7 @@ from piccolo.columns.defaults.uuid import UUID4, UUIDArg
|
|
60
60
|
from piccolo.columns.operators.comparison import ArrayAll, ArrayAny
|
61
61
|
from piccolo.columns.operators.string import Concat
|
62
62
|
from piccolo.columns.reference import LazyTableReference
|
63
|
-
from piccolo.querystring import QueryString
|
63
|
+
from piccolo.querystring import QueryString
|
64
64
|
from piccolo.utils.encoding import dump_json
|
65
65
|
from piccolo.utils.warnings import colored_warning
|
66
66
|
|
@@ -752,8 +752,8 @@ class SmallInt(Integer):
|
|
752
752
|
###############################################################################
|
753
753
|
|
754
754
|
|
755
|
-
DEFAULT =
|
756
|
-
NULL =
|
755
|
+
DEFAULT = QueryString("DEFAULT")
|
756
|
+
NULL = QueryString("null")
|
757
757
|
|
758
758
|
|
759
759
|
class Serial(Column):
|
@@ -778,7 +778,7 @@ class Serial(Column):
|
|
778
778
|
if engine_type == "postgres":
|
779
779
|
return DEFAULT
|
780
780
|
elif engine_type == "cockroach":
|
781
|
-
return
|
781
|
+
return QueryString("unique_rowid()")
|
782
782
|
elif engine_type == "sqlite":
|
783
783
|
return NULL
|
784
784
|
raise Exception("Unrecognized engine type")
|
@@ -2194,6 +2194,7 @@ class ForeignKey(Column, t.Generic[ReferencedTable]):
|
|
2194
2194
|
column_meta: ColumnMeta = object.__getattribute__(self, "_meta")
|
2195
2195
|
|
2196
2196
|
new_column._meta.call_chain = column_meta.call_chain.copy()
|
2197
|
+
|
2197
2198
|
new_column._meta.call_chain.append(self)
|
2198
2199
|
return new_column
|
2199
2200
|
else:
|
@@ -2311,7 +2312,7 @@ class JSONB(JSON):
|
|
2311
2312
|
|
2312
2313
|
def get_select_string(
|
2313
2314
|
self, engine_type: str, with_alias: bool = True
|
2314
|
-
) ->
|
2315
|
+
) -> QueryString:
|
2315
2316
|
select_string = self._meta.get_full_name(with_alias=False)
|
2316
2317
|
|
2317
2318
|
if self.json_operator is not None:
|
@@ -2321,7 +2322,7 @@ class JSONB(JSON):
|
|
2321
2322
|
alias = self._alias or self._meta.get_default_alias()
|
2322
2323
|
select_string += f' AS "{alias}"'
|
2323
2324
|
|
2324
|
-
return select_string
|
2325
|
+
return QueryString(select_string)
|
2325
2326
|
|
2326
2327
|
def eq(self, value) -> Where:
|
2327
2328
|
"""
|
@@ -2616,7 +2617,9 @@ class Array(Column):
|
|
2616
2617
|
else:
|
2617
2618
|
raise ValueError("Only integers can be used for indexing.")
|
2618
2619
|
|
2619
|
-
def get_select_string(
|
2620
|
+
def get_select_string(
|
2621
|
+
self, engine_type: str, with_alias=True
|
2622
|
+
) -> QueryString:
|
2620
2623
|
select_string = self._meta.get_full_name(with_alias=False)
|
2621
2624
|
|
2622
2625
|
if isinstance(self.index, int):
|
@@ -2626,7 +2629,7 @@ class Array(Column):
|
|
2626
2629
|
alias = self._alias or self._meta.get_default_alias()
|
2627
2630
|
select_string += f' AS "{alias}"'
|
2628
2631
|
|
2629
|
-
return select_string
|
2632
|
+
return QueryString(select_string)
|
2630
2633
|
|
2631
2634
|
def any(self, value: t.Any) -> Where:
|
2632
2635
|
"""
|
@@ -4,7 +4,6 @@ import inspect
|
|
4
4
|
import typing as t
|
5
5
|
from dataclasses import dataclass
|
6
6
|
|
7
|
-
from piccolo.columns.base import Selectable
|
8
7
|
from piccolo.columns.column_types import (
|
9
8
|
JSON,
|
10
9
|
JSONB,
|
@@ -12,6 +11,7 @@ from piccolo.columns.column_types import (
|
|
12
11
|
ForeignKey,
|
13
12
|
LazyTableReference,
|
14
13
|
)
|
14
|
+
from piccolo.querystring import QueryString, Selectable
|
15
15
|
from piccolo.utils.list import flatten
|
16
16
|
from piccolo.utils.sync import run_sync
|
17
17
|
|
@@ -56,7 +56,9 @@ class M2MSelect(Selectable):
|
|
56
56
|
for column in columns
|
57
57
|
)
|
58
58
|
|
59
|
-
def get_select_string(
|
59
|
+
def get_select_string(
|
60
|
+
self, engine_type: str, with_alias=True
|
61
|
+
) -> QueryString:
|
60
62
|
m2m_table_name_with_schema = (
|
61
63
|
self.m2m._meta.resolved_joining_table._meta.get_formatted_tablename() # noqa: E501
|
62
64
|
) # noqa: E501
|
@@ -90,28 +92,33 @@ class M2MSelect(Selectable):
|
|
90
92
|
if engine_type in ("postgres", "cockroach"):
|
91
93
|
if self.as_list:
|
92
94
|
column_name = self.columns[0]._meta.db_column_name
|
93
|
-
return
|
95
|
+
return QueryString(
|
96
|
+
f"""
|
94
97
|
ARRAY(
|
95
98
|
SELECT
|
96
99
|
"inner_{table_2_name}"."{column_name}"
|
97
100
|
FROM {inner_select}
|
98
101
|
) AS "{m2m_relationship_name}"
|
99
102
|
"""
|
103
|
+
)
|
100
104
|
elif not self.serialisation_safe:
|
101
105
|
column_name = table_2_pk_name
|
102
|
-
return
|
106
|
+
return QueryString(
|
107
|
+
f"""
|
103
108
|
ARRAY(
|
104
109
|
SELECT
|
105
110
|
"inner_{table_2_name}"."{column_name}"
|
106
111
|
FROM {inner_select}
|
107
112
|
) AS "{m2m_relationship_name}"
|
108
113
|
"""
|
114
|
+
)
|
109
115
|
else:
|
110
116
|
column_names = ", ".join(
|
111
117
|
f'"inner_{table_2_name}"."{column._meta.db_column_name}"'
|
112
118
|
for column in self.columns
|
113
119
|
)
|
114
|
-
return
|
120
|
+
return QueryString(
|
121
|
+
f"""
|
115
122
|
(
|
116
123
|
SELECT JSON_AGG({m2m_relationship_name}_results)
|
117
124
|
FROM (
|
@@ -119,13 +126,15 @@ class M2MSelect(Selectable):
|
|
119
126
|
) AS "{m2m_relationship_name}_results"
|
120
127
|
) AS "{m2m_relationship_name}"
|
121
128
|
"""
|
129
|
+
)
|
122
130
|
elif engine_type == "sqlite":
|
123
131
|
if len(self.columns) > 1 or not self.serialisation_safe:
|
124
132
|
column_name = table_2_pk_name
|
125
133
|
else:
|
126
134
|
column_name = self.columns[0]._meta.db_column_name
|
127
135
|
|
128
|
-
return
|
136
|
+
return QueryString(
|
137
|
+
f"""
|
129
138
|
(
|
130
139
|
SELECT group_concat(
|
131
140
|
"inner_{table_2_name}"."{column_name}"
|
@@ -134,6 +143,7 @@ class M2MSelect(Selectable):
|
|
134
143
|
)
|
135
144
|
AS "{m2m_relationship_name} [M2M]"
|
136
145
|
"""
|
146
|
+
)
|
137
147
|
else:
|
138
148
|
raise ValueError(f"{engine_type} is an unrecognised engine type")
|
139
149
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
3
3
|
import typing as t
|
4
4
|
from dataclasses import dataclass
|
5
5
|
|
6
|
-
from piccolo.
|
6
|
+
from piccolo.querystring import QueryString, Selectable
|
7
7
|
|
8
8
|
if t.TYPE_CHECKING: # pragma: no cover
|
9
9
|
from piccolo.columns.base import Column
|
@@ -27,25 +27,27 @@ class Readable(Selectable):
|
|
27
27
|
i._meta.get_full_name(with_alias=False) for i in self.columns
|
28
28
|
)
|
29
29
|
|
30
|
-
def _get_string(self, operator: str) ->
|
31
|
-
return (
|
30
|
+
def _get_string(self, operator: str) -> QueryString:
|
31
|
+
return QueryString(
|
32
32
|
f"{operator}('{self.template}', {self._columns_string}) AS "
|
33
33
|
f"{self.output_name}"
|
34
34
|
)
|
35
35
|
|
36
36
|
@property
|
37
|
-
def sqlite_string(self) ->
|
37
|
+
def sqlite_string(self) -> QueryString:
|
38
38
|
return self._get_string(operator="PRINTF")
|
39
39
|
|
40
40
|
@property
|
41
|
-
def postgres_string(self) ->
|
41
|
+
def postgres_string(self) -> QueryString:
|
42
42
|
return self._get_string(operator="FORMAT")
|
43
43
|
|
44
44
|
@property
|
45
|
-
def cockroach_string(self) ->
|
45
|
+
def cockroach_string(self) -> QueryString:
|
46
46
|
return self._get_string(operator="FORMAT")
|
47
47
|
|
48
|
-
def get_select_string(
|
48
|
+
def get_select_string(
|
49
|
+
self, engine_type: str, with_alias=True
|
50
|
+
) -> QueryString:
|
49
51
|
try:
|
50
52
|
return getattr(self, f"{engine_type}_string")
|
51
53
|
except AttributeError as e:
|
@@ -1,9 +1,9 @@
|
|
1
1
|
from piccolo.columns.combination import WhereRaw
|
2
2
|
|
3
3
|
from .base import Query
|
4
|
+
from .functions.aggregate import Avg, Max, Min, Sum
|
4
5
|
from .methods import (
|
5
6
|
Alter,
|
6
|
-
Avg,
|
7
7
|
Count,
|
8
8
|
Create,
|
9
9
|
CreateIndex,
|
@@ -11,12 +11,9 @@ from .methods import (
|
|
11
11
|
DropIndex,
|
12
12
|
Exists,
|
13
13
|
Insert,
|
14
|
-
Max,
|
15
|
-
Min,
|
16
14
|
Objects,
|
17
15
|
Raw,
|
18
16
|
Select,
|
19
|
-
Sum,
|
20
17
|
TableExists,
|
21
18
|
Update,
|
22
19
|
)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from .aggregate import Avg, Count, Max, Min, Sum
|
2
|
+
from .string import Length, Lower, Ltrim, Reverse, Rtrim, Upper
|
3
|
+
|
4
|
+
__all__ = (
|
5
|
+
"Avg",
|
6
|
+
"Count",
|
7
|
+
"Length",
|
8
|
+
"Lower",
|
9
|
+
"Ltrim",
|
10
|
+
"Max",
|
11
|
+
"Min",
|
12
|
+
"Reverse",
|
13
|
+
"Rtrim",
|
14
|
+
"Sum",
|
15
|
+
"Upper",
|
16
|
+
)
|
@@ -0,0 +1,179 @@
|
|
1
|
+
import typing as t
|
2
|
+
|
3
|
+
from piccolo.columns.base import Column
|
4
|
+
from piccolo.querystring import QueryString
|
5
|
+
|
6
|
+
from .base import Function
|
7
|
+
|
8
|
+
|
9
|
+
class Avg(Function):
|
10
|
+
"""
|
11
|
+
``AVG()`` SQL function. Column type must be numeric to run the query.
|
12
|
+
|
13
|
+
.. code-block:: python
|
14
|
+
|
15
|
+
await Band.select(Avg(Band.popularity)).run()
|
16
|
+
|
17
|
+
# We can use an alias. These two are equivalent:
|
18
|
+
|
19
|
+
await Band.select(
|
20
|
+
Avg(Band.popularity, alias="popularity_avg")
|
21
|
+
).run()
|
22
|
+
|
23
|
+
await Band.select(
|
24
|
+
Avg(Band.popularity).as_alias("popularity_avg")
|
25
|
+
).run()
|
26
|
+
|
27
|
+
"""
|
28
|
+
|
29
|
+
function_name = "AVG"
|
30
|
+
|
31
|
+
|
32
|
+
class Count(QueryString):
|
33
|
+
"""
|
34
|
+
Used in ``Select`` queries, usually in conjunction with the ``group_by``
|
35
|
+
clause::
|
36
|
+
|
37
|
+
>>> await Band.select(
|
38
|
+
... Band.manager.name.as_alias('manager_name'),
|
39
|
+
... Count(alias='band_count')
|
40
|
+
... ).group_by(Band.manager)
|
41
|
+
[{'manager_name': 'Guido', 'count': 1}, ...]
|
42
|
+
|
43
|
+
It can also be used without the ``group_by`` clause (though you may prefer
|
44
|
+
to the :meth:`Table.count <piccolo.table.Table.count>` method instead, as
|
45
|
+
it's more convenient)::
|
46
|
+
|
47
|
+
>>> await Band.select(Count())
|
48
|
+
[{'count': 3}]
|
49
|
+
|
50
|
+
"""
|
51
|
+
|
52
|
+
def __init__(
|
53
|
+
self,
|
54
|
+
column: t.Optional[Column] = None,
|
55
|
+
distinct: t.Optional[t.Sequence[Column]] = None,
|
56
|
+
alias: str = "count",
|
57
|
+
):
|
58
|
+
"""
|
59
|
+
:param column:
|
60
|
+
If specified, the count is for non-null values in that column.
|
61
|
+
:param distinct:
|
62
|
+
If specified, the count is for distinct values in those columns.
|
63
|
+
:param alias:
|
64
|
+
The name of the value in the response::
|
65
|
+
|
66
|
+
# These two are equivalent:
|
67
|
+
|
68
|
+
await Band.select(
|
69
|
+
Band.name, Count(alias="total")
|
70
|
+
).group_by(Band.name)
|
71
|
+
|
72
|
+
await Band.select(
|
73
|
+
Band.name,
|
74
|
+
Count().as_alias("total")
|
75
|
+
).group_by(Band.name)
|
76
|
+
|
77
|
+
"""
|
78
|
+
if distinct and column:
|
79
|
+
raise ValueError("Only specify `column` or `distinct`")
|
80
|
+
|
81
|
+
if distinct:
|
82
|
+
engine_type = distinct[0]._meta.engine_type
|
83
|
+
if engine_type == "sqlite":
|
84
|
+
# SQLite doesn't allow us to specify multiple columns, so
|
85
|
+
# instead we concatenate the values.
|
86
|
+
column_names = " || ".join("{}" for _ in distinct)
|
87
|
+
else:
|
88
|
+
column_names = ", ".join("{}" for _ in distinct)
|
89
|
+
|
90
|
+
return super().__init__(
|
91
|
+
f"COUNT(DISTINCT({column_names}))", *distinct, alias=alias
|
92
|
+
)
|
93
|
+
else:
|
94
|
+
if column:
|
95
|
+
return super().__init__("COUNT({})", column, alias=alias)
|
96
|
+
else:
|
97
|
+
return super().__init__("COUNT(*)", alias=alias)
|
98
|
+
|
99
|
+
|
100
|
+
class Min(Function):
|
101
|
+
"""
|
102
|
+
``MIN()`` SQL function.
|
103
|
+
|
104
|
+
.. code-block:: python
|
105
|
+
|
106
|
+
await Band.select(Min(Band.popularity)).run()
|
107
|
+
|
108
|
+
# We can use an alias. These two are equivalent:
|
109
|
+
|
110
|
+
await Band.select(
|
111
|
+
Min(Band.popularity, alias="popularity_min")
|
112
|
+
).run()
|
113
|
+
|
114
|
+
await Band.select(
|
115
|
+
Min(Band.popularity).as_alias("popularity_min")
|
116
|
+
).run()
|
117
|
+
|
118
|
+
"""
|
119
|
+
|
120
|
+
function_name = "MIN"
|
121
|
+
|
122
|
+
|
123
|
+
class Max(Function):
|
124
|
+
"""
|
125
|
+
``MAX()`` SQL function.
|
126
|
+
|
127
|
+
.. code-block:: python
|
128
|
+
|
129
|
+
await Band.select(
|
130
|
+
Max(Band.popularity)
|
131
|
+
).run()
|
132
|
+
|
133
|
+
# We can use an alias. These two are equivalent:
|
134
|
+
|
135
|
+
await Band.select(
|
136
|
+
Max(Band.popularity, alias="popularity_max")
|
137
|
+
).run()
|
138
|
+
|
139
|
+
await Band.select(
|
140
|
+
Max(Band.popularity).as_alias("popularity_max")
|
141
|
+
).run()
|
142
|
+
|
143
|
+
"""
|
144
|
+
|
145
|
+
function_name = "MAX"
|
146
|
+
|
147
|
+
|
148
|
+
class Sum(Function):
|
149
|
+
"""
|
150
|
+
``SUM()`` SQL function. Column type must be numeric to run the query.
|
151
|
+
|
152
|
+
.. code-block:: python
|
153
|
+
|
154
|
+
await Band.select(
|
155
|
+
Sum(Band.popularity)
|
156
|
+
).run()
|
157
|
+
|
158
|
+
# We can use an alias. These two are equivalent:
|
159
|
+
|
160
|
+
await Band.select(
|
161
|
+
Sum(Band.popularity, alias="popularity_sum")
|
162
|
+
).run()
|
163
|
+
|
164
|
+
await Band.select(
|
165
|
+
Sum(Band.popularity).as_alias("popularity_sum")
|
166
|
+
).run()
|
167
|
+
|
168
|
+
"""
|
169
|
+
|
170
|
+
function_name = "SUM"
|
171
|
+
|
172
|
+
|
173
|
+
__all__ = (
|
174
|
+
"Avg",
|
175
|
+
"Count",
|
176
|
+
"Min",
|
177
|
+
"Max",
|
178
|
+
"Sum",
|
179
|
+
)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import typing as t
|
2
|
+
|
3
|
+
from piccolo.columns.base import Column
|
4
|
+
from piccolo.querystring import QueryString
|
5
|
+
|
6
|
+
|
7
|
+
class Function(QueryString):
|
8
|
+
function_name: str
|
9
|
+
|
10
|
+
def __init__(
|
11
|
+
self,
|
12
|
+
identifier: t.Union[Column, QueryString, str],
|
13
|
+
alias: t.Optional[str] = None,
|
14
|
+
):
|
15
|
+
alias = alias or self.__class__.__name__.lower()
|
16
|
+
|
17
|
+
super().__init__(
|
18
|
+
f"{self.function_name}({{}})",
|
19
|
+
identifier,
|
20
|
+
alias=alias,
|
21
|
+
)
|
@@ -0,0 +1,73 @@
|
|
1
|
+
"""
|
2
|
+
These functions mirror their counterparts in the Postgresql docs:
|
3
|
+
|
4
|
+
https://www.postgresql.org/docs/current/functions-string.html
|
5
|
+
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .base import Function
|
9
|
+
|
10
|
+
|
11
|
+
class Length(Function):
|
12
|
+
"""
|
13
|
+
Returns the number of characters in the string.
|
14
|
+
"""
|
15
|
+
|
16
|
+
function_name = "LENGTH"
|
17
|
+
|
18
|
+
|
19
|
+
class Lower(Function):
|
20
|
+
"""
|
21
|
+
Converts the string to all lower case, according to the rules of the
|
22
|
+
database's locale.
|
23
|
+
"""
|
24
|
+
|
25
|
+
function_name = "LOWER"
|
26
|
+
|
27
|
+
|
28
|
+
class Ltrim(Function):
|
29
|
+
"""
|
30
|
+
Removes the longest string containing only characters in characters (a
|
31
|
+
space by default) from the start of string.
|
32
|
+
"""
|
33
|
+
|
34
|
+
function_name = "LTRIM"
|
35
|
+
|
36
|
+
|
37
|
+
class Reverse(Function):
|
38
|
+
"""
|
39
|
+
Return reversed string.
|
40
|
+
|
41
|
+
Not supported in SQLite.
|
42
|
+
|
43
|
+
"""
|
44
|
+
|
45
|
+
function_name = "REVERSE"
|
46
|
+
|
47
|
+
|
48
|
+
class Rtrim(Function):
|
49
|
+
"""
|
50
|
+
Removes the longest string containing only characters in characters (a
|
51
|
+
space by default) from the end of string.
|
52
|
+
"""
|
53
|
+
|
54
|
+
function_name = "RTRIM"
|
55
|
+
|
56
|
+
|
57
|
+
class Upper(Function):
|
58
|
+
"""
|
59
|
+
Converts the string to all upper case, according to the rules of the
|
60
|
+
database's locale.
|
61
|
+
"""
|
62
|
+
|
63
|
+
function_name = "UPPER"
|
64
|
+
|
65
|
+
|
66
|
+
__all__ = (
|
67
|
+
"Length",
|
68
|
+
"Lower",
|
69
|
+
"Ltrim",
|
70
|
+
"Reverse",
|
71
|
+
"Rtrim",
|
72
|
+
"Upper",
|
73
|
+
)
|