piccolo 0.110.0__tar.gz → 0.111.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-0.110.0 → piccolo-0.111.0}/PKG-INFO +1 -1
- piccolo-0.111.0/piccolo/__init__.py +1 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/new.py +1 -1
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/insert.py +61 -5
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/objects.py +2 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/select.py +5 -7
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/mixins.py +168 -4
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/PKG-INFO +1 -1
- piccolo-0.111.0/tests/table/test_insert.py +474 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_select.py +2 -2
- piccolo-0.110.0/piccolo/__init__.py +0 -1
- piccolo-0.110.0/tests/table/test_insert.py +0 -78
- {piccolo-0.110.0 → piccolo-0.111.0}/README.md +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/commands/new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/commands/show_all.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/app/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/commands/load.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/meta/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/meta/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/meta/commands/version.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/meta/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/operations.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/check.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/clean.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/migrations/tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/playground/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/playground/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/playground/commands/run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/playground/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/project/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/project/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/project/commands/new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/project/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/commands/generate.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/commands/graph.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/schema/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/shell/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/shell/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/shell/commands/run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/shell/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/sql_shell/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/tester/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/tester/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/tester/commands/run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/tester/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/commands/change_password.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/commands/create.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/apps/user/tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/choices.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/column_types.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/combination.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/date.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/interval.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/time.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/timestamp.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/timestamptz.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/defaults/uuid.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/indexes.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/m2m.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/operators/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/operators/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/operators/comparison.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/operators/math.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/operators/string.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/readable.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/columns/reference.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/conf/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/conf/apps.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/custom_types.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/cockroach.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/exceptions.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/finder.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/postgres.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/engine/sqlite.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/main.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/py.typed +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/alter.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/count.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/create.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/create_index.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/delete.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/drop_index.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/exists.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/indexes.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/raw.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/refresh.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/table_exists.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/methods/update.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/query/proxy.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/querystring.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/table.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/table_reflection.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/testing/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/testing/model_builder.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/testing/random_builder.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/dictionary.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/encoding.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/graphlib/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/lazy_loader.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/list.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/naming.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/objects.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/printing.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/pydantic.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/repr.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/sql_values.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/sync.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo/utils/warnings.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/SOURCES.txt +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/dependency_links.txt +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/entry_points.txt +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/requires.txt +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/piccolo.egg-info/top_level.txt +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/profiling/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/profiling/run_profile.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/pyproject.toml +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/setup.cfg +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/setup.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/app/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/app/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/app/commands/test_new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/app/commands/test_show_all.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/asgi/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/asgi/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/asgi/commands/test_new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/fixtures/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/meta/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/meta/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/meta/commands/test_version.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/integration/test_migrations.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/test_migration_manager.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_check.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_clean.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/commands/test_new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/migrations/test_migration.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/project/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/project/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/project/commands/test_new.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/schema/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/shell/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/shell/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/shell/commands/test_run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/sql_shell/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/tester/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/commands/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/commands/test_change_password.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/commands/test_create.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/apps/user/test_tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_array.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_base.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_bigint.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_boolean.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_bytea.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_choices.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_combination.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_date.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_db_column_name.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_defaults.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_double_precision.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_interval.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_json.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_jsonb.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_m2m.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_numeric.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_primary_key.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_readable.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_real.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_reference.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_reserved_column_names.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_smallint.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_time.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_timestamp.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_timestamptz.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_uuid.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/columns/test_varchar.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/conf/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/conf/example.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/conf/test_apps.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_extra_nodes.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_logging.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_nested_transaction.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_pool.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_transaction.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/engine/test_version_parsing.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/mega/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/mega/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/mega/tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/music/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/music/piccolo_app.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/music/tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/example_apps/music/tables_detailed.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/mixins/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/mixins/test_columns_delegate.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_await.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_camelcase.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_freeze.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_gather.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_querystring.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/query/test_slots.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_create.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_get_related.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_get_related_readable.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_instantiate.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_remove.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_save.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/instance/test_to_dict.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_all_columns.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_alter.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_batch.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_callback.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_constructor.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_count.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_create.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_create_db_tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_create_table_class.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_delete.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_drop_db_tables.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_exists.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_from_dict.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_indexes.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_inheritance.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_join.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_join_on.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_metaclass.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_objects.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_output.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_raw.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_ref.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_refresh.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_repr.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_str.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_table_exists.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/table/test_update.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/testing/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/testing/test_model_builder.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/testing/test_random_builder.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/__init__.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_dictionary.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_encoding.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_lazy_loader.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_list.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_naming.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_printing.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_pydantic.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_sql_values.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_sync.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_table_reflection.py +0 -0
- {piccolo-0.110.0 → piccolo-0.111.0}/tests/utils/test_warnings.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__VERSION__ = "0.111.0"
|
@@ -12,7 +12,7 @@ TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), "templates/app/")
|
|
12
12
|
SERVERS = ["uvicorn", "Hypercorn"]
|
13
13
|
ROUTERS = ["starlette", "fastapi", "blacksheep", "litestar"]
|
14
14
|
ROUTER_DEPENDENCIES = {
|
15
|
-
"litestar": ["litestar
|
15
|
+
"litestar": ["litestar==2.0.0a3"],
|
16
16
|
}
|
17
17
|
|
18
18
|
|
@@ -2,9 +2,16 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import typing as t
|
4
4
|
|
5
|
-
from
|
5
|
+
from typing_extensions import Literal
|
6
|
+
|
7
|
+
from piccolo.custom_types import Combinable, TableInstance
|
6
8
|
from piccolo.query.base import Query
|
7
|
-
from piccolo.query.mixins import
|
9
|
+
from piccolo.query.mixins import (
|
10
|
+
AddDelegate,
|
11
|
+
OnConflictAction,
|
12
|
+
OnConflictDelegate,
|
13
|
+
ReturningDelegate,
|
14
|
+
)
|
8
15
|
from piccolo.querystring import QueryString
|
9
16
|
|
10
17
|
if t.TYPE_CHECKING: # pragma: no cover
|
@@ -15,7 +22,7 @@ if t.TYPE_CHECKING: # pragma: no cover
|
|
15
22
|
class Insert(
|
16
23
|
t.Generic[TableInstance], Query[TableInstance, t.List[t.Dict[str, t.Any]]]
|
17
24
|
):
|
18
|
-
__slots__ = ("add_delegate", "returning_delegate")
|
25
|
+
__slots__ = ("add_delegate", "on_conflict_delegate", "returning_delegate")
|
19
26
|
|
20
27
|
def __init__(
|
21
28
|
self, table: t.Type[TableInstance], *instances: TableInstance, **kwargs
|
@@ -23,6 +30,7 @@ class Insert(
|
|
23
30
|
super().__init__(table, **kwargs)
|
24
31
|
self.add_delegate = AddDelegate()
|
25
32
|
self.returning_delegate = ReturningDelegate()
|
33
|
+
self.on_conflict_delegate = OnConflictDelegate()
|
26
34
|
self.add(*instances)
|
27
35
|
|
28
36
|
###########################################################################
|
@@ -36,6 +44,43 @@ class Insert(
|
|
36
44
|
self.returning_delegate.returning(columns)
|
37
45
|
return self
|
38
46
|
|
47
|
+
def on_conflict(
|
48
|
+
self: Self,
|
49
|
+
target: t.Optional[t.Union[str, Column, t.Tuple[Column, ...]]] = None,
|
50
|
+
action: t.Union[
|
51
|
+
OnConflictAction, Literal["DO NOTHING", "DO UPDATE"]
|
52
|
+
] = OnConflictAction.do_nothing,
|
53
|
+
values: t.Optional[
|
54
|
+
t.Sequence[t.Union[Column, t.Tuple[Column, t.Any]]]
|
55
|
+
] = None,
|
56
|
+
where: t.Optional[Combinable] = None,
|
57
|
+
) -> Self:
|
58
|
+
if (
|
59
|
+
self.engine_type == "sqlite"
|
60
|
+
and self.table._meta.db.get_version_sync() < 3.24
|
61
|
+
):
|
62
|
+
raise NotImplementedError(
|
63
|
+
"SQLite versions lower than 3.24 don't support ON CONFLICT"
|
64
|
+
)
|
65
|
+
|
66
|
+
if (
|
67
|
+
self.engine_type in ("postgres", "cockroach")
|
68
|
+
and len(self.on_conflict_delegate._on_conflict.on_conflict_items)
|
69
|
+
== 1
|
70
|
+
):
|
71
|
+
raise NotImplementedError(
|
72
|
+
"Postgres and Cockroach only support a single ON CONFLICT "
|
73
|
+
"clause."
|
74
|
+
)
|
75
|
+
|
76
|
+
self.on_conflict_delegate.on_conflict(
|
77
|
+
target=target,
|
78
|
+
action=action,
|
79
|
+
values=values,
|
80
|
+
where=where,
|
81
|
+
)
|
82
|
+
return self
|
83
|
+
|
39
84
|
###########################################################################
|
40
85
|
|
41
86
|
def _raw_response_callback(self, results):
|
@@ -70,16 +115,27 @@ class Insert(
|
|
70
115
|
|
71
116
|
engine_type = self.engine_type
|
72
117
|
|
118
|
+
on_conflict = self.on_conflict_delegate._on_conflict
|
119
|
+
if on_conflict.on_conflict_items:
|
120
|
+
querystring = QueryString(
|
121
|
+
"{}{}",
|
122
|
+
querystring,
|
123
|
+
on_conflict.querystring,
|
124
|
+
query_type="insert",
|
125
|
+
table=self.table,
|
126
|
+
)
|
127
|
+
|
73
128
|
if engine_type in ("postgres", "cockroach") or (
|
74
129
|
engine_type == "sqlite"
|
75
130
|
and self.table._meta.db.get_version_sync() >= 3.35
|
76
131
|
):
|
77
|
-
|
132
|
+
returning = self.returning_delegate._returning
|
133
|
+
if returning:
|
78
134
|
return [
|
79
135
|
QueryString(
|
80
136
|
"{}{}",
|
81
137
|
querystring,
|
82
|
-
|
138
|
+
returning.querystring,
|
83
139
|
query_type="insert",
|
84
140
|
table=self.table,
|
85
141
|
)
|
@@ -230,6 +230,8 @@ class Objects(
|
|
230
230
|
return self
|
231
231
|
|
232
232
|
def as_of(self, interval: str = "-1s") -> Objects:
|
233
|
+
if self.engine_type != "cockroach":
|
234
|
+
raise NotImplementedError("Only CockroachDB supports AS OF")
|
233
235
|
self.as_of_delegate.as_of(interval)
|
234
236
|
return self
|
235
237
|
|
@@ -356,13 +356,8 @@ class Select(Query[TableInstance, t.List[t.Dict[str, t.Any]]]):
|
|
356
356
|
def distinct(
|
357
357
|
self: Self, *, on: t.Optional[t.Sequence[Column]] = None
|
358
358
|
) -> Self:
|
359
|
-
if on is not None and self.engine_type
|
360
|
-
"
|
361
|
-
"cockroach",
|
362
|
-
):
|
363
|
-
raise ValueError(
|
364
|
-
"Only Postgres and Cockroach supports DISTINCT ON"
|
365
|
-
)
|
359
|
+
if on is not None and self.engine_type == "sqlite":
|
360
|
+
raise NotImplementedError("SQLite doesn't support DISTINCT ON")
|
366
361
|
|
367
362
|
self.distinct_delegate.distinct(enabled=True, on=on)
|
368
363
|
return self
|
@@ -377,6 +372,9 @@ class Select(Query[TableInstance, t.List[t.Dict[str, t.Any]]]):
|
|
377
372
|
return self
|
378
373
|
|
379
374
|
def as_of(self: Self, interval: str = "-1s") -> Self:
|
375
|
+
if self.engine_type != "cockroach":
|
376
|
+
raise NotImplementedError("Only CockroachDB supports AS OF")
|
377
|
+
|
380
378
|
self.as_of_delegate.as_of(interval)
|
381
379
|
return self
|
382
380
|
|
@@ -7,6 +7,8 @@ import typing as t
|
|
7
7
|
from dataclasses import dataclass, field
|
8
8
|
from enum import Enum, auto
|
9
9
|
|
10
|
+
from typing_extensions import Literal
|
11
|
+
|
10
12
|
from piccolo.columns import And, Column, Or, Where
|
11
13
|
from piccolo.columns.column_types import ForeignKey
|
12
14
|
from piccolo.custom_types import Combinable
|
@@ -581,9 +583,10 @@ class OffsetDelegate:
|
|
581
583
|
|
582
584
|
Typically used in conjunction with order_by and limit.
|
583
585
|
|
584
|
-
Example usage
|
586
|
+
Example usage::
|
587
|
+
|
588
|
+
.offset(100)
|
585
589
|
|
586
|
-
.offset(100)
|
587
590
|
"""
|
588
591
|
|
589
592
|
_offset: t.Optional[Offset] = None
|
@@ -613,12 +616,173 @@ class GroupBy:
|
|
613
616
|
@dataclass
|
614
617
|
class GroupByDelegate:
|
615
618
|
"""
|
616
|
-
Used to group results - needed when doing aggregation
|
619
|
+
Used to group results - needed when doing aggregation::
|
620
|
+
|
621
|
+
.group_by(Band.name)
|
617
622
|
|
618
|
-
.group_by(Band.name)
|
619
623
|
"""
|
620
624
|
|
621
625
|
_group_by: t.Optional[GroupBy] = None
|
622
626
|
|
623
627
|
def group_by(self, *columns: Column):
|
624
628
|
self._group_by = GroupBy(columns=columns)
|
629
|
+
|
630
|
+
|
631
|
+
class OnConflictAction(str, Enum):
|
632
|
+
"""
|
633
|
+
Specify which action to take on conflict.
|
634
|
+
"""
|
635
|
+
|
636
|
+
do_nothing = "DO NOTHING"
|
637
|
+
do_update = "DO UPDATE"
|
638
|
+
|
639
|
+
|
640
|
+
@dataclass
|
641
|
+
class OnConflictItem:
|
642
|
+
target: t.Optional[t.Union[str, Column, t.Tuple[Column, ...]]] = None
|
643
|
+
action: t.Optional[OnConflictAction] = None
|
644
|
+
values: t.Optional[
|
645
|
+
t.Sequence[t.Union[Column, t.Tuple[Column, t.Any]]]
|
646
|
+
] = None
|
647
|
+
where: t.Optional[Combinable] = None
|
648
|
+
|
649
|
+
@property
|
650
|
+
def target_string(self) -> str:
|
651
|
+
target = self.target
|
652
|
+
assert target
|
653
|
+
|
654
|
+
def to_string(value) -> str:
|
655
|
+
if isinstance(value, Column):
|
656
|
+
return f'"{value._meta.db_column_name}"'
|
657
|
+
else:
|
658
|
+
raise ValueError("OnConflict.target isn't a valid type")
|
659
|
+
|
660
|
+
if isinstance(target, str):
|
661
|
+
return f'ON CONSTRAINT "{target}"'
|
662
|
+
elif isinstance(target, Column):
|
663
|
+
return f"({to_string(target)})"
|
664
|
+
elif isinstance(target, tuple):
|
665
|
+
columns_str = ", ".join([to_string(i) for i in target])
|
666
|
+
return f"({columns_str})"
|
667
|
+
else:
|
668
|
+
raise ValueError("OnConflict.target isn't a valid type")
|
669
|
+
|
670
|
+
@property
|
671
|
+
def action_string(self) -> QueryString:
|
672
|
+
action = self.action
|
673
|
+
if isinstance(action, OnConflictAction):
|
674
|
+
if action == OnConflictAction.do_nothing:
|
675
|
+
return QueryString(OnConflictAction.do_nothing.value)
|
676
|
+
elif action == OnConflictAction.do_update:
|
677
|
+
values = []
|
678
|
+
query = f"{OnConflictAction.do_update.value} SET"
|
679
|
+
|
680
|
+
if not self.values:
|
681
|
+
raise ValueError("No values specified for `on conflict`")
|
682
|
+
|
683
|
+
for value in self.values:
|
684
|
+
if isinstance(value, Column):
|
685
|
+
column_name = value._meta.db_column_name
|
686
|
+
query += f' "{column_name}"=EXCLUDED."{column_name}",'
|
687
|
+
elif isinstance(value, tuple):
|
688
|
+
column = value[0]
|
689
|
+
value_ = value[1]
|
690
|
+
if isinstance(column, Column):
|
691
|
+
column_name = column._meta.db_column_name
|
692
|
+
else:
|
693
|
+
raise ValueError("Unsupported column type")
|
694
|
+
|
695
|
+
query += f' "{column_name}"={{}},'
|
696
|
+
values.append(value_)
|
697
|
+
|
698
|
+
return QueryString(query.rstrip(","), *values)
|
699
|
+
|
700
|
+
raise ValueError("OnConflict.action isn't a valid type")
|
701
|
+
|
702
|
+
@property
|
703
|
+
def querystring(self) -> QueryString:
|
704
|
+
query = " ON CONFLICT"
|
705
|
+
values = []
|
706
|
+
|
707
|
+
if self.target:
|
708
|
+
query += f" {self.target_string}"
|
709
|
+
|
710
|
+
if self.action:
|
711
|
+
query += " {}"
|
712
|
+
values.append(self.action_string)
|
713
|
+
|
714
|
+
if self.where:
|
715
|
+
query += " WHERE {}"
|
716
|
+
values.append(self.where.querystring)
|
717
|
+
|
718
|
+
return QueryString(query, *values)
|
719
|
+
|
720
|
+
def __str__(self) -> str:
|
721
|
+
return self.querystring.__str__()
|
722
|
+
|
723
|
+
|
724
|
+
@dataclass
|
725
|
+
class OnConflict:
|
726
|
+
"""
|
727
|
+
Multiple `ON CONFLICT` statements are allowed - which is why we have this
|
728
|
+
parent class.
|
729
|
+
"""
|
730
|
+
|
731
|
+
on_conflict_items: t.List[OnConflictItem] = field(default_factory=list)
|
732
|
+
|
733
|
+
@property
|
734
|
+
def querystring(self) -> QueryString:
|
735
|
+
query = "".join("{}" for i in self.on_conflict_items)
|
736
|
+
return QueryString(
|
737
|
+
query, *[i.querystring for i in self.on_conflict_items]
|
738
|
+
)
|
739
|
+
|
740
|
+
def __str__(self) -> str:
|
741
|
+
return self.querystring.__str__()
|
742
|
+
|
743
|
+
|
744
|
+
@dataclass
|
745
|
+
class OnConflictDelegate:
|
746
|
+
"""
|
747
|
+
Used with insert queries to specify what to do when a query fails due to
|
748
|
+
a constraint::
|
749
|
+
|
750
|
+
.on_conflict(action='DO NOTHING')
|
751
|
+
|
752
|
+
.on_conflict(action='DO UPDATE', values=[Band.popularity])
|
753
|
+
|
754
|
+
.on_conflict(action='DO UPDATE', values=[(Band.popularity, 1)])
|
755
|
+
|
756
|
+
"""
|
757
|
+
|
758
|
+
_on_conflict: OnConflict = field(default_factory=OnConflict)
|
759
|
+
|
760
|
+
def on_conflict(
|
761
|
+
self,
|
762
|
+
target: t.Optional[t.Union[str, Column, t.Tuple[Column, ...]]] = None,
|
763
|
+
action: t.Union[
|
764
|
+
OnConflictAction, Literal["DO NOTHING", "DO UPDATE"]
|
765
|
+
] = OnConflictAction.do_nothing,
|
766
|
+
values: t.Optional[
|
767
|
+
t.Sequence[t.Union[Column, t.Tuple[Column, t.Any]]]
|
768
|
+
] = None,
|
769
|
+
where: t.Optional[Combinable] = None,
|
770
|
+
):
|
771
|
+
action_: OnConflictAction
|
772
|
+
if isinstance(action, OnConflictAction):
|
773
|
+
action_ = action
|
774
|
+
elif isinstance(action, str):
|
775
|
+
action_ = OnConflictAction(action.upper())
|
776
|
+
else:
|
777
|
+
raise ValueError("Unrecognised `on conflict` action.")
|
778
|
+
|
779
|
+
if where and action_ == OnConflictAction.do_nothing:
|
780
|
+
raise ValueError(
|
781
|
+
"The `where` option can only be used with DO NOTHING."
|
782
|
+
)
|
783
|
+
|
784
|
+
self._on_conflict.on_conflict_items.append(
|
785
|
+
OnConflictItem(
|
786
|
+
target=target, action=action_, values=values, where=where
|
787
|
+
)
|
788
|
+
)
|