piccolo 1.8.0__tar.gz → 1.9.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {piccolo-1.8.0 → piccolo-1.9.0}/PKG-INFO +1 -1
- piccolo-1.9.0/piccolo/__init__.py +1 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/base.py +55 -29
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/base.py +5 -3
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/functions/__init__.py +5 -0
- piccolo-1.9.0/piccolo/query/functions/math.py +48 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/querystring.py +18 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/schema.py +2 -1
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/PKG-INFO +1 -1
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/SOURCES.txt +8 -1
- {piccolo-1.8.0 → piccolo-1.9.0}/pyproject.toml +2 -1
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_array.py +63 -19
- piccolo-1.9.0/tests/columns/test_get_sql_value.py +66 -0
- piccolo-1.9.0/tests/query/functions/base.py +34 -0
- piccolo-1.9.0/tests/query/functions/test_functions.py +64 -0
- piccolo-1.9.0/tests/query/functions/test_math.py +39 -0
- piccolo-1.9.0/tests/query/functions/test_string.py +25 -0
- piccolo-1.9.0/tests/query/functions/test_type_conversion.py +134 -0
- piccolo-1.9.0/tests/query/test_querystring.py +166 -0
- piccolo-1.9.0/tests/utils/__init__.py +0 -0
- piccolo-1.8.0/piccolo/__init__.py +0 -1
- piccolo-1.8.0/tests/query/test_functions.py +0 -238
- piccolo-1.8.0/tests/query/test_querystring.py +0 -30
- {piccolo-1.8.0 → piccolo-1.9.0}/LICENSE +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/README.md +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/commands/new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/commands/show_all.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/commands/templates/piccolo_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/commands/templates/tables.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/app/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/README.md.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_blacksheep_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_esmerald_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_fastapi_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_lilya_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_litestar_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/_starlette_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/conftest.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/__init__.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_blacksheep_endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_esmerald_endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_lilya_endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_litestar_endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/_starlette_endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/endpoints.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_app.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/piccolo_migrations/README.md +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/tables.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/templates/base.html.jinja_raw +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/home/templates/home.html.jinja_raw +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/main.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/piccolo_conf_test.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/requirements.txt.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/static/favicon.ico +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/commands/templates/app/static/main.css +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/asgi/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/dump.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/load.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/commands/shared.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/fixtures/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/meta/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/meta/commands/version.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/meta/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/diffable_table.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/migration_manager.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/operations.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/schema_differ.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/schema_snapshot.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/serialisation.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/auto/serialisation_legacy.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/backwards.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/check.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/clean.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/forwards.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/commands/templates/migration.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/migrations/tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/playground/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/playground/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/playground/commands/run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/playground/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/project/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/project/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/project/commands/new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/project/commands/templates/piccolo_conf.py.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/project/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/exceptions.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/generate.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/graph.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/commands/templates/graphviz.dot.jinja +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/schema/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/shell/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/shell/commands/run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/shell/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/commands/run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/sql_shell/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/tester/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/tester/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/tester/commands/run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/tester/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/commands/change_password.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/commands/change_permissions.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/commands/create.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/commands/list.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2019-11-14T21-52-21.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2020-06-11T21-38-55.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/2021-04-30T16-14-15.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/apps/user/tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/choices.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/column_types.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/combination.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/date.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/interval.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/time.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/timestamp.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/timestamptz.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/defaults/uuid.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/indexes.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/m2m.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/operators/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/operators/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/operators/comparison.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/operators/math.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/operators/string.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/readable.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/columns/reference.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/conf/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/conf/apps.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/custom_types.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/cockroach.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/exceptions.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/finder.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/postgres.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/engine/sqlite.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/main.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/py.typed +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/functions/aggregate.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/functions/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/functions/string.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/functions/type_conversion.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/alter.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/count.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/create.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/create_index.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/delete.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/drop_index.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/exists.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/indexes.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/insert.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/objects.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/raw.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/refresh.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/select.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/table_exists.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/methods/update.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/mixins.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/query/proxy.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/table.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/table_reflection.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/testing/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/testing/model_builder.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/testing/random_builder.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/dictionary.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/encoding.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/graphlib/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/graphlib/_graphlib.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/lazy_loader.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/list.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/naming.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/objects.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/printing.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/pydantic.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/repr.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/sql_values.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/sync.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo/utils/warnings.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/dependency_links.txt +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/entry_points.txt +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/requires.txt +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/piccolo.egg-info/top_level.txt +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/profiling/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/profiling/run_profile.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/setup.cfg +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/setup.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/app/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/app/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/app/commands/test_new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/app/commands/test_show_all.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/asgi/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/asgi/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/asgi/commands/test_new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/fixtures/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/test_dump_load.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/fixtures/commands/test_shared.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/meta/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/meta/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/meta/commands/test_version.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/integration/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/integration/test_migrations.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_diffable_table.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_migration_manager.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_schema_differ.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_schema_snapshot.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/auto/test_serialisation.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_check.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_clean.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_forwards_backwards.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_migrations/2020-03-31T20-38-22.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_migrations/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/commands/test_new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/migrations/test_migration.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/project/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/project/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/project/commands/test_new.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/schema/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/shell/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/shell/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/shell/commands/test_run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/sql_shell/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/sql_shell/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/sql_shell/commands/test_run.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/tester/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/commands/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/commands/test_change_password.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/commands/test_change_permissions.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/commands/test_create.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/commands/test_list.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/apps/user/test_tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/m2m/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/m2m/base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/m2m/test_m2m.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/m2m/test_m2m_schema.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_base.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_bigint.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_boolean.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_bytea.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_choices.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_combination.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_date.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_db_column_name.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_defaults.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_double_precision.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_interval.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_json.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_jsonb.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_numeric.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_primary_key.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_readable.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_real.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_reference.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_reserved_column_names.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_smallint.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_time.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_timestamp.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_timestamptz.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_uuid.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/columns/test_varchar.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/conf/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/conf/example.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/conf/test_apps.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_extra_nodes.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_logging.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_nested_transaction.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_pool.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_transaction.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/engine/test_version_parsing.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/mega/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_migrations/2021-09-20T21-23-25-698988.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/mega/piccolo_migrations/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/mega/tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/music/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/music/piccolo_app.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/music/tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/example_apps/music/tables_detailed.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/__init__.py +0 -0
- {piccolo-1.8.0/tests/query/mixins → piccolo-1.9.0/tests/query/functions}/__init__.py +0 -0
- {piccolo-1.8.0/tests/table → piccolo-1.9.0/tests/query/mixins}/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/mixins/test_columns_delegate.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/mixins/test_order_by_delegate.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/test_await.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/test_camelcase.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/test_freeze.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/test_gather.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/query/test_slots.py +0 -0
- {piccolo-1.8.0/tests/table/instance → piccolo-1.9.0/tests/table}/__init__.py +0 -0
- {piccolo-1.8.0/tests/testing → piccolo-1.9.0/tests/table/instance}/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_create.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_get_related.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_get_related_readable.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_instantiate.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_remove.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_save.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/instance/test_to_dict.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_all_columns.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_alter.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_batch.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_callback.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_constructor.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_count.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_create.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_create_db_tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_create_table_class.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_delete.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_drop_db_tables.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_exists.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_from_dict.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_indexes.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_inheritance.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_insert.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_join.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_join_on.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_metaclass.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_objects.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_output.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_raw.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_ref.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_refresh.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_repr.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_select.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_str.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_table_exists.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/table/test_update.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/test_main.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/test_schema.py +0 -0
- {piccolo-1.8.0/tests/utils → piccolo-1.9.0/tests/testing}/__init__.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/testing/test_model_builder.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/testing/test_random_builder.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_dictionary.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_encoding.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_lazy_loader.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_list.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_naming.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_printing.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_pydantic.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_sql_values.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_sync.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_table_reflection.py +0 -0
- {piccolo-1.8.0 → piccolo-1.9.0}/tests/utils/test_warnings.py +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
__VERSION__ = "1.9.0"
|
@@ -830,7 +830,11 @@ class Column(Selectable):
|
|
830
830
|
engine_type=engine_type, with_alias=False
|
831
831
|
)
|
832
832
|
|
833
|
-
def get_sql_value(
|
833
|
+
def get_sql_value(
|
834
|
+
self,
|
835
|
+
value: t.Any,
|
836
|
+
delimiter: str = "'",
|
837
|
+
) -> str:
|
834
838
|
"""
|
835
839
|
When using DDL statements, we can't parameterise the values. An example
|
836
840
|
is when setting the default for a column. So we have to convert from
|
@@ -839,11 +843,18 @@ class Column(Selectable):
|
|
839
843
|
|
840
844
|
:param value:
|
841
845
|
The Python value to convert to a string usable in a DDL statement
|
842
|
-
e.g. 1
|
846
|
+
e.g. ``1``.
|
847
|
+
:param delimiter:
|
848
|
+
The string returned by this function is wrapped in delimiters,
|
849
|
+
ready to be added to a DDL statement. For example:
|
850
|
+
``'hello world'``.
|
843
851
|
:returns:
|
844
|
-
The string usable in the DDL statement e.g. '1'
|
852
|
+
The string usable in the DDL statement e.g. ``'1'``.
|
845
853
|
|
846
854
|
"""
|
855
|
+
from piccolo.engine.sqlite import ADAPTERS as sqlite_adapters
|
856
|
+
|
857
|
+
# Common across all DB engines
|
847
858
|
if isinstance(value, Default):
|
848
859
|
return getattr(value, self._meta.engine_type)
|
849
860
|
elif value is None:
|
@@ -851,37 +862,52 @@ class Column(Selectable):
|
|
851
862
|
elif isinstance(value, (float, decimal.Decimal)):
|
852
863
|
return str(value)
|
853
864
|
elif isinstance(value, str):
|
854
|
-
return f"
|
865
|
+
return f"{delimiter}{value}{delimiter}"
|
855
866
|
elif isinstance(value, bool):
|
856
867
|
return str(value).lower()
|
857
|
-
elif isinstance(value, datetime.datetime):
|
858
|
-
return f"'{value.isoformat().replace('T', ' ')}'"
|
859
|
-
elif isinstance(value, datetime.date):
|
860
|
-
return f"'{value.isoformat()}'"
|
861
|
-
elif isinstance(value, datetime.time):
|
862
|
-
return f"'{value.isoformat()}'"
|
863
|
-
elif isinstance(value, datetime.timedelta):
|
864
|
-
interval = IntervalCustom.from_timedelta(value)
|
865
|
-
return getattr(interval, self._meta.engine_type)
|
866
868
|
elif isinstance(value, bytes):
|
867
|
-
return f"
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
(
|
876
|
-
|
877
|
-
|
878
|
-
|
869
|
+
return f"{delimiter}{value.hex()}{delimiter}"
|
870
|
+
|
871
|
+
# SQLite specific
|
872
|
+
if self._meta.engine_type == "sqlite":
|
873
|
+
if adapter := sqlite_adapters.get(type(value)):
|
874
|
+
sqlite_value = adapter(value)
|
875
|
+
return (
|
876
|
+
f"{delimiter}{sqlite_value}{delimiter}"
|
877
|
+
if isinstance(sqlite_value, str)
|
878
|
+
else sqlite_value
|
879
|
+
)
|
880
|
+
|
881
|
+
# Postgres and Cockroach
|
882
|
+
if self._meta.engine_type in ["postgres", "cockroach"]:
|
883
|
+
if isinstance(value, datetime.datetime):
|
884
|
+
return f"{delimiter}{value.isoformat().replace('T', ' ')}{delimiter}" # noqa: E501
|
885
|
+
elif isinstance(value, datetime.date):
|
886
|
+
return f"{delimiter}{value.isoformat()}{delimiter}"
|
887
|
+
elif isinstance(value, datetime.time):
|
888
|
+
return f"{delimiter}{value.isoformat()}{delimiter}"
|
889
|
+
elif isinstance(value, datetime.timedelta):
|
890
|
+
interval = IntervalCustom.from_timedelta(value)
|
891
|
+
return getattr(interval, self._meta.engine_type)
|
892
|
+
elif isinstance(value, uuid.UUID):
|
893
|
+
return f"{delimiter}{value}{delimiter}"
|
894
|
+
elif isinstance(value, list):
|
895
|
+
# Convert to the array syntax.
|
896
|
+
return (
|
897
|
+
delimiter
|
898
|
+
+ "{"
|
899
|
+
+ ",".join(
|
900
|
+
self.get_sql_value(
|
901
|
+
i,
|
902
|
+
delimiter="" if isinstance(i, list) else '"',
|
903
|
+
)
|
904
|
+
for i in value
|
879
905
|
)
|
880
|
-
|
906
|
+
+ "}"
|
907
|
+
+ delimiter
|
881
908
|
)
|
882
|
-
|
883
|
-
|
884
|
-
return value
|
909
|
+
|
910
|
+
return str(value)
|
885
911
|
|
886
912
|
@property
|
887
913
|
def column_type(self):
|
@@ -1,17 +1,19 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import typing as t
|
4
|
-
from abc import ABC, abstractmethod
|
4
|
+
from abc import ABC, abstractmethod
|
5
5
|
|
6
6
|
from piccolo.utils.repr import repr_class_instance
|
7
7
|
|
8
8
|
|
9
9
|
class Default(ABC):
|
10
|
-
@
|
10
|
+
@property
|
11
|
+
@abstractmethod
|
11
12
|
def postgres(self) -> str:
|
12
13
|
pass
|
13
14
|
|
14
|
-
@
|
15
|
+
@property
|
16
|
+
@abstractmethod
|
15
17
|
def sqlite(self) -> str:
|
16
18
|
pass
|
17
19
|
|
@@ -1,17 +1,22 @@
|
|
1
1
|
from .aggregate import Avg, Count, Max, Min, Sum
|
2
|
+
from .math import Abs, Ceil, Floor, Round
|
2
3
|
from .string import Length, Lower, Ltrim, Reverse, Rtrim, Upper
|
3
4
|
from .type_conversion import Cast
|
4
5
|
|
5
6
|
__all__ = (
|
7
|
+
"Abs",
|
6
8
|
"Avg",
|
7
9
|
"Cast",
|
10
|
+
"Ceil",
|
8
11
|
"Count",
|
12
|
+
"Floor",
|
9
13
|
"Length",
|
10
14
|
"Lower",
|
11
15
|
"Ltrim",
|
12
16
|
"Max",
|
13
17
|
"Min",
|
14
18
|
"Reverse",
|
19
|
+
"Round",
|
15
20
|
"Rtrim",
|
16
21
|
"Sum",
|
17
22
|
"Upper",
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"""
|
2
|
+
These functions mirror their counterparts in the Postgresql docs:
|
3
|
+
|
4
|
+
https://www.postgresql.org/docs/current/functions-math.html
|
5
|
+
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .base import Function
|
9
|
+
|
10
|
+
|
11
|
+
class Abs(Function):
|
12
|
+
"""
|
13
|
+
Absolute value.
|
14
|
+
"""
|
15
|
+
|
16
|
+
function_name = "ABS"
|
17
|
+
|
18
|
+
|
19
|
+
class Ceil(Function):
|
20
|
+
"""
|
21
|
+
Nearest integer greater than or equal to argument.
|
22
|
+
"""
|
23
|
+
|
24
|
+
function_name = "CEIL"
|
25
|
+
|
26
|
+
|
27
|
+
class Floor(Function):
|
28
|
+
"""
|
29
|
+
Nearest integer less than or equal to argument.
|
30
|
+
"""
|
31
|
+
|
32
|
+
function_name = "FLOOR"
|
33
|
+
|
34
|
+
|
35
|
+
class Round(Function):
|
36
|
+
"""
|
37
|
+
Rounds to nearest integer.
|
38
|
+
"""
|
39
|
+
|
40
|
+
function_name = "ROUND"
|
41
|
+
|
42
|
+
|
43
|
+
__all__ = (
|
44
|
+
"Abs",
|
45
|
+
"Ceil",
|
46
|
+
"Floor",
|
47
|
+
"Round",
|
48
|
+
)
|
@@ -282,12 +282,30 @@ class QueryString(Selectable):
|
|
282
282
|
def __le__(self, value) -> QueryString:
|
283
283
|
return QueryString("{} <= {}", self, value)
|
284
284
|
|
285
|
+
def __truediv__(self, value) -> QueryString:
|
286
|
+
return QueryString("{} / {}", self, value)
|
287
|
+
|
288
|
+
def __mul__(self, value) -> QueryString:
|
289
|
+
return QueryString("{} * {}", self, value)
|
290
|
+
|
291
|
+
def __pow__(self, value) -> QueryString:
|
292
|
+
return QueryString("{} ^ {}", self, value)
|
293
|
+
|
294
|
+
def __mod__(self, value) -> QueryString:
|
295
|
+
return QueryString("{} % {}", self, value)
|
296
|
+
|
285
297
|
def is_in(self, value) -> QueryString:
|
286
298
|
return QueryString("{} IN {}", self, value)
|
287
299
|
|
288
300
|
def not_in(self, value) -> QueryString:
|
289
301
|
return QueryString("{} NOT IN {}", self, value)
|
290
302
|
|
303
|
+
def like(self, value: str) -> QueryString:
|
304
|
+
return QueryString("{} LIKE {}", self, value)
|
305
|
+
|
306
|
+
def ilike(self, value: str) -> QueryString:
|
307
|
+
return QueryString("{} ILIKE {}", self, value)
|
308
|
+
|
291
309
|
|
292
310
|
class Unquoted(QueryString):
|
293
311
|
"""
|
@@ -162,6 +162,7 @@ piccolo/query/proxy.py
|
|
162
162
|
piccolo/query/functions/__init__.py
|
163
163
|
piccolo/query/functions/aggregate.py
|
164
164
|
piccolo/query/functions/base.py
|
165
|
+
piccolo/query/functions/math.py
|
165
166
|
piccolo/query/functions/string.py
|
166
167
|
piccolo/query/functions/type_conversion.py
|
167
168
|
piccolo/query/methods/__init__.py
|
@@ -265,6 +266,7 @@ tests/columns/test_date.py
|
|
265
266
|
tests/columns/test_db_column_name.py
|
266
267
|
tests/columns/test_defaults.py
|
267
268
|
tests/columns/test_double_precision.py
|
269
|
+
tests/columns/test_get_sql_value.py
|
268
270
|
tests/columns/test_interval.py
|
269
271
|
tests/columns/test_json.py
|
270
272
|
tests/columns/test_jsonb.py
|
@@ -308,10 +310,15 @@ tests/query/__init__.py
|
|
308
310
|
tests/query/test_await.py
|
309
311
|
tests/query/test_camelcase.py
|
310
312
|
tests/query/test_freeze.py
|
311
|
-
tests/query/test_functions.py
|
312
313
|
tests/query/test_gather.py
|
313
314
|
tests/query/test_querystring.py
|
314
315
|
tests/query/test_slots.py
|
316
|
+
tests/query/functions/__init__.py
|
317
|
+
tests/query/functions/base.py
|
318
|
+
tests/query/functions/test_functions.py
|
319
|
+
tests/query/functions/test_math.py
|
320
|
+
tests/query/functions/test_string.py
|
321
|
+
tests/query/functions/test_type_conversion.py
|
315
322
|
tests/query/mixins/__init__.py
|
316
323
|
tests/query/mixins/test_columns_delegate.py
|
317
324
|
tests/query/mixins/test_order_by_delegate.py
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import datetime
|
2
2
|
from unittest import TestCase
|
3
3
|
|
4
|
+
import pytest
|
5
|
+
|
4
6
|
from piccolo.columns.column_types import (
|
5
7
|
Array,
|
6
8
|
BigInt,
|
@@ -10,8 +12,9 @@ from piccolo.columns.column_types import (
|
|
10
12
|
Timestamp,
|
11
13
|
Timestamptz,
|
12
14
|
)
|
15
|
+
from piccolo.querystring import QueryString
|
13
16
|
from piccolo.table import Table
|
14
|
-
from tests.base import engines_only, sqlite_only
|
17
|
+
from tests.base import engines_only, engines_skip, sqlite_only
|
15
18
|
|
16
19
|
|
17
20
|
class MyTable(Table):
|
@@ -40,12 +43,18 @@ class TestArray(TestCase):
|
|
40
43
|
def tearDown(self):
|
41
44
|
MyTable.alter().drop_table().run_sync()
|
42
45
|
|
43
|
-
@
|
46
|
+
@pytest.mark.cockroach_array_slow
|
44
47
|
def test_storage(self):
|
45
48
|
"""
|
46
49
|
Make sure data can be stored and retrieved.
|
47
50
|
|
48
|
-
|
51
|
+
In CockroachDB <= v22.2.0 we had this error:
|
52
|
+
|
53
|
+
* https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
|
54
|
+
|
55
|
+
In newer CockroachDB versions, it runs but is very slow:
|
56
|
+
|
57
|
+
* https://github.com/piccolo-orm/piccolo/issues/1005
|
49
58
|
|
50
59
|
""" # noqa: E501
|
51
60
|
MyTable(value=[1, 2, 3]).save().run_sync()
|
@@ -54,12 +63,19 @@ class TestArray(TestCase):
|
|
54
63
|
assert row is not None
|
55
64
|
self.assertEqual(row.value, [1, 2, 3])
|
56
65
|
|
57
|
-
@
|
66
|
+
@engines_skip("sqlite")
|
67
|
+
@pytest.mark.cockroach_array_slow
|
58
68
|
def test_index(self):
|
59
69
|
"""
|
60
70
|
Indexes should allow individual array elements to be queried.
|
61
71
|
|
62
|
-
|
72
|
+
In CockroachDB <= v22.2.0 we had this error:
|
73
|
+
|
74
|
+
* https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
|
75
|
+
|
76
|
+
In newer CockroachDB versions, it runs but is very slow:
|
77
|
+
|
78
|
+
* https://github.com/piccolo-orm/piccolo/issues/1005
|
63
79
|
|
64
80
|
""" # noqa: E501
|
65
81
|
MyTable(value=[1, 2, 3]).save().run_sync()
|
@@ -68,66 +84,92 @@ class TestArray(TestCase):
|
|
68
84
|
MyTable.select(MyTable.value[0]).first().run_sync(), {"value": 1}
|
69
85
|
)
|
70
86
|
|
71
|
-
@
|
87
|
+
@engines_skip("sqlite")
|
88
|
+
@pytest.mark.cockroach_array_slow
|
72
89
|
def test_all(self):
|
73
90
|
"""
|
74
91
|
Make sure rows can be retrieved where all items in an array match a
|
75
92
|
given value.
|
76
93
|
|
77
|
-
|
94
|
+
In CockroachDB <= v22.2.0 we had this error:
|
95
|
+
|
96
|
+
* https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
|
97
|
+
|
98
|
+
In newer CockroachDB versions, it runs but is very slow:
|
99
|
+
|
100
|
+
* https://github.com/piccolo-orm/piccolo/issues/1005
|
78
101
|
|
79
102
|
""" # noqa: E501
|
80
103
|
MyTable(value=[1, 1, 1]).save().run_sync()
|
81
104
|
|
105
|
+
# We have to explicitly specify the type, so CockroachDB works.
|
82
106
|
self.assertEqual(
|
83
107
|
MyTable.select(MyTable.value)
|
84
|
-
.where(MyTable.value.all(1))
|
108
|
+
.where(MyTable.value.all(QueryString("{}::INTEGER", 1)))
|
85
109
|
.first()
|
86
110
|
.run_sync(),
|
87
111
|
{"value": [1, 1, 1]},
|
88
112
|
)
|
89
113
|
|
114
|
+
# We have to explicitly specify the type, so CockroachDB works.
|
90
115
|
self.assertEqual(
|
91
116
|
MyTable.select(MyTable.value)
|
92
|
-
.where(MyTable.value.all(0))
|
117
|
+
.where(MyTable.value.all(QueryString("{}::INTEGER", 0)))
|
93
118
|
.first()
|
94
119
|
.run_sync(),
|
95
120
|
None,
|
96
121
|
)
|
97
122
|
|
98
|
-
@
|
123
|
+
@engines_skip("sqlite")
|
124
|
+
@pytest.mark.cockroach_array_slow
|
99
125
|
def test_any(self):
|
100
126
|
"""
|
101
127
|
Make sure rows can be retrieved where any items in an array match a
|
102
128
|
given value.
|
103
129
|
|
104
|
-
|
130
|
+
In CockroachDB <= v22.2.0 we had this error:
|
131
|
+
|
132
|
+
* https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
|
133
|
+
|
134
|
+
In newer CockroachDB versions, it runs but is very slow:
|
135
|
+
|
136
|
+
* https://github.com/piccolo-orm/piccolo/issues/1005
|
105
137
|
|
106
138
|
""" # noqa: E501
|
139
|
+
|
107
140
|
MyTable(value=[1, 2, 3]).save().run_sync()
|
108
141
|
|
142
|
+
# We have to explicitly specify the type, so CockroachDB works.
|
109
143
|
self.assertEqual(
|
110
144
|
MyTable.select(MyTable.value)
|
111
|
-
.where(MyTable.value.any(1))
|
145
|
+
.where(MyTable.value.any(QueryString("{}::INTEGER", 1)))
|
112
146
|
.first()
|
113
147
|
.run_sync(),
|
114
148
|
{"value": [1, 2, 3]},
|
115
149
|
)
|
116
150
|
|
151
|
+
# We have to explicitly specify the type, so CockroachDB works.
|
117
152
|
self.assertEqual(
|
118
153
|
MyTable.select(MyTable.value)
|
119
|
-
.where(MyTable.value.any(0))
|
154
|
+
.where(MyTable.value.any(QueryString("{}::INTEGER", 0)))
|
120
155
|
.first()
|
121
156
|
.run_sync(),
|
122
157
|
None,
|
123
158
|
)
|
124
159
|
|
125
|
-
@
|
160
|
+
@engines_skip("sqlite")
|
161
|
+
@pytest.mark.cockroach_array_slow
|
126
162
|
def test_cat(self):
|
127
163
|
"""
|
128
164
|
Make sure values can be appended to an array.
|
129
165
|
|
130
|
-
|
166
|
+
In CockroachDB <= v22.2.0 we had this error:
|
167
|
+
|
168
|
+
* https://github.com/cockroachdb/cockroach/issues/71908 "could not decorrelate subquery" error under asyncpg
|
169
|
+
|
170
|
+
In newer CockroachDB versions, it runs but is very slow:
|
171
|
+
|
172
|
+
* https://github.com/piccolo-orm/piccolo/issues/1005
|
131
173
|
|
132
174
|
""" # noqa: E501
|
133
175
|
MyTable(value=[1, 1, 1]).save().run_sync()
|
@@ -137,7 +179,8 @@ class TestArray(TestCase):
|
|
137
179
|
).run_sync()
|
138
180
|
|
139
181
|
self.assertEqual(
|
140
|
-
MyTable.select().run_sync(),
|
182
|
+
MyTable.select(MyTable.value).run_sync(),
|
183
|
+
[{"value": [1, 1, 1, 2]}],
|
141
184
|
)
|
142
185
|
|
143
186
|
# Try plus symbol
|
@@ -147,7 +190,8 @@ class TestArray(TestCase):
|
|
147
190
|
).run_sync()
|
148
191
|
|
149
192
|
self.assertEqual(
|
150
|
-
MyTable.select().run_sync(),
|
193
|
+
MyTable.select(MyTable.value).run_sync(),
|
194
|
+
[{"value": [1, 1, 1, 2, 3]}],
|
151
195
|
)
|
152
196
|
|
153
197
|
# Make sure non-list values work
|
@@ -157,8 +201,8 @@ class TestArray(TestCase):
|
|
157
201
|
).run_sync()
|
158
202
|
|
159
203
|
self.assertEqual(
|
160
|
-
MyTable.select().run_sync(),
|
161
|
-
[{"
|
204
|
+
MyTable.select(MyTable.value).run_sync(),
|
205
|
+
[{"value": [1, 1, 1, 2, 3, 4]}],
|
162
206
|
)
|
163
207
|
|
164
208
|
@sqlite_only
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import datetime
|
2
|
+
from unittest import TestCase
|
3
|
+
|
4
|
+
from tests.base import engines_only
|
5
|
+
from tests.example_apps.music.tables import Band
|
6
|
+
|
7
|
+
|
8
|
+
@engines_only("postgres", "cockroach")
|
9
|
+
class TestArrayPostgres(TestCase):
|
10
|
+
|
11
|
+
def test_string(self):
|
12
|
+
self.assertEqual(
|
13
|
+
Band.name.get_sql_value(["a", "b", "c"]),
|
14
|
+
'\'{"a","b","c"}\'',
|
15
|
+
)
|
16
|
+
|
17
|
+
def test_int(self):
|
18
|
+
self.assertEqual(
|
19
|
+
Band.name.get_sql_value([1, 2, 3]),
|
20
|
+
"'{1,2,3}'",
|
21
|
+
)
|
22
|
+
|
23
|
+
def test_nested(self):
|
24
|
+
self.assertEqual(
|
25
|
+
Band.name.get_sql_value([1, 2, 3, [4, 5, 6]]),
|
26
|
+
"'{1,2,3,{4,5,6}}'",
|
27
|
+
)
|
28
|
+
|
29
|
+
def test_time(self):
|
30
|
+
self.assertEqual(
|
31
|
+
Band.name.get_sql_value([datetime.time(hour=8, minute=0)]),
|
32
|
+
"'{\"08:00:00\"}'",
|
33
|
+
)
|
34
|
+
|
35
|
+
|
36
|
+
@engines_only("sqlite")
|
37
|
+
class TestArraySQLite(TestCase):
|
38
|
+
"""
|
39
|
+
Note, we use ``.replace(" ", "")`` because we serialise arrays using
|
40
|
+
Python's json library, and there is inconsistency between Python versions
|
41
|
+
(some output ``["a", "b", "c"]``, and others ``["a","b","c"]``).
|
42
|
+
"""
|
43
|
+
|
44
|
+
def test_string(self):
|
45
|
+
self.assertEqual(
|
46
|
+
Band.name.get_sql_value(["a", "b", "c"]).replace(" ", ""),
|
47
|
+
'\'["a","b","c"]\'',
|
48
|
+
)
|
49
|
+
|
50
|
+
def test_int(self):
|
51
|
+
self.assertEqual(
|
52
|
+
Band.name.get_sql_value([1, 2, 3]).replace(" ", ""),
|
53
|
+
"'[1,2,3]'",
|
54
|
+
)
|
55
|
+
|
56
|
+
def test_nested(self):
|
57
|
+
self.assertEqual(
|
58
|
+
Band.name.get_sql_value([1, 2, 3, [4, 5, 6]]).replace(" ", ""),
|
59
|
+
"'[1,2,3,[4,5,6]]'",
|
60
|
+
)
|
61
|
+
|
62
|
+
def test_time(self):
|
63
|
+
self.assertEqual(
|
64
|
+
Band.name.get_sql_value([datetime.time(hour=8, minute=0)]),
|
65
|
+
"'[\"08:00:00\"]'",
|
66
|
+
)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import typing as t
|
2
|
+
from unittest import TestCase
|
3
|
+
|
4
|
+
from piccolo.table import Table, create_db_tables_sync, drop_db_tables_sync
|
5
|
+
from tests.example_apps.music.tables import Band, Manager
|
6
|
+
|
7
|
+
|
8
|
+
class FunctionTest(TestCase):
|
9
|
+
tables: t.List[t.Type[Table]]
|
10
|
+
|
11
|
+
def setUp(self) -> None:
|
12
|
+
create_db_tables_sync(*self.tables)
|
13
|
+
|
14
|
+
def tearDown(self) -> None:
|
15
|
+
drop_db_tables_sync(*self.tables)
|
16
|
+
|
17
|
+
|
18
|
+
class BandTest(FunctionTest):
|
19
|
+
tables = [Band, Manager]
|
20
|
+
|
21
|
+
def setUp(self) -> None:
|
22
|
+
super().setUp()
|
23
|
+
|
24
|
+
manager = Manager({Manager.name: "Guido"})
|
25
|
+
manager.save().run_sync()
|
26
|
+
|
27
|
+
band = Band(
|
28
|
+
{
|
29
|
+
Band.name: "Pythonistas",
|
30
|
+
Band.manager: manager,
|
31
|
+
Band.popularity: 1000,
|
32
|
+
}
|
33
|
+
)
|
34
|
+
band.save().run_sync()
|
@@ -0,0 +1,64 @@
|
|
1
|
+
from piccolo.query.functions import Reverse, Upper
|
2
|
+
from piccolo.querystring import QueryString
|
3
|
+
from tests.base import engines_skip
|
4
|
+
from tests.example_apps.music.tables import Band
|
5
|
+
|
6
|
+
from .base import BandTest
|
7
|
+
|
8
|
+
|
9
|
+
@engines_skip("sqlite")
|
10
|
+
class TestNested(BandTest):
|
11
|
+
"""
|
12
|
+
Skip the the test for SQLite, as it doesn't support ``Reverse``.
|
13
|
+
"""
|
14
|
+
|
15
|
+
def test_nested(self):
|
16
|
+
"""
|
17
|
+
Make sure we can nest functions.
|
18
|
+
"""
|
19
|
+
response = Band.select(Upper(Reverse(Band.name))).run_sync()
|
20
|
+
self.assertListEqual(response, [{"upper": "SATSINOHTYP"}])
|
21
|
+
|
22
|
+
def test_nested_with_joined_column(self):
|
23
|
+
"""
|
24
|
+
Make sure nested functions can be used on a column from a joined table.
|
25
|
+
"""
|
26
|
+
response = Band.select(Upper(Reverse(Band.manager._.name))).run_sync()
|
27
|
+
self.assertListEqual(response, [{"upper": "ODIUG"}])
|
28
|
+
|
29
|
+
def test_nested_within_querystring(self):
|
30
|
+
"""
|
31
|
+
If we wrap a function in a custom QueryString - make sure the columns
|
32
|
+
are still accessible, so joins are successful.
|
33
|
+
"""
|
34
|
+
response = Band.select(
|
35
|
+
QueryString("CONCAT({}, '!')", Upper(Band.manager._.name)),
|
36
|
+
).run_sync()
|
37
|
+
|
38
|
+
self.assertListEqual(response, [{"concat": "GUIDO!"}])
|
39
|
+
|
40
|
+
|
41
|
+
class TestWhereClause(BandTest):
|
42
|
+
|
43
|
+
def test_where(self):
|
44
|
+
"""
|
45
|
+
Make sure where clauses work with functions.
|
46
|
+
"""
|
47
|
+
response = (
|
48
|
+
Band.select(Band.name)
|
49
|
+
.where(Upper(Band.name) == "PYTHONISTAS")
|
50
|
+
.run_sync()
|
51
|
+
)
|
52
|
+
self.assertListEqual(response, [{"name": "Pythonistas"}])
|
53
|
+
|
54
|
+
def test_where_with_joined_column(self):
|
55
|
+
"""
|
56
|
+
Make sure where clauses work with functions, when a joined column is
|
57
|
+
used.
|
58
|
+
"""
|
59
|
+
response = (
|
60
|
+
Band.select(Band.name)
|
61
|
+
.where(Upper(Band.manager._.name) == "GUIDO")
|
62
|
+
.run_sync()
|
63
|
+
)
|
64
|
+
self.assertListEqual(response, [{"name": "Pythonistas"}])
|