[
  {
    "path": ".coveragerc",
    "content": "\n[report]\nshow_missing = True\nomit =\n    /usr/*\n    venv/*\n    tests/*\n    src/fastapi_quickcrud/misc/abstract_execute.py\n    src/fastapi_quickcrud/misc/abstract_query.py\n# Regexes for lines to exclude from consideration\nexclude_lines =\n    raise NotImplementedError\n    self._exclude_column = \\[\\]\n    if __name__ == .__main__.:\n    pass\n    session.expire_all()\n    return async_execute_and_expire_result\n    if 'duplicate key value violates unique constraint' not in err_msg:\n    raise UnknownError(f'Unknown error, {i}')\n    response_result = await parsing_service.async_find_one\n    return response_result\n    parsed_response = await parsing_service.async_find_many*\n    return await parsing_service.async_upsert_one*\n    return await parsing_service.async_upsert_many*\n    return await parsing_service.async_delete_one*\n    return await parsing_service.async_delete_many*\n    return await result_parser.async_post_redirect_get*\n    return await result_parser.async_update_one*\n    return await result_parser.async_patch_many*\n    return await result_parser.async_update_one*\n    return await result_parser.async_update_many*\n    return result\n    raise FindOneApiNotRegister*\n    return RedirectResponse.*?redirect_url\n    raise QueryOperatorNotFound(f'The query operator of {column_name} not found!')\n    raise InvalidRequestMethod(f'{request_method} is not an available request method')\n    raise RequestMissing*\n    raise InvalidRequestMethod.*?f'{value} is not an available request method, Please use CrudMethods\n    delattr(received_insert, received_insert_item)\n    delattr(request_or_response_object, name)\n    routes_source = SQLAlchemyNotSupportRouteSource\n    query_service = SQLAlchemyNotSupportQueryService"
  },
  {
    "path": ".github/workflows/ci.yml",
    "content": "# This is a basic workflow to help you get started with Actions\n\nname: Unit testing in 🐍3.7/8/9/10\n\n# Controls when the workflow will run\non:\n  push:\n    branches: [ \"main\", \"develop\", \"feature/*\" ]\n  pull_request:\n    branches: [ \"main\", \"develop\" ]\n  # Allows you to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\n# A workflow run is made up of one or more jobs that can run sequentially or in parallel\njobs:\n  ciPython37:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.7 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython38:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.8 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython39:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.9 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython310:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ '3.10' ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations"
  },
  {
    "path": ".github/workflows/coverage.yml",
    "content": "# This is a basic workflow to help you get started with Actions\n\nname: Coverage\n\n# Controls when the workflow will run\non:\n  push:\n    branches: [ \"main\", \"develop\" ]\n  pull_request:\n    branches: [ \"main\", \"develop\" ]\n  # Allows you to run this workflow manually from the Actions tab\n  workflow_dispatch:\n\n# A workflow run is made up of one or more jobs that can run sequentially or in parallel\njobs:\n  Coverage:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ '3.10' ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n\n    steps:\n      - uses: actions/checkout@master\n\n      - name: Set github token\n        run: echo \"GITHUB_TOKEN=${{ secrets.GIT_TOKEN }}\" >> $GITHUB_ENV\n      - name: Set coveralls token\n        run: echo \"COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}\" >> $GITHUB_ENV\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: pip install, make coverage\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n          pip install coverage\n          pip install coveralls\n          python -m coverage run -m unittest\n          coveralls\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "# This is a basic workflow to help you get started with Actions\n\nname: Publish Python 🐍 distributions 📦 to PyPI\n\non:\n  push:\n    tags:\n      - '**'\n\njobs:\n  ciPython37:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.7 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython38:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.8 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython39:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ 3.9 ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  ciPython310:\n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        python-version: [ '3.10' ]\n    services:\n      postgres:\n        image: postgres:11\n        env:\n          POSTGRES_USER: postgres\n          POSTGRES_PASSWORD: postgres\n          POSTGRES_DB: ci_db_test\n        ports:\n          - 5432:5432\n        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5\n    steps:\n      - uses: actions/checkout@v3\n      - name: Set up Python ${{ matrix.python-version }}\n        uses: actions/setup-python@v1\n        with:\n          python-version: ${{ matrix.python-version }}\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install -r requirements.txt\n      - name: Enable Postgres Trigram Extension\n        run: |\n          PGPASSWORD=postgres psql -U postgres -h 127.0.0.1 -p ${{ job.services.postgres.ports[5432] }} -d ci_db_test -c \"CREATE EXTENSION IF NOT EXISTS \\\"uuid-ossp\\\";\"\n      - name: Test with unittest\n        env:\n          TEST_DATABASE_URL: postgresql://postgres:postgres@localhost/ci_db_test\n          TEST_DATABASE_ASYNC_URL: postgresql+asyncpg://postgres:postgres@localhost/ci_db_test\n        run: |\n          python -m unittest discover -s ./tests/test_implementations\n  build-n-publish:\n    needs: [ciPython37, ciPython38, ciPython39,ciPython310]\n    name: Build and publish Python 🐍 distributions 📦 to PyPI\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@master\n      - name: Set up Python 3.7\n        uses: actions/setup-python@v3\n        with:\n          python-version: \"3.7\"\n      - name: Set release version env\n        run: echo \"RELEASE_VERSION=${GITHUB_REF#refs/*/}\" >> $GITHUB_ENV\n      - name: Release version\n        run: |\n          echo $RELEASE_VERSION\n          echo ${{ env.RELEASE_VERSION }}\n      - name: Install pypa/build\n        run: >-\n            python -m\n            pip install\n            build\n            --user\n      - name: Build a binary wheel and a source tarball\n        run: >-\n            python -m\n            build\n            --sdist\n            --wheel\n            --outdir dist/\n            .\n      - name: Publish distribution 📦 to PyPI\n        if: startsWith(github.ref, 'refs/tags')\n        uses: pypa/gh-action-pypi-publish@release/v1\n        with:\n          user: __token__\n          password: ${{ secrets.PYPI_API_TOKEN }}"
  },
  {
    "path": ".gitignore",
    "content": "/htmlcov/\n.coverage\ntests/htmlcov\n/poetry.lock\n/pyproject.toml\n*.xml\n*.pyc\nworkspace.xml\n*.iml\n*.xml\n*.sh\n*.gz\n*.txt\n*.\nPKG-INFO\nfastapi_quickcrud_code_generator_beta.egg-info\nsrc/fastapi_quickcrud.egg-info\ndist\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "\n# Change Log\nAll notable changes to this project will be documented in this file.\n\n\n\n## [not release] - 2021-09-27\n \n### FIX\npydantic update is not good for this project\n\n---\n\n## [not release] - 2021-09-27\n \n### Added\nFull SQL support\n\n### Changed\n\n\n### Fixed\n\n### ToDo\n\nupsert for each sql\n---\n\n\n## [not release] - 2021-09-08\n \n### Added\nField description in docs\n\n### Changed\n\n\n### Fixed\n\n\n## [0.0.1a16] - 2021-09-08\n \n### Added\nrelationship with get api\n\n### Changed\n\ndisable alias\n\nusage is more easy and quick build up\n\n### Fixed\n\n\n## [0.0.1a13] - 2021-08-23\n \n### Added\n\n### Changed\n\n### Fixed\n\npost redirect get can not rollback when find one api not found with async session\n\n---\n\n## [0.0.1a12] - 2021-08-23\n \n### Added\n\nsupport create more than one pydantic model with same\n\n### Changed\n\n### Fixed\n\nduplicated pydantic model name \n\n\n---\n\n\n## [Unreleased] - 2021-08-22\n \n### Added\n\nSQLAlchemy Table is supported, but not support alias yet\n\nSupport create CRUD route without primary key for SQLAlchemy Table \n\n```python\n\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint( 'int4_value', 'float4_value'),\n)\n```\n\n\n### Changed\n- primary key can be optional if autoincrement is True\n\n- get many responses 204 if not found\n\n### Fixed\n\n---\n\n##  - 2021-08-20\n \n### Added\n \n### Changed\n- primary key will be required if no default value or not nullable\n\n\n### Fixed\n\n---\n\n##  - 2021-08-19\n \n### Added\n- User don't need to declare crud_service\n\n\n\n### Changed\n- query abstract\n    - Sqlalchemy\n- route abstract\n### Fixed\n\nWhen you ask for a specific resource, say a user or with query param, and the user doesn't exist\n\n ```https://0.0.0.0:8080/api/:userid```\n \nthen fastapi-qucikcrud should return 404. In this case, the client requested a resource that doesn't exist.\n\n----\n\nIn the other case, you have  an api that returns all users in the system using the following url:\n\n ```https://0.0.0.0:8080/api/user```\n\nIf there are no users in the system, then, in this case, you should return 204.\n\n\n---\n\n##  - 2021-08-18\n \n### Added\n - FastAPIQuickCRUD support commit by user\n  - for example if autocommit set False\n    ```python\n    def get_transaction_session():\n        try:\n            db = sync_session()\n            yield db\n        finally:\n            db.commit()\n            db.close()\n    ```\n  - for example if autocommit set True\n    ```python\n    def get_transaction_session():\n        try:\n            db = sync_session()\n            yield db\n        finally:\n            db.close()\n    ```\n### Changed\n- Refactor - Separate the sql result parsing\n\n\n### Fixed\n "
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2021 Luis Lui\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "#  FastAPI Quick CRUD\n\n![Imgur](https://i.imgur.com/LsLKQHd.png)\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c2a6306f7f0a41948369d80368eb7abb?style=flat-square)](https://www.codacy.com/gh/LuisLuii/FastAPIQuickCRUD/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=LuisLuii/FastAPIQuickCRUD&amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/LuisLuii/FastAPIQuickCRUD/badge.svg?branch=main)](https://coveralls.io/github/LuisLuii/FastAPIQuickCRUD?branch=main)\n[![unit test](https://github.com/LuisLuii/FastAPIQuickCRUD/actions/workflows/ci.yml/badge.svg)](https://github.com/LuisLuii/FastAPIQuickCRUD/actions/workflows/ci.yml)\n[![SupportedVersion](https://img.shields.io/pypi/pyversions/fastapi-quickcrud?style=flat-square)](https://pypi.org/project/fastapi-quickcrud)\n[![develop dtatus](https://img.shields.io/pypi/status/fastapi-quickcrud?style=flat-square)](https://pypi.org/project/fastapi-quickcrud)\n[![PyPI version](https://badge.fury.io/py/fastapi-quickcrud.svg)](https://badge.fury.io/py/fastapi-quickcrud)\n\n\n---\n\n## [If you need apply business logic or add on some code, you can use my another open source project which supports CRUD router code generator](https://github.com/LuisLuii/fastapi-crud-template-generator)\n\n\n- [Introduction](#introduction)\n  - [Advantages](#advantages)\n  - [Limitations](#limitations)\n- [Getting started](#getting-started)\n  - [Installation](#installation)\n  - [Usage](#usage)\n- [Design](#design)\n  - [Path Parameter](#path-parameter)\n  - [Query Parameter](#query-parameter)\n  - [Request Body](#request-body)\n  - [Foreign Tree](#foreign-tree)\n  - [Upsert](#upsert)\n  - [Add description into docs](#add-description-into-docs)\n  - [Relationship](#relationship)\n  - [FastAPI_quickcrud Response Status Code standard](#fastapi_quickcrud-response-status-code-standard)\n    \n\n\n# Introduction\n\nI believe that many people who work with FastApi to build RESTful CRUD services end up wasting time writing repitive boilerplate code.\n\n`FastAPI Quick CRUD` can generate CRUD methods in FastApi from an SQLAlchemy schema:\n\n- Get one\n- Get one with foreign key \n- Get many\n- Get many with foreign key\n- Update one\n- Update many\n- Patch one\n- Patch many\n- Create/Upsert one\n- Create/Upsert many\n- Delete One\n- Delete Many\n- Post Redirect Get\n\n`FastAPI Quick CRUD`is developed based on SQLAlchemy `1.4.23` version and supports sync and async.\n\n![docs page](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/page_preview.png?raw=true)\n![docs_page_2](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/foreign_tree.png?raw=true)\n\n\n\n## Advantages\n\n  - [x] **Support SQLAlchemy 1.4** - Allows you build a fully asynchronous or synchronous python service\n  \n  - [x] **Full SQLAlchemy DBAPI Support** - Support different SQL for SQLAlchemy\n    \n  - [x] **Support Pagination** - `Get many` API support `order by` `offset` `limit` field in API\n\n  - [x] **Rich FastAPI CRUD router generation** - Many operations of CRUD are implemented to complete the development and coverage of all aspects of basic CRUD.\n\n  - [x] **CRUD route automatically generated** - Support Declarative class definitions and Imperative table\n    \n  - [x] **Flexible API request** - `UPDATE ONE/MANY` `FIND ONE/MANY` `PATCH ONE/MANY` `DELETE ONE/MANY` supports Path Parameters (primary key) and Query Parameters as a command to the resource to filter and limit the scope of the scope of data in request.\n     \n  - [x] **SQL Relationship** - `FIND ONE/MANY` supports Path get data with relationship\n    \n## Limitations\n   \n  - ❌ If there are multiple **unique constraints**, please use **composite unique constraints** instead\n  - ❌ **Composite primary key** is not supported\n  - ❌ Unsupported API requests with on resources `xxx/{primary key}` for tables without a primary key; \n    - `UPDATE ONE`\n    - `FIND ONE`\n    - `PATCH ONE` \n    - `DELETE ONE` \n  \n\n# Getting started\n\n##\nI try to update the version dependencies as soon as possible to ensure that the core dependencies of this project have the highest version possible.\n```bash\nfastapi<=0.68.2\npydantic<=1.8.2\nSQLAlchemy<=1.4.30\nstarlette==0.14.2\n```\n\n## Installation\n\n```bash\npip install fastapi-quickcrud\n```\n\nI suggest the following library if you try to connect to PostgreSQL \n```bash\npip install psycopg2\npip install asyncpg\n```\n\n## Usage\nrun and go to http://127.0.0.1:port/docs and see the auto-generated API\n### Simple Code (or see the longer ([example](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/tutorial/sample.py))\n\n\n```python\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    String, Table, ForeignKey, orm\nfrom fastapi_quickcrud import crud_router_builder\n\nBase = orm.declarative_base()\n\n\nclass User(Base):\n    __tablename__ = 'test_users'\n    id = Column(Integer, primary_key=True, autoincrement=True, unique=True)\n    name = Column(String, nullable=False)\n    email = Column(String, nullable=False)\n\n\nfriend = Table(\n    'test_friend', Base.metadata,\n    Column('id', ForeignKey('test_users.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('friend_name', String, nullable=False)\n)\n\ncrud_route_1 = crud_router_builder(db_model=User,\n                                   prefix=\"/user\",\n                                   tags=[\"User\"],\n                                   async_mode=True\n                                   )\ncrud_route_2 = crud_router_builder(db_model=friend,\n                                   prefix=\"/friend\",\n                                   tags=[\"friend\"],\n                                   async_mode=True\n                                   )\n\napp = FastAPI()\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\n```\n\n### Foreign Tree With Relationship\n```python\nfrom fastapi import FastAPI\nfrom fastapi_quickcrud import crud_router_builder\nfrom sqlalchemy import *\nfrom sqlalchemy.orm import *\nfrom fastapi_quickcrud.crud_router import generic_sql_crud_router_builder\n\nBase = declarative_base()\n\nclass Account(Base):\n    __tablename__ = \"account\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    blog_post = relationship(\"BlogPost\", back_populates=\"account\")\n\n\nclass BlogPost(Base):\n    __tablename__ = \"blog_post\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    account_id = Column(Integer, ForeignKey(\"account.id\"), nullable=False)\n    account = relationship(\"Account\", back_populates=\"blog_post\")\n    blog_comment = relationship(\"BlogComment\", back_populates=\"blog_post\")\n\n\nclass BlogComment(Base):\n    __tablename__ = \"blog_comment\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    blog_id = Column(Integer, ForeignKey(\"blog_post.id\"), nullable=False)\n    blog_post = relationship(\"BlogPost\", back_populates=\"blog_comment\")\n\n\ncrud_route_parent = crud_router_builder(\n    db_model=Account,\n    prefix=\"/account\",\n    tags=[\"account\"],\n    foreign_include=[BlogComment, BlogPost]\n\n)\ncrud_route_child1 = generic_sql_crud_router_builder(\n    db_model=BlogPost,\n    prefix=\"/blog_post\",\n    tags=[\"blog_post\"],\n    foreign_include=[BlogComment]\n\n)\ncrud_route_child2 = generic_sql_crud_router_builder(\n    db_model=BlogComment,\n    prefix=\"/blog_comment\",\n    tags=[\"blog_comment\"]\n\n)\n\napp = FastAPI()\n[app.include_router(i) for i in [crud_route_parent, crud_route_child1, crud_route_child2]]\n\n```\n\n### SQLAlchemy to Pydantic Model Converter And Build your own API([example](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/tutorial/basic_usage/quick_usage_with_async_SQLALchemy_Base.py))\n```python\nimport uvicorn\nfrom fastapi import FastAPI, Depends\nfrom fastapi_quickcrud import CrudMethods\nfrom fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom fastapi_quickcrud.misc.memory_sql import sync_memory_db\n\nfrom sqlalchemy import CHAR, Column, Integer\nfrom sqlalchemy.ext.declarative import declarative_base\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass Child(Base):\n    __tablename__ = 'right'\n    id = Column(Integer, primary_key=True)\n    name = Column(CHAR, nullable=True)\n\n\nfriend_model_set = sqlalchemy_to_pydantic(db_model=Child,\n                                          crud_methods=[\n                                              CrudMethods.FIND_MANY,\n                                              CrudMethods.UPSERT_MANY,\n                                              CrudMethods.UPDATE_MANY,\n                                              CrudMethods.DELETE_MANY,\n                                              CrudMethods.CREATE_ONE,\n                                              CrudMethods.PATCH_MANY,\n\n                                          ],\n                                          exclude_columns=[])\n\n\npost_model = friend_model_set.POST[CrudMethods.CREATE_ONE]\nsync_memory_db.create_memory_table(Child)\n\n@app.post(\"/hello\",\n          status_code=201,\n          tags=[\"Child\"],\n          response_model=post_model.responseModel,\n          dependencies=[])\nasync def my_api(\n        query: post_model.requestBodyModel = Depends(post_model.requestBodyModel),\n        session=Depends(sync_memory_db.get_memory_db_session)\n):\n    db_item = Child(**query.__dict__)\n    session.add(db_item)\n    session.commit()\n    session.refresh(db_item)\n    return db_item.__dict__\n\n\n\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n\n```\n\n* Note:\n you can use [sqlacodegen](https://github.com/agronholm/sqlacodegen) to generate SQLAlchemy models for your table. This project is based on the model development and testing generated by sqlacodegen\n\n### Main module\n\n#### Generate CRUD router\n\n**crud_router_builder args**\n- db_session [Optional] `execute session generator` \n    - default using in-memory db with create table automatically\n    - example:\n        - sync SQLALchemy:\n      ```python\n        from sqlalchemy.orm import sessionmaker\n        def get_transaction_session():\n            try:\n                db = sessionmaker(...)\n                yield db\n            except Exception as e:\n                db.rollback()\n                raise e\n            finally:\n                db.close()\n        ```\n        - Async SQLALchemy\n        ```python\n        from sqlalchemy.orm import sessionmaker\n        from sqlalchemy.ext.asyncio import AsyncSession\n        async_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n        async def get_transaction_session() -> AsyncSession:\n            async with async_session() as session:\n                async with session.begin():\n                    yield session\n        ```\n- db_model [Require] `SQLALchemy Declarative Base Class or Table`\n    \n    >  **Note**: There are some constraint in the SQLALchemy Schema\n    \n- async_mode  [Optional (auto set by db_session)] `bool`: if your db session is async\n    \n    >  **Note**: require async session generator if True\n    \n- autocommit [Optional (default True)] `bool`: if you don't need to commit by your self    \n    \n    >  **Note**: require handle the commit in your async session generator if False\n    \n- dependencies [Optional]: API dependency injection of fastapi\n        \n    >  **Note**: Get the example usage in `./example`        \n\n- crud_methods: ```CrudMethods```\n    > - CrudMethods.FIND_ONE\n    > - CrudMethods.FIND_MANY\n    > - CrudMethods.UPDATE_ONE\n    > - CrudMethods.UPDATE_MANY\n    > - CrudMethods.PATCH_ONE\n    > - CrudMethods.PATCH_MANY\n    > - CrudMethods.UPSERT_ONE (only support postgresql yet)\n    > - CrudMethods.UPSERT_MANY (only support postgresql yet)\n    > - CrudMethods.CREATE_ONE\n    > - CrudMethods.CREATE_MANY\n    > - CrudMethods.DELETE_ONE\n    > - CrudMethods.DELETE_MANY\n    > - CrudMethods.POST_REDIRECT_GET\n\n- exclude_columns: `list` \n  > set the columns that not to be operated but the columns should nullable or set the default value)\n\n- foreign_include: `list[declarative_base()]` \n  > add the SqlAlchemy models here, and build the foreign tree get one/many api (don't support SqlAlchemy table)\n\n\n- dynamic argument (prefix, tags): extra argument for APIRouter() of fastapi\n\n\n# Design\n\nIn `PUT` `DELETE` `PATCH`, user can use Path Parameters and Query Parameters to limit the scope of the data affected by the operation, and the Query Parameters is same with `FIND` API\n\n## Path Parameter\n\nIn the design of this tool, **Path Parameters** should be a primary key of table, that why limited primary key can only be one.\n\n## Query Parameter\n\n- Query Operation will look like that when python type of column is \n  <details>\n    <summary>string</summary>\n  \n    - **support Approximate String Matching that require this** \n        - (<column_name>____str, <column_name>____str_____matching_pattern)\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n    - **preview**\n    ![string](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/string_query.png?raw=true)\n  </details>\n  \n  <details>\n    <summary>numeric or datetime</summary>\n  \n    - **support Range Searching from and to**\n        - (<column_name>____from, <column_name>____from_____comparison_operator)\n        - (<column_name>____to, <column_name>____to_____comparison_operator)\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n    - **preview**\n        ![numeric](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/numeric_query.png?raw=true)\n        ![datetime](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/time_query.png?raw=true)\n  </details>\n\n  <details>\n    <summary>uuid</summary>\n  \n    uuid supports In-place Operation only\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n  </details>\n\n\n- EXTRA query parameter for `GET_MANY`: \n  <details>\n    <summary>Pagination</summary>\n  \n    - **limit**\n    - **offset**\n    - **order by**\n    - **preview**\n        ![Pagination](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/Pagination_query.png?raw=true)  \n\n  </details>\n\n    \n### Query to SQL statement example\n\n- [**Approximate String Matching**](https://www.postgresql.org/docs/9.3/functions-matching.html)\n  <details>\n    <summary>example</summary>\n  \n    - request url\n      ```text\n      /test_CRUD?\n      char_value____str_____matching_pattern=match_regex_with_case_sensitive&\n      char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive&\n      char_value____str_____matching_pattern=case_sensitive&\n      char_value____str_____matching_pattern=not_case_insensitive&\n      char_value____str=a&\n      char_value____str=b\n      ```\n    - generated sql\n      ```sql\n        SELECT *\n        FROM untitled_table_256 \n        WHERE (untitled_table_256.char_value ~ 'a') OR \n        (untitled_table_256.char_value ~ 'b' OR \n        (untitled_table_256.char_value !~* 'a') OR \n        (untitled_table_256.char_value !~* 'b' OR \n        untitled_table_256.char_value LIKE 'a' OR \n        untitled_table_256.char_value LIKE 'b' OR \n        untitled_table_256.char_value NOT ILIKE 'a' \n        OR untitled_table_256.char_value NOT ILIKE 'b'\n        ```\n  </details>\n\n  \n- **In-place Operation**\n  <details>\n    <summary>example</summary>\n  \n    - In-place support the following operation\n    - generated sql if user select Equal operation and input True and False\n    - preview\n      ![in](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/in_query.png?raw=true)  \n\n    - generated sql\n      ```sql        \n        select * FROM untitled_table_256 \n        WHERE untitled_table_256.bool_value = true OR \n        untitled_table_256.bool_value = false\n        ```  \n    \n  </details>        \n\n\n- **Range Searching**\n  <details>\n    <summary>example</summary>\n  \n    - Range Searching support the following operation\n    \n        ![greater](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/greater_query.png?raw=true)  \n            \n        ![less](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/less_query.png?raw=true)\n    - generated sql \n      ```sql\n        select * from untitled_table_256\n        WHERE untitled_table_256.date_value > %(date_value_1)s \n      ```\n      ```sql\n        select * from untitled_table_256\n        WHERE untitled_table_256.date_value < %(date_value_1)s \n      ```\n    \n  </details>\n  \n\n- Also support your custom dependency for each api(there is a example in `./example`)\n\n\n### Request Body\n\nIn the design of this tool, the columns of the table will be used as the fields of request body.\n\nIn the basic request body in the api generated by this tool, some fields are optional if :\n\n* [x] it is primary key with `autoincrement` is True or the `server_default` or `default` is True\n* [x] it is not a primary key, but the `server_default` or `default` is True\n* [x] The field is nullable\n\n\n### Foreign Tree\nTBC\n\n\n\n## Upsert\n\n** Upsert supports PosgreSQL only yet\n\nPOST API will perform the data insertion action with using the basic [Request Body](#request-body),\nIn addition, it also supports upsert(insert on conflict do)\n\nThe operation will use upsert instead if the unique column in the inserted row that is being inserted already exists in the table \n\nThe tool uses `unique columns` in the table as a parameter of on conflict , and you can define which column will be updated \n\n![upsert](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/upsert_preview.png?raw=true)\n\n## Add description into docs\n\nYou can declare `comment` argument for `sqlalchemy.Column` to configure the description of column\n\nexample:\n\n```python\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True,comment='parent_test')\n\n    # one-to-many collection\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True,comment='child_pk_test')\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'),info=({'description':'child_parent_id_test'}))\n\n    # many-to-one scalar\n    parent = relationship(\"Parent\", back_populates=\"children\")\n```\n\n\n## Relationship\n\nNow, `FIND_ONE` and `FIND_MANY` are supporting select data with join operation\n```python\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n```\nthere is a relationship with using back_populates between Parent table and Child table, the `parent_id` in `Child` will refer to `id` column in `Parent`.\n\n`FastApi Quick CRUD` will generate an api with a `join_foreign_table` field, and get api will respond to your selection of the reference data row of the corresponding table in `join_foreign_table` field, \n\n![join_1](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_preview_1.png?raw=true)\n\n![join_2](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_preview_2.png?raw=true)\n\n* Try Request\nnow there are some data in these two table\n  \n![parent](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_parent.png?raw=true)\n\n![child](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_child.png?raw=true)\n\nwhen i request\n* Case One\n    ```commandline\n    curl -X 'GET' \\\n    'http://0.0.0.0:8000/parent?join_foreign_table=child_o2o' \\\n    -H 'accept: application/json'\n    ```\n    Response data\n    ```json\n    [\n      {\n        \"id_foreign\": [\n          {\n            \"id\": 1,\n            \"parent_id\": 1\n          },\n          {\n            \"id\": 2,\n            \"parent_id\": 1\n          }\n        ],\n        \"id\": 1\n      },\n      {\n        \"id_foreign\": [\n          {\n            \"id\": 3,\n            \"parent_id\": 2\n          },\n          {\n            \"id\": 4,\n            \"parent_id\": 2\n          }\n        ],\n        \"id\": 2\n      }\n    ]\n    ```\n    Response headers\n    ```text\n     x-total-count: 4 \n    ```\n    \n    There are response 4 data, response data will be grouped by the parent row, if the child refer to the same parent row\n    \n* Case Two\n    ```commandline\n    curl -X 'GET' \\\n    'http://0.0.0.0:8000/child?join_foreign_table=parent_o2o' \\\n    -H 'accept: application/json'\n    ```\n    Response data\n    ```json\n    [\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 1\n          }\n        ],\n        \"id\": 1,\n        \"parent_id\": 1\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 1\n          }\n        ],\n        \"id\": 2,\n        \"parent_id\": 1\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 2\n          }\n        ],\n        \"id\": 3,\n        \"parent_id\": 2\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 2\n          }\n        ],\n        \"id\": 4,\n        \"parent_id\": 2\n      }\n    ]\n    ```\n    Response Header\n    ```text\n    x-total-count: 4 \n    ```\n\n#### FastAPI_quickcrud Response Status Code standard \n\n\nWhen you ask for a specific resource, say a user or with query param, and the user doesn't exist\n\n ```GET: get one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```UPDATE: update one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```PATCH: patch one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```DELETE: delete one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n \nthen fastapi-qucikcrud should return 404. In this case, the client requested a resource that doesn't exist.\n\n----\n\nIn the other case, you have an api that operate data on batch in the system using the following url:\n\n ```GET: get many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```UPDATE: update many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```DELETE: delete many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```PATCH: patch many : https://0.0.0.0:8080/api/user?xx=xx```\n\nIf there are no users in the system, then, in this case, you should return 204.\n\n\n### TODO\n[milestones](https://github.com/LuisLuii/FastAPIQuickCRUD/milestones)\n\n    \n\n"
  },
  {
    "path": "README_zh.md",
    "content": "#  FastAPI Quick CRUD\n\n\n![Imgur](https://i.imgur.com/LsLKQHd.png)\n\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c2a6306f7f0a41948369d80368eb7abb?style=flat-square)](https://www.codacy.com/gh/LuisLuii/FastAPIQuickCRUD/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=LuisLuii/FastAPIQuickCRUD&amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/LuisLuii/FastAPIQuickCRUD/badge.svg?branch=main)](https://coveralls.io/github/LuisLuii/FastAPIQuickCRUD?branch=main)\n[![CircleCI](https://circleci.com/gh/LuisLuii/FastAPIQuickCRUD/tree/main.svg?style=svg)](https://circleci.com/gh/LuisLuii/FastAPIQuickCRUD/tree/main)\n[![PyPidownload](https://img.shields.io/pypi/dm/fastapi-quickcrud?style=flat-square)](https://pypi.org/project/fastapi-quickcrud)\n[![SupportedVersion](https://img.shields.io/pypi/pyversions/fastapi-quickcrud?style=flat-square)](https://pypi.org/project/fastapi-quickcrud)\n[![develop dtatus](https://img.shields.io/pypi/status/fastapi-quickcrud?style=flat-square)](https://pypi.org/project/fastapi-quickcrud)\n[![PyPI version](https://badge.fury.io/py/fastapi-quickcrud.svg)](https://badge.fury.io/py/fastapi-quickcrud)\n\n\n---\n\n\n\n\n- [Introduction](#introduction)\n  - [Advantage](#advantage)\n  - [Constraint](#constraint)\n- [Getting started](#getting-started)\n  - [Installation](#installation)\n  - [Usage](#usage)\n- [Design](#design)\n  - [Path Parameter](#path-parameter)\n  - [Query Parameter](#query-parameter)\n  - [Request Body](#request-body)\n  - [Upsert](#upsert)\n\n\n# Introduction\n\n我相信很多人會使用FastAPI寫一些簡單CRUD服務，浪費時間去為每個table 寫高度相似的代碼\n\n如果你使用SQLAlchemy , 你可以通過`FastAPI Quick CRUD` 去生成CRUD API\n\n- Get one\n- Get many\n- Update one\n- Update many\n- Patch one\n- Patch many\n- Create/Upsert one\n- Create/Upsert many\n- Delete One\n- Delete Many\n- Post Redirect Get\n\n`FastAPI Quick CRUD`是基於SQLAlchemy `1.4` 版本進行開發，同時支持同步及異步\n![docs page](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/page_preview.png?raw=true)\n\n\n## 好處\n\n  - [x] **支持 SQLAlchemy 1.41版本** - 允許你建立異步或同步的api 服務\n  \n  - [x] **支持分頁** - Get many API 支持 order by offset limit \n\n  - [x] **支持全部SQL DBAPI ** - 支持所有SQLAlchemy 支持的SQL DB dialect\n\n  - [x] **CRUD路由自動生成n** - 豐富的CRUD路由生成選擇 - 多種CRUD操作可供選擇\n\n  - [x] **CRUD路由自動生成** - 支持SQLAlchemy的 Declarative class definitions 和 Imperative table\n    \n  - [x] **彈性API 請求** - `UPDATE ONE/MANY` `FIND ONE/MANY` `PATCH ONE/MANY` `DELETE ONE/MANY` 支持利用主鍵作為Path parameter and 以及table的column作Query Parameters，先對數據進行過濾再處理\n    \n## 限制\n   \n  - ❌ 請使用**composite unique constraints** 代替多個**unique constraints**\n  - ❌ table 只能有一個主鍵\n  - ❌ 以下API 不支持*Path Parameter* 如果沒有主鍵\n    - `UPDATE ONE`\n    - `FIND ONE`\n    - `PATCH ONE` \n    - `DELETE ONE` \n  \n\n# Getting started\n\n## Installation\n\n```bash\npip install fastapi-quickcrud\n```\n\n\n#### Simple Code (到 `./example` 取得更多例子)\n\n```python\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    String, Table, ForeignKey, orm\nfrom fastapi_quickcrud import crud_router_builder\n\nBase = orm.declarative_base()\n\n\nclass User(Base):\n    __tablename__ = 'test_users'\n    id = Column(Integer, primary_key=True, autoincrement=True, unique=True)\n    name = Column(String, nullable=False)\n    email = Column(String, nullable=False)\n\n\nfriend = Table(\n    'test_friend', Base.metadata,\n    Column('id', ForeignKey('test_users.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('friend_name', String, nullable=False)\n)\n\ncrud_route_1 = crud_router_builder(db_model=User,\n                                   prefix=\"/user\",\n                                   tags=[\"User\"],\n                                   async_mode=True\n                                   )\ncrud_route_2 = crud_router_builder(db_model=friend,\n                                   prefix=\"/friend\",\n                                   tags=[\"friend\"],\n                                   async_mode=True\n                                   )\n\napp = FastAPI()\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\n```\n\n\n### Main module\n\n#### Generate CRUD router\n\n**crud_router_builder args**\n- db_session [Optional] `execute session generator` \n    - 默認使用In-memory DB, 或如以下例子自定義你的數據庫連接\n    - example:\n        - 同步 SQLALchemy:\n      ```python\n        from sqlalchemy.orm import sessionmaker\n        def get_transaction_session():\n            try:\n                db = sessionmaker(...)\n                yield db\n            except Exception as e:\n                db.rollback()\n                raise e\n            finally:\n                db.close()\n        ```\n        - 異步 SQLALchemy\n        ```python\n        from sqlalchemy.orm import sessionmaker\n        from sqlalchemy.ext.asyncio import AsyncSession\n        async_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n        async def get_transaction_session() -> AsyncSession:\n            async with async_session() as session:\n                async with session.begin():\n                    yield session\n        ```\n- db_model [Require] `SQLALchemy Declarative Base Class or Table`\n    \n    >  **Note**: db_model 會有一些限制，例如數據庫獨特的數據類型\n    \n- async_mode  [Optional (會通過你的db_session自動判斷)] `bool`: 你的數據庫連接是不是異步\n    \n    >  **Note**: 如果你的數據庫連接是異步，請設置True\n    \n- autocommit [Optional (default True)] `bool`: 自動幫你commit每一個 CRUD\n    \n    >  **Note**: 如果你在你的db_session 自已handle 了commit, 請設置False\n  \n- dependencies [Optional]: FastAPI 的依赖注入 \n        \n    >  **Note**:  `./example` 有相關使用例子        \n\n- crud_methods [Optional]: ```CrudMethods``` 目前支持的CRUD， 如不設置便會自動設置\n    > - CrudMethods.FIND_ONE\n    > - CrudMethods.FIND_MANY\n    > - CrudMethods.UPDATE_ONE\n    > - CrudMethods.UPDATE_MANY\n    > - CrudMethods.PATCH_ONE\n    > - CrudMethods.PATCH_MANY\n    > - CrudMethods.UPSERT_ONE (only support postgresql yet)\n    > - CrudMethods.UPSERT_MANY (only support postgresql yet)\n    > - CrudMethods.CREATE_ONE\n    > - CrudMethods.CREATE_MANY\n    > - CrudMethods.DELETE_ONE\n    > - CrudMethods.DELETE_MANY\n    > - CrudMethods.POST_REDIRECT_GET\n\n- exclude_columns: `list`1 \n  > 怱略column，不會生成該怱略column的API請求列\n\n- dynamic argument (prefix, tags): 用作FastApi APIRouter() 的參數\n\n\n\n# Design\n\nIn `PUT` `DELETE` `PATCH`, 用戶可以通過 Path Parameters and Query Parameters 去限制受影響的數據 ，當中的Query Parameter 跟 `FIND` API一樣\n\n## Path Parameter\n\n在這個工具的設計中，**Path Parameters** 應該是表的一個主鍵，所以有限的主鍵只能是一個。\n\n## Query Parameter\n\n- 當列的 python 類型為時，查詢操作將如下所示\n  <details>\n    <summary>string</summary>\n  \n    - **support Approximate String Matching that require this** \n        - (<column_name>____str, <column_name>____str_____matching_pattern)\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n    - **preview**\n    ![string](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/string_query.png?raw=true)\n  </details>\n  \n  <details>\n    <summary>numeric or datetime</summary>\n  \n    - **support Range Searching from and to**\n        - (<column_name>____from, <column_name>____from_____comparison_operator)\n        - (<column_name>____to, <column_name>____to_____comparison_operator)\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n    - **preview**\n        ![numeric](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/numeric_query.png?raw=true)\n        ![datetime](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/time_query.png?raw=true)\n  </details>\n\n  <details>\n    <summary>uuid</summary>\n  \n    uuid supports In-place Operation only\n    - **support In-place Operation, get the value of column in the list of input**\n        - (<column_name>____list, <column_name>____list____comparison_operator)\n  </details>\n\n\n- `GET_MANY` 的額外查詢參數：\n  <details>\n    <summary>Pagination</summary>\n  \n    - **limit**\n    - **offset**\n    - **order by**\n    - **preview**\n        ![Pagination](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/Pagination_query.png?raw=true)  \n\n  </details>\n\n    \n### Query to SQL statement example\n\n- [**Approximate String Matching**](https://www.postgresql.org/docs/9.3/functions-matching.html)\n  <details>\n    <summary>example</summary>\n  \n    - request url\n      ```text\n      /test_CRUD?\n      char_value____str_____matching_pattern=match_regex_with_case_sensitive&\n      char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive&\n      char_value____str_____matching_pattern=case_sensitive&\n      char_value____str_____matching_pattern=not_case_insensitive&\n      char_value____str=a&\n      char_value____str=b\n      ```\n    - generated sql\n      ```sql\n        SELECT *\n        FROM untitled_table_256 \n        WHERE (untitled_table_256.char_value ~ 'a') OR \n        (untitled_table_256.char_value ~ 'b' OR \n        (untitled_table_256.char_value !~* 'a') OR \n        (untitled_table_256.char_value !~* 'b' OR \n        untitled_table_256.char_value LIKE 'a' OR \n        untitled_table_256.char_value LIKE 'b' OR \n        untitled_table_256.char_value NOT ILIKE 'a' \n        OR untitled_table_256.char_value NOT ILIKE 'b'\n        ```\n  </details>\n\n  \n- **In-place Operation**\n  <details>\n    <summary>example</summary>\n  \n    - In-place support the following operation\n    - generated sql if user select Equal operation and input True and False\n    - preview\n      ![in](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/in_query.png?raw=true)  \n\n    - generated sql\n      ```sql        \n        select * FROM untitled_table_256 \n        WHERE untitled_table_256.bool_value = true OR \n        untitled_table_256.bool_value = false\n        ```  \n    \n  </details>        \n\n\n- **Range Searching**\n  <details>\n    <summary>example</summary>\n  \n    - Range Searching support the following operation\n    \n        ![greater](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/greater_query.png?raw=true)  \n            \n        ![less](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/less_query.png?raw=true)\n    - generated sql \n      ```sql\n        select * from untitled_table_256\n        WHERE untitled_table_256.date_value > %(date_value_1)s \n      ```\n      ```sql\n        select * from untitled_table_256\n        WHERE untitled_table_256.date_value < %(date_value_1)s \n      ```\n    \n  </details>\n  \n\n- 還支持您對每個 api 的自定義依賴項(there is a example in `./example`)\n\n### 請求正文\n\n在這個工具的設計中，表格的列將被用作請求正文的字段。\n\n在此工俱生成的 api 中的基本請求正文中，某些字段是可選的，如果：\n\n* [x] 它是主鍵，`autoincrement` 為 True 或 `server_default` 或 `default` 為 True\n* [x] 它不是主鍵，但 `server_default` 或 `default` 為 True\n* [x] 該字段可以為空\n\n## Upsert\n** Upsert 目前僅支持 PosgreSQL\n\nPOST API 將使用基本的 [Request Body](#request-body) 執行數據插入操作，\n此外，它還支持upsert（在衝突時插入）\n\n如果要插入的插入行中的唯一列已存在於表中，則該操作將使用 upsert\n\n該工具使用表中的“唯一列”作為衝突時的參數，您可以定義將更新哪一列\n![upsert](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/upsert_preview.png?raw=true)\n\n## Add description into docs\n\n你可以為`sqlalchemy.Column`聲明`comment`參數來配置列的描述\n\n例子：\n\n```python\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True,comment='parent_test')\n\n    # one-to-many collection\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True,comment='child_pk_test')\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'),info=({'description':'child_parent_id_test'}))\n\n    # many-to-one scalar\n    parent = relationship(\"Parent\", back_populates=\"children\")\n```\n\n\n## Relationship\n\n現在，`FIND_ONE` 和 `FIND_MANY` 支持 relationship\n```python\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n```\n父表和子表之間使用back_populates有關係，`Child`中的`parent_id`將引用`Parent`中的`id`列。\n\n`FastApi Quick CRUD`會生成一個帶有`join_foreign_table`字段的api，get api會響應你在`join_foreign_table`字段中選擇對應表的引用數據行，\n![join_1](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_preview_1.png?raw=true)\n\n![join_2](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_preview_2.png?raw=true)\n\n* Try Request\n\n現在這兩個表中有一些數據\n  \n![parent](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_parent.png?raw=true)\n\n![child](https://github.com/LuisLuii/FastAPIQuickCRUD/blob/main/pic/join_child.png?raw=true)\n\n當我請求時\n* Case One\n    ```commandline\n    curl -X 'GET' \\\n    'http://0.0.0.0:8000/parent?join_foreign_table=child_o2o' \\\n    -H 'accept: application/json'\n    ```\n    Response data\n    ```json\n    [\n      {\n        \"id_foreign\": [\n          {\n            \"id\": 1,\n            \"parent_id\": 1\n          },\n          {\n            \"id\": 2,\n            \"parent_id\": 1\n          }\n        ],\n        \"id\": 1\n      },\n      {\n        \"id_foreign\": [\n          {\n            \"id\": 3,\n            \"parent_id\": 2\n          },\n          {\n            \"id\": 4,\n            \"parent_id\": 2\n          }\n        ],\n        \"id\": 2\n      }\n    ]\n    ```\n    Response headers\n    ```text\n     x-total-count: 4 \n    ```\n    \n    這有響應四個數據，響應數據將按父行分組，如果子引用相同的父行\n    \n* Case Two\n    ```commandline\n    curl -X 'GET' \\\n    'http://0.0.0.0:8000/child?join_foreign_table=parent_o2o' \\\n    -H 'accept: application/json'\n    ```\n    Response data\n    ```json\n    [\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 1\n          }\n        ],\n        \"id\": 1,\n        \"parent_id\": 1\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 1\n          }\n        ],\n        \"id\": 2,\n        \"parent_id\": 1\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 2\n          }\n        ],\n        \"id\": 3,\n        \"parent_id\": 2\n      },\n      {\n        \"parent_id_foreign\": [\n          {\n            \"id\": 2\n          }\n        ],\n        \"id\": 4,\n        \"parent_id\": 2\n      }\n    ]\n    ```\n    Response Header\n    ```text\n    x-total-count: 4 \n    ```\n\n#### FastAPI_quickcrud Response Status Code standard \n\n\n當您請求特定資源時，例如一個用戶或帶有查詢參數，而該用戶不存在\n\n ```GET: get one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```UPDATE: update one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```PATCH: patch one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n ```DELETE: delete one : https://0.0.0.0:8080/api/:userid?xx=xx```\n\n \n那麼 fastapi-qucikcrud 應該返回 404。在這種情況下，客戶端請求了一個不存在的資源。\n\n----\n\n在另一種情況下，您有一個 api，它使用以下 url 在系統中批量操作數據：\n\n ```GET: get many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```UPDATE: update many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```DELETE: delete many : https://0.0.0.0:8080/api/user?xx=xx```\n\n ```PATCH: patch many : https://0.0.0.0:8080/api/user?xx=xx```\n\n如果系統中沒有用戶，那麼在這種情況下，您應該返回 204。\n\n### TODO\n\n- 每個 SQL 的 Upsert 操作\n    \n\n"
  },
  {
    "path": "__init__.py",
    "content": ""
  },
  {
    "path": "__main__.py",
    "content": ""
  },
  {
    "path": "setup.py",
    "content": "import os\n\nfrom setuptools import setup, find_packages\n\nVERSION = os.getenv(\"RELEASE_VERSION\", default=None) or os.getenv(\"env.RELEASE_VERSION\", default=None)\n\nprint(\n    \"\"\"\n\n- upload\n    - build wheel: python setup.py sdist\n    - upload to server: twine upload dist/*\n\n- download\n    - Just pip install <package>\n\n\"\"\"\n)\n\n\nif __name__ == \"__main__\":\n    setup(\n        name=\"fastapi_quickcrud\",\n        version=VERSION,\n        install_requires=[\n            \"fastapi==0.68.2\",\n            \"pydantic==1.8.2\",\n            \"SQLAlchemy==1.4.30\",\n            \"StrEnum==0.4.7\",\n            \"starlette==0.14.2\",\n            \"aiosqlite==0.17.0\",\n        ],\n        extras_require={\n            'dev': [\n                \"uvicorn==0.17.0\",\n                \"greenlet==1.1.2\",\n                \"anyio==3.5.0\"\n            ],\n        },\n        python_requires=\">=3.7\",\n        description=\"A comprehensive FastaAPI's CRUD router generator for SQLALchemy.\",\n        long_description=open(\"README.md\", \"r\", encoding=\"utf-8\").read(),\n        long_description_content_type=\"text/markdown\",\n        author=\"Luis Lui\",\n        author_email=\"luis11235178@gmail.com\",\n        url=\"https://github.com/LuisLuii/FastAPIQuickCRUD\",\n        license=\"MIT License\",\n        keywords=[\n            \"fastapi\",\n            \"crud\",\n            \"restful\",\n            \"routing\",\n            \"SQLAlchemy\",\n            \"generator\",\n            \"crudrouter\",\n            \"postgresql\",\n            \"builder\",\n        ],\n        packages=find_packages(\"src\"),\n        package_dir={\"\": \"src\"},\n        setup_requires=[\"setuptools>=31.6.0\"],\n        classifiers=[\n            \"Operating System :: OS Independent\",\n            \"Programming Language :: Python :: 3\",\n            \"Programming Language :: Python\",\n            \"Topic :: Internet\",\n            \"Topic :: Software Development :: Libraries :: Application Frameworks\",\n            \"Topic :: Software Development :: Libraries :: Python Modules\",\n            \"Topic :: Software Development :: Libraries\",\n            \"Topic :: Software Development :: Code Generators\",\n            \"Topic :: Software Development\",\n            \"Typing :: Typed\",\n            \"Development Status :: 5 - Production/Stable\",\n            \"Environment :: Web Environment\",\n            \"Framework :: AsyncIO\",\n            \"Intended Audience :: Developers\",\n            \"Intended Audience :: Information Technology\",\n            \"Intended Audience :: System Administrators\",\n            \"License :: OSI Approved :: MIT License\",\n            \"Programming Language :: Python :: 3 :: Only\",\n            \"Programming Language :: Python :: 3.7\",\n            \"Programming Language :: Python :: 3.8\",\n            \"Programming Language :: Python :: 3.9\",\n            \"Programming Language :: Python :: 3.10\",\n            \"Topic :: Internet :: WWW/HTTP :: HTTP Servers\",\n            \"Topic :: Internet :: WWW/HTTP\",\n        ],\n        include_package_data=True,\n    )\n"
  },
  {
    "path": "src/__init__.py",
    "content": ""
  },
  {
    "path": "src/fastapi_quickcrud/__init__.py",
    "content": "from .misc.utils import sqlalchemy_to_pydantic\nfrom .crud_router import crud_router_builder\nfrom .misc.type import CrudMethods\n\n\n"
  },
  {
    "path": "src/fastapi_quickcrud/crud_router.py",
    "content": "import asyncio\nimport inspect\nfrom functools import partial\nfrom typing import \\\n    Any, \\\n    List, \\\n    TypeVar, Union, Callable, Optional\n\nfrom fastapi import \\\n    Depends, APIRouter\nfrom pydantic import \\\n    BaseModel\nfrom sqlalchemy.sql.schema import Table\n\nfrom . import sqlalchemy_to_pydantic\nfrom .misc.abstract_execute import SQLALchemyExecuteService\nfrom .misc.abstract_parser import SQLAlchemyGeneralSQLeResultParse\nfrom .misc.abstract_query import SQLAlchemyPGSQLQueryService, \\\n    SQLAlchemySQLITEQueryService, SQLAlchemyNotSupportQueryService\nfrom .misc.abstract_route import SQLAlchemySQLLiteRouteSource, SQLAlchemyPGSQLRouteSource, \\\n    SQLAlchemyNotSupportRouteSource\nfrom .misc.crud_model import CRUDModel\nfrom .misc.memory_sql import async_memory_db, sync_memory_db\nfrom .misc.type import CrudMethods, SqlType\nfrom .misc.utils import convert_table_to_model, Base\n\nCRUDModelType = TypeVar(\"CRUDModelType\", bound=BaseModel)\nCompulsoryQueryModelType = TypeVar(\"CompulsoryQueryModelType\", bound=BaseModel)\nOnConflictModelType = TypeVar(\"OnConflictModelType\", bound=BaseModel)\n\n\ndef crud_router_builder(\n        *,\n        db_model: Union[Table, 'DeclarativeBaseModel'],\n        db_session: Callable = None,\n        autocommit: bool = True,\n        crud_methods: Optional[List[CrudMethods]] = None,\n        exclude_columns: Optional[List[str]] = None,\n        dependencies: Optional[List[callable]] = None,\n        crud_models: Optional[CRUDModel] = None,\n        async_mode: Optional[bool] = None,\n        foreign_include: Optional[Base] = None,\n        sql_type: Optional[SqlType] = None,\n        **router_kwargs: Any) -> APIRouter:\n    \"\"\"\n    @param db_model:\n        The Sqlalchemy Base model/Table you want to use it to build api.\n\n    @param db_session:\n        The callable variable and return a session generator that will be used to get database connection session for fastapi.\n\n    @param autocommit:\n        set False if you handle commit in your db_session.\n\n    @param crud_methods:\n        Fastapi Quick CRUD supports a few of crud methods, and they save into the Enum class,\n        get it by : from fastapi_quickcrud import CrudMethods\n        example:\n            [CrudMethods.GET_MANY,CrudMethods.ONE]\n        note:\n            if there is no primary key in your SQLAlchemy model, it dose not support request with\n            specific resource, such as GET_ONE, UPDATE_ONE, DELETE_ONE, PATCH_ONE AND POST_REDIRECT_GET\n            this is because POST_REDIRECT_GET need to redirect to GET_ONE api\n\n    @param exclude_columns:\n        Fastapi Quick CRUD will get all the columns in you table to generate a CRUD router,\n        it is allow you exclude some columns you dont want it expose to operated by API\n        note:\n            if the column in exclude list but is it not nullable or no default_value, it may throw error\n            when you do insert\n\n    @param dependencies:\n        A variable that will be added to the path operation decorators.\n\n    @param crud_models:\n        You can use the sqlalchemy_to_pydantic() to build your own Pydantic model CRUD set\n\n    @param async_mode:\n        As your database connection\n\n    @param foreign_include: BaseModel\n        Used to build foreign tree api\n\n    @param sql_type:\n        You sql database type\n\n    @param router_kwargs:\n        other argument for FastApi's views\n\n    @return:\n        APIRouter for fastapi\n    \"\"\"\n\n    db_model, NO_PRIMARY_KEY = convert_table_to_model(db_model)\n\n    constraints = db_model.__table__.constraints\n\n    if db_session is None:\n        if async_mode:\n            db_connection = async_memory_db\n            db_session: Callable = db_connection.async_get_memory_db_session\n        else:\n            db_connection = sync_memory_db\n            db_session: Callable = db_connection.get_memory_db_session\n        db_connection.create_memory_table(db_model)\n\n    if async_mode is None:\n        async_mode = inspect.isasyncgen(db_session())\n\n    if sql_type is None:\n        async def async_runner(f):\n            return [i.bind.name async for i in f()]\n\n        try:\n            if async_mode:\n                sql_type, = asyncio.get_event_loop().run_until_complete(async_runner(db_session))\n            else:\n                sql_type, = [i.bind.name for i in db_session()]\n        except Exception:\n            raise RuntimeError(\"Some unknown problem occurred error, maybe you are uvicorn.run with reload=True. \"\n                               \"Try declaring sql_type for crud_router_builder yourself using from fastapi_quickcrud.misc.type import SqlType\")\n\n    if not crud_methods and NO_PRIMARY_KEY == False:\n        crud_methods = CrudMethods.get_declarative_model_full_crud_method()\n    if not crud_methods and NO_PRIMARY_KEY == True:\n        crud_methods = CrudMethods.get_table_full_crud_method()\n    result_parser_builder = SQLAlchemyGeneralSQLeResultParse\n\n    if sql_type == SqlType.sqlite:\n        routes_source = SQLAlchemySQLLiteRouteSource\n        query_service = SQLAlchemySQLITEQueryService\n    elif sql_type == SqlType.postgresql:\n        routes_source = SQLAlchemyPGSQLRouteSource\n        query_service = SQLAlchemyPGSQLQueryService\n    else:\n        routes_source = SQLAlchemyNotSupportRouteSource\n        query_service = SQLAlchemyNotSupportQueryService\n\n    if not crud_models:\n        crud_models_builder: CRUDModel = sqlalchemy_to_pydantic\n        crud_models: CRUDModel = crud_models_builder(db_model=db_model,\n                                                     constraints=constraints,\n                                                     crud_methods=crud_methods,\n                                                     exclude_columns=exclude_columns,\n                                                     sql_type=sql_type,\n                                                     foreign_include=foreign_include,\n                                                     exclude_primary_key=NO_PRIMARY_KEY)\n\n    foreign_table_mapping = {db_model.__tablename__: db_model}\n    if foreign_include:\n        for i in foreign_include:\n            model , _= convert_table_to_model(i)\n            foreign_table_mapping[model.__tablename__] = i\n    crud_service = query_service(model=db_model, async_mode=async_mode, foreign_table_mapping=foreign_table_mapping)\n    # else:\n    #     crud_service = SQLAlchemyPostgreQueryService(model=db_model, async_mode=async_mode)\n\n    result_parser = result_parser_builder(async_model=async_mode,\n                                          crud_models=crud_models,\n                                          autocommit=autocommit)\n    methods_dependencies = crud_models.get_available_request_method()\n    primary_name = crud_models.PRIMARY_KEY_NAME\n    if primary_name:\n        path = '/{' + primary_name + '}'\n    else:\n        path = \"\"\n    unique_list: List[str] = crud_models.UNIQUE_LIST\n\n    execute_service = SQLALchemyExecuteService()\n\n    def find_one_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        _request_url_param_model = request_response_model.get('requestUrlParamModel', None)\n        routes_source.find_one(path=path,\n                               request_url_param_model=_request_url_param_model,\n                               request_query_model=_request_query_model,\n                               response_model=_response_model,\n                               db_session=db_session,\n                               query_service=crud_service,\n                               parsing_service=result_parser,\n                               execute_service=execute_service,\n                               dependencies=dependencies,\n                               api=api,\n                               async_mode=async_mode)\n\n    def find_many_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        routes_source.find_many(path=\"\",\n                                request_query_model=_request_query_model,\n                                response_model=_response_model,\n                                db_session=db_session,\n                                query_service=crud_service,\n                                parsing_service=result_parser,\n                                execute_service=execute_service,\n                                dependencies=dependencies,\n                                api=api,\n                                async_mode=async_mode)\n\n    def upsert_one_api(request_response_model: dict, dependencies):\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        routes_source.upsert_one(path=\"\",\n                                 request_body_model=_request_body_model,\n                                 response_model=_response_model,\n                                 db_session=db_session,\n                                 query_service=crud_service,\n                                 parsing_service=result_parser,\n                                 execute_service=execute_service,\n                                 dependencies=dependencies,\n                                 api=api,\n                                 async_mode=async_mode,\n                                 unique_list=unique_list)\n\n    def upsert_many_api(request_response_model: dict, dependencies):\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n\n        routes_source.upsert_many(path=\"\",\n                                  request_body_model=_request_body_model,\n                                  response_model=_response_model,\n                                  db_session=db_session,\n                                  query_service=crud_service,\n                                  parsing_service=result_parser,\n                                  execute_service=execute_service,\n                                  dependencies=dependencies,\n                                  api=api,\n                                  unique_list=unique_list,\n                                  async_mode=async_mode)\n\n    def create_one_api(request_response_model: dict, dependencies):\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        routes_source.create_one(path=\"\",\n                                 request_body_model=_request_body_model,\n                                 response_model=_response_model,\n                                 db_session=db_session,\n                                 query_service=crud_service,\n                                 parsing_service=result_parser,\n                                 execute_service=execute_service,\n                                 dependencies=dependencies,\n                                 api=api,\n                                 async_mode=async_mode,\n                                 unique_list=unique_list)\n\n    def create_many_api(request_response_model: dict, dependencies):\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n\n        routes_source.create_many(path=\"\",\n                                  request_body_model=_request_body_model,\n                                  response_model=_response_model,\n                                  db_session=db_session,\n                                  query_service=crud_service,\n                                  parsing_service=result_parser,\n                                  execute_service=execute_service,\n                                  dependencies=dependencies,\n                                  api=api,\n                                  unique_list=unique_list,\n                                  async_mode=async_mode)\n\n    def delete_one_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _request_url_model = request_response_model.get('requestUrlParamModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n\n        routes_source.delete_one(path=path,\n                                 request_query_model=_request_query_model,\n                                 request_url_model=_request_url_model,\n                                 response_model=_response_model,\n                                 db_session=db_session,\n                                 query_service=crud_service,\n                                 parsing_service=result_parser,\n                                 execute_service=execute_service,\n                                 dependencies=dependencies,\n                                 api=api,\n                                 async_mode=async_mode)\n\n    def delete_many_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n\n        routes_source.delete_many(path=\"\",\n                                  request_query_model=_request_query_model,\n                                  response_model=_response_model,\n                                  db_session=db_session,\n                                  query_service=crud_service,\n                                  parsing_service=result_parser,\n                                  execute_service=execute_service,\n                                  dependencies=dependencies,\n                                  api=api,\n                                  async_mode=async_mode)\n\n    def post_redirect_get_api(request_response_model: dict, dependencies):\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n\n        routes_source.post_redirect_get(api=api,\n                                        dependencies=dependencies,\n                                        request_body_model=_request_body_model,\n                                        db_session=db_session,\n                                        crud_service=crud_service,\n                                        result_parser=result_parser,\n                                        execute_service=execute_service,\n                                        async_mode=async_mode,\n                                        response_model=_response_model)\n\n    def patch_one_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _request_url_param_model = request_response_model.get('requestUrlParamModel', None)\n\n        routes_source.patch_one(api=api,\n                                path=path,\n                                request_url_param_model=_request_url_param_model,\n                                request_query_model=_request_query_model,\n                                dependencies=dependencies,\n                                request_body_model=_request_body_model,\n                                db_session=db_session,\n                                crud_service=crud_service,\n                                result_parser=result_parser,\n                                execute_service=execute_service,\n                                async_mode=async_mode,\n                                response_model=_response_model)\n\n    def patch_many_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n\n        routes_source.patch_many(api=api,\n                                 path=\"\",\n                                 request_query_model=_request_query_model,\n                                 dependencies=dependencies,\n                                 request_body_model=_request_body_model,\n                                 db_session=db_session,\n                                 crud_service=crud_service,\n                                 result_parser=result_parser,\n                                 execute_service=execute_service,\n                                 async_mode=async_mode,\n                                 response_model=_response_model)\n\n    def put_one_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n        _request_url_param_model = request_response_model.get('requestUrlParamModel', None)\n        routes_source.put_one(api=api,\n                              path=path,\n                              request_query_model=_request_query_model,\n                              dependencies=dependencies,\n                              request_body_model=_request_body_model,\n                              db_session=db_session,\n                              crud_service=crud_service,\n                              result_parser=result_parser,\n                              execute_service=execute_service,\n                              async_mode=async_mode,\n                              response_model=_response_model,\n                              request_url_param_model=_request_url_param_model)\n\n    def put_many_api(request_response_model: dict, dependencies):\n        _request_query_model = request_response_model.get('requestQueryModel', None)\n        _response_model = request_response_model.get('responseModel', None)\n        _request_body_model = request_response_model.get('requestBodyModel', None)\n\n        routes_source.put_many(api=api,\n                               path='',\n                               request_query_model=_request_query_model,\n                               dependencies=dependencies,\n                               request_body_model=_request_body_model,\n                               db_session=db_session,\n                               crud_service=crud_service,\n                               result_parser=result_parser,\n                               execute_service=execute_service,\n                               async_mode=async_mode,\n                               response_model=_response_model)\n\n    def find_one_foreign_tree_api(request_response_model: dict, dependencies):\n        _foreign_list_model = request_response_model.get('foreignListModel', None)\n        for i in _foreign_list_model:\n            _request_query_model = i[\"request_query_model\"]\n            _response_model = i[\"response_model\"]\n            _path = i[\"path\"]\n            _function_name = i[\"function_name\"]\n            request_url_param_model = i[\"primary_key_dataclass_model\"]\n            routes_source.find_one_foreign_tree(path=_path,\n                                                request_query_model=_request_query_model,\n                                                response_model=_response_model,\n                                                request_url_param_model=request_url_param_model,\n                                                db_session=db_session,\n                                                query_service=crud_service,\n                                                parsing_service=result_parser,\n                                                execute_service=execute_service,\n                                                dependencies=dependencies,\n                                                api=api,\n                                                function_name=_function_name,\n                                                async_mode=async_mode)\n\n    def find_many_foreign_tree_api(request_response_model: dict, dependencies):\n        _foreign_list_model = request_response_model.get('foreignListModel', None)\n        for i in _foreign_list_model:\n            _request_query_model = i[\"request_query_model\"]\n            _response_model = i[\"response_model\"]\n            _path = i[\"path\"]\n            _function_name = i[\"function_name\"]\n            request_url_param_model = i[\"primary_key_dataclass_model\"]\n            routes_source.find_many_foreign_tree(path=_path,\n                                                 request_query_model=_request_query_model,\n                                                 response_model=_response_model,\n                                                 request_url_param_model=request_url_param_model,\n                                                 db_session=db_session,\n                                                 query_service=crud_service,\n                                                 parsing_service=result_parser,\n                                                 execute_service=execute_service,\n                                                 dependencies=dependencies,\n                                                 api=api,\n                                                 async_mode=async_mode,\n                                                 function_name=_function_name)\n\n    api_register = {\n        CrudMethods.FIND_ONE.value: find_one_api,\n        CrudMethods.FIND_MANY.value: find_many_api,\n        CrudMethods.UPSERT_ONE.value: upsert_one_api,\n        CrudMethods.UPSERT_MANY.value: upsert_many_api,\n        CrudMethods.CREATE_MANY.value: create_many_api,\n        CrudMethods.CREATE_ONE.value: create_one_api,\n        CrudMethods.DELETE_ONE.value: delete_one_api,\n        CrudMethods.DELETE_MANY.value: delete_many_api,\n        CrudMethods.POST_REDIRECT_GET.value: post_redirect_get_api,\n        CrudMethods.PATCH_ONE.value: patch_one_api,\n        CrudMethods.PATCH_MANY.value: patch_many_api,\n        CrudMethods.UPDATE_ONE.value: put_one_api,\n        CrudMethods.UPDATE_MANY.value: put_many_api,\n        CrudMethods.FIND_ONE_WITH_FOREIGN_TREE.value: find_one_foreign_tree_api,\n        CrudMethods.FIND_MANY_WITH_FOREIGN_TREE.value: find_many_foreign_tree_api\n    }\n    api = APIRouter(**router_kwargs)\n\n    if dependencies is None:\n        dependencies = []\n    dependencies = [Depends(dep) for dep in dependencies]\n    for request_method in methods_dependencies:\n        value_of_dict_crud_model = crud_models.get_model_by_request_method(request_method)\n        crud_model_of_this_request_methods = value_of_dict_crud_model.keys()\n        for crud_model_of_this_request_method in crud_model_of_this_request_methods:\n            request_response_model_of_this_request_method = value_of_dict_crud_model[crud_model_of_this_request_method]\n            api_register[crud_model_of_this_request_method.value](request_response_model_of_this_request_method,\n                                                                  dependencies)\n\n    return api\n\n\npgsql_crud_router_builder = partial(crud_router_builder)\ngeneric_sql_crud_router_builder = partial(crud_router_builder)\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/__init__.py",
    "content": ""
  },
  {
    "path": "src/fastapi_quickcrud/misc/abstract_execute.py",
    "content": "from typing import Any\n\nfrom sqlalchemy.sql.elements import BinaryExpression\n\n\nclass SQLALchemyExecuteService(object):\n\n    def __init__(self):\n        pass\n\n    # @staticmethod\n    # async def async_execute_and_expire(session, stmt: BinaryExpression) -> Any:\n    #     async_execute_and_expire_result = await session.execute(stmt)\n    #     session.expire_all()\n    #     return async_execute_and_expire_result\n    #\n    # @staticmethod\n    # def execute_and_expire(session, stmt: BinaryExpression) -> Any:\n    #     execute_and_expire_result = session.execute(stmt)\n    #     session.expire_all()\n    #     return execute_and_expire_result\n\n    @staticmethod\n    def add(session, model) -> Any:\n        session.add(model)\n\n    @staticmethod\n    def add_all(session, model) -> Any:\n        session.add_all(model)\n\n    @staticmethod\n    async def async_flush(session) -> Any:\n        await session.flush()\n\n    @staticmethod\n    def flush(session) -> Any:\n        session.flush()\n\n    @staticmethod\n    async def async_execute(session, stmt: BinaryExpression) -> Any:\n        return await session.execute(stmt)\n\n    @staticmethod\n    def execute(session, stmt: BinaryExpression) -> Any:\n        return session.execute(stmt)\n\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/abstract_parser.py",
    "content": "import copy\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\nfrom pydantic import parse_obj_as\nfrom starlette.responses import Response, RedirectResponse\n\nfrom .utils import group_find_many_join\nfrom .exceptions import FindOneApiNotRegister\n\n\nclass SQLAlchemyGeneralSQLeResultParse(object):\n\n    def __init__(self, async_model, crud_models, autocommit):\n\n        \"\"\"\n        :param async_model: bool\n        :param crud_models: pre ready\n        :param autocommit: bool\n        \"\"\"\n\n        self.async_mode = async_model\n        self.crud_models = crud_models\n        self.primary_name = crud_models.PRIMARY_KEY_NAME\n        self.autocommit = autocommit\n\n    async def async_commit(self, session):\n        await session.flush()\n        if self.autocommit:\n            await session.commit()\n\n    def commit(self, session):\n        session.flush()\n        if self.autocommit:\n            session.commit()\n\n    async def async_delete(self, session, data):\n        await session.delete(data)\n\n    def delete(self, session, data):\n        session.delete(data)\n\n    def update_data_model(self, data, update_args):\n        for update_arg_name, update_arg_value in update_args.items():\n            setattr(data, update_arg_name, update_arg_value)\n        return data\n\n    @staticmethod\n    async def async_rollback(session):\n        await session.rollback()\n\n    @staticmethod\n    def rollback(session):\n        session.rollback()\n\n    @staticmethod\n    def _response_builder(sql_execute_result, fastapi_response, response_model):\n        result = parse_obj_as(response_model, sql_execute_result)\n        fastapi_response.headers[\"x-total-count\"] = str(len(sql_execute_result) if isinstance(sql_execute_result, list)\n                                                        else '1')\n        return result\n\n    # async def async_update_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n    #     result = self._response_builder(sql_execute_result, fastapi_response, response_model)\n    #     await self.async_commit(kwargs.get('session'))\n    #     return result\n    #\n    # async def async_patch_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n    #     result = self._response_builder(sql_execute_result, fastapi_response, response_model)\n    #     await self.async_commit(kwargs.get('session'))\n    #     return result\n    #\n    # def patch_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n    #     result = self._response_builder(sql_execute_result, fastapi_response, response_model)\n    #     self.commit(kwargs.get('session'))\n    #     return result\n\n    def update_func(self, response_model, sql_execute_result, fastapi_response, update_args, update_one):\n        if not isinstance(sql_execute_result, list):\n            sql_execute_result = [sql_execute_result]\n        tmp = []\n        for i in sql_execute_result:\n            tmp.append(self.update_data_model(i, update_args=update_args))\n\n        if not update_one:\n            sql_execute_result = tmp\n        else:\n            sql_execute_result, = tmp\n        return self._response_builder(response_model=response_model,\n                                      sql_execute_result=sql_execute_result,\n                                      fastapi_response=fastapi_response)\n\n    def update(self, *, response_model, sql_execute_result, fastapi_response, update_args, **kwargs):\n        session = kwargs.get('session')\n        update_one = kwargs.get('update_one')\n        result = self.update_func(response_model, sql_execute_result, fastapi_response, update_args, update_one)\n        self.commit(session)\n        return result\n\n    async def async_update(self, *, response_model, sql_execute_result, fastapi_response, update_args, **kwargs):\n        session = kwargs.get('session')\n        update_one = kwargs.get('update_one')\n        result = self.update_func(response_model, sql_execute_result, fastapi_response, update_args, update_one)\n        await self.async_commit(session)\n        return result\n\n    @staticmethod\n    def find_one_sub_func(sql_execute_result, response_model, fastapi_response, **kwargs):\n        join = kwargs.get('join_mode', None)\n\n        one_row_data = sql_execute_result.fetchall()\n        if not one_row_data:\n            return Response('specific data not found', status_code=HTTPStatus.NOT_FOUND)\n        response = []\n        for i in one_row_data:\n            i = dict(i)\n            result__ = copy.deepcopy(i)\n            tmp = {}\n            for key_, value_ in result__.items():\n                if '_____' in key_:\n                    key, foreign_column = key_.split('_____')\n                    if key not in tmp:\n                        tmp[key] = {foreign_column: value_}\n                    else:\n                        tmp[key][foreign_column] = value_\n                else:\n                    tmp[key_] = value_\n            response.append(tmp)\n        if join:\n            response = group_find_many_join(response)\n        if isinstance(response, list):\n            response = response[0]\n        fastapi_response.headers[\"x-total-count\"] = str(1)\n        return response\n\n    async def async_find_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.find_one_sub_func(sql_execute_result, response_model, fastapi_response, **kwargs)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def find_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.find_one_sub_func(sql_execute_result, response_model, fastapi_response, **kwargs)\n        self.commit(kwargs.get('session'))\n        return result\n\n    @staticmethod\n    def find_many_sub_func(response_model, sql_execute_result, fastapi_response, **kwargs):\n        join = kwargs.get('join_mode', None)\n        result = sql_execute_result.fetchall()\n        if not result:\n            return Response(status_code=HTTPStatus.NO_CONTENT)\n        response = []\n        for i in result:\n            i = dict(i)\n            result__ = copy.deepcopy(i)\n            tmp = {}\n            for key_, value_ in result__.items():\n                if '_____' in key_:\n                    key, foreign_column = key_.split('_____')\n                    if key not in tmp:\n                        tmp[key] = {foreign_column: value_}\n                    else:\n                        tmp[key][foreign_column] = value_\n                else:\n                    tmp[key_] = value_\n            response.append(tmp)\n\n        fastapi_response.headers[\"x-total-count\"] = str(len(response))\n        if join:\n            response = group_find_many_join(response)\n        response = parse_obj_as(response_model, response)\n        return response\n\n    async def async_find_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.find_many_sub_func(response_model, sql_execute_result, fastapi_response, **kwargs)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def find_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.find_many_sub_func(response_model, sql_execute_result, fastapi_response, **kwargs)\n        self.commit(kwargs.get('session'))\n        return result\n\n    # @staticmethod\n    # def update_one_sub_func(response_model, sql_execute_result, fastapi_response):\n    #     result = parse_obj_as(response_model, sql_execute_result)\n    #     fastapi_response.headers[\"x-total-count\"] = str(1)\n    #     return result\n    #\n    # async def async_update_one(self, *, response_model, sql_execute_result, fastapi_response, update_args, **kwargs):\n    #     session = kwargs.get('session')\n    #     if not sql_execute_result:\n    #         return Response(status_code=HTTPStatus.NOT_FOUND)\n    #     data = self.update_data_model(sql_execute_result, update_args=update_args)\n    #     result = self.update_one_sub_func(response_model, data, fastapi_response)\n    #     await self.commit(session)\n    #     return result\n    #\n    # def update_one(self, *, response_model, sql_execute_result, fastapi_response, update_args, **kwargs):\n    #     session = kwargs.get('session')\n    #     if not sql_execute_result:\n    #         return Response(status_code=HTTPStatus.NOT_FOUND)\n    #     data = self.update_data_model(sql_execute_result, update_args=update_args)\n    #     result = self.update_one_sub_func(response_model, data, fastapi_response)\n    #     self.commit(session)\n    #     return result\n\n    # async def async_patch_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n    #     result = self.update_one_sub_func(response_model, sql_execute_result, fastapi_response)\n    #     await self.async_commit(kwargs.get('session'))\n    #     return result\n    #\n    # def patch_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n    #     result = self.update_one_sub_func(response_model, sql_execute_result, fastapi_response)\n    #     self.commit(kwargs.get('session'))\n    #     return result\n\n    @staticmethod\n    def create_one_sub_func(response_model, sql_execute_result, fastapi_response):\n        inserted_data, = sql_execute_result\n        result = parse_obj_as(response_model, inserted_data)\n        fastapi_response.headers[\"x-total-count\"] = str(1)\n        return result\n\n    async def async_create_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.create_one_sub_func(response_model, sql_execute_result, fastapi_response)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def create_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.create_one_sub_func(response_model, sql_execute_result, fastapi_response)\n        self.commit(kwargs.get('session'))\n        return result\n\n    @staticmethod\n    def create_many_sub_func(response_model, sql_execute_result, fastapi_response):\n        result = parse_obj_as(response_model, sql_execute_result)\n        fastapi_response.headers[\"x-total-count\"] = str(len(sql_execute_result))\n        return result\n\n    async def async_create_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.create_many_sub_func(response_model, sql_execute_result, fastapi_response)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def create_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.create_many_sub_func(response_model, sql_execute_result, fastapi_response)\n        self.commit(kwargs.get('session'))\n        return result\n\n    @staticmethod\n    def upsert_one_sub_func(response_model, sql_execute_result, fastapi_response):\n        sql_execute_result = sql_execute_result.fetchone()\n        result = parse_obj_as(response_model, dict(sql_execute_result))\n        fastapi_response.headers[\"x-total-count\"] = str(1)\n        return result\n\n    async def async_upsert_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.upsert_one_sub_func(response_model, sql_execute_result, fastapi_response)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def upsert_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.upsert_one_sub_func(response_model, sql_execute_result, fastapi_response)\n        self.commit(kwargs.get('session'))\n        return result\n\n    @staticmethod\n    def upsert_many_sub_func(response_model, sql_execute_result, fastapi_response):\n        insert_result_list = sql_execute_result.fetchall()\n        result = parse_obj_as(response_model, insert_result_list)\n        fastapi_response.headers[\"x-total-count\"] = str(len(insert_result_list))\n        return result\n\n    async def async_upsert_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.upsert_many_sub_func(response_model, sql_execute_result, fastapi_response)\n        await self.async_commit(kwargs.get('session'))\n        return result\n\n    def upsert_many(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        result = self.upsert_many_sub_func(response_model, sql_execute_result, fastapi_response)\n        self.commit(kwargs.get('session'))\n        return result\n\n    def delete_one_sub_func(self, response_model, sql_execute_result, fastapi_response, **kwargs):\n        if not sql_execute_result:\n            return Response(status_code=HTTPStatus.NOT_FOUND)\n        result = parse_obj_as(response_model, sql_execute_result)\n        fastapi_response.headers[\"x-total-count\"] = str(1)\n        return result\n\n    def delete_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        session = kwargs.get('session')\n        if sql_execute_result:\n            self.delete(session, sql_execute_result)\n        result = self.delete_one_sub_func(response_model, sql_execute_result, fastapi_response, **kwargs)\n        self.commit(session)\n        return result\n\n    async def async_delete_one(self, *, response_model, sql_execute_result, fastapi_response, **kwargs):\n        session = kwargs.get('session')\n        if sql_execute_result:\n            self.delete(session, sql_execute_result)\n        result = self.delete_one_sub_func(response_model, sql_execute_result, fastapi_response, **kwargs)\n        await self.async_commit(session)\n        return result\n\n    def delete_many_sub_func(self, response_model, sql_execute_result, fastapi_response):\n        if not sql_execute_result:\n            return Response(status_code=HTTPStatus.NO_CONTENT)\n        deleted_rows = sql_execute_result\n        result = parse_obj_as(response_model, deleted_rows)\n        fastapi_response.headers[\"x-total-count\"] = str(len(deleted_rows))\n        return result\n\n    def delete_many(self, *, response_model, sql_execute_results, fastapi_response, **kwargs):\n        session = kwargs.get('session')\n        if sql_execute_results:\n            for sql_execute_result in sql_execute_results:\n                self.delete(session, sql_execute_result)\n        result = self.delete_many_sub_func(response_model, sql_execute_results, fastapi_response)\n        self.commit(session)\n        return result\n\n    async def async_delete_many(self, *, response_model, sql_execute_results, fastapi_response, **kwargs):\n        session = kwargs.get('session')\n        if sql_execute_results:\n            for sql_execute_result in sql_execute_results:\n                await self.async_delete(session, sql_execute_result)\n        result = self.delete_many_sub_func(response_model, sql_execute_results, fastapi_response)\n        await self.async_commit(session)\n        return result\n\n    def has_end_point(self, fastapi_request) -> bool:\n        redirect_end_point = fastapi_request.url.path + \"/{\" + self.primary_name + \"}\"\n        redirect_url_exist = False\n        for route in fastapi_request.app.routes:\n            if route.path == redirect_end_point:\n                route_request_method, = route.methods\n                if route_request_method.upper() == 'GET':\n                    redirect_url_exist = True\n        return redirect_url_exist\n\n    def post_redirect_get_sub_func(self, response_model, sql_execute_result, fastapi_request):\n        result = parse_obj_as(response_model, sql_execute_result)\n        primary_key_field = result.__dict__.pop(self.primary_name, None)\n        assert primary_key_field is not None\n        redirect_url = fastapi_request.url.path + \"/\" + str(primary_key_field)\n        return redirect_url\n\n    def get_post_redirect_get_url(self, response_model, sql_execute_result, fastapi_request):\n        redirect_url = self.post_redirect_get_sub_func(response_model, sql_execute_result, fastapi_request)\n        header_dict = {i[0].decode(\"utf-8\"): i[1].decode(\"utf-8\") for i in fastapi_request.headers.__dict__['_list']}\n        redirect_url += f'?{urlencode(header_dict)}'\n        return redirect_url\n\n    async def async_post_redirect_get(self, *, response_model, sql_execute_result, fastapi_request, **kwargs):\n        session = kwargs['session']\n        if not self.has_end_point(fastapi_request):\n            await self.async_rollback(session)\n            raise FindOneApiNotRegister(404,\n                                        f'End Point {fastapi_request.url.path}/{ {self.primary_name} }'\n                                        f' with GET method not found')\n        redirect_url = self.get_post_redirect_get_url(response_model, sql_execute_result, fastapi_request)\n        await self.async_commit(session)\n        return RedirectResponse(redirect_url,\n                                status_code=HTTPStatus.SEE_OTHER\n                                )\n\n    def post_redirect_get(self, *, response_model, sql_execute_result, fastapi_request, **kwargs):\n        session = kwargs['session']\n        if not self.has_end_point(fastapi_request):\n            self.rollback(session)\n            raise FindOneApiNotRegister(404,\n                                        f'End Point {fastapi_request.url.path}/{ {self.primary_name} }'\n                                        f' with GET method not found')\n        redirect_url = self.get_post_redirect_get_url(response_model, sql_execute_result, fastapi_request)\n        self.commit(session)\n        return RedirectResponse(redirect_url,\n                                status_code=HTTPStatus.SEE_OTHER\n                                )\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/abstract_query.py",
    "content": "from abc import ABC\nfrom typing import List, Union\n\nfrom sqlalchemy import and_, select, text\nfrom sqlalchemy.dialects.postgresql import insert\nfrom sqlalchemy.sql.elements import BinaryExpression\nfrom sqlalchemy.sql.schema import Table\n\nfrom .exceptions import UnknownOrderType, UnknownColumn, UpdateColumnEmptyException\nfrom .type import Ordering\nfrom .utils import clean_input_fields, path_query_builder\nfrom .utils import find_query_builder\n\n\nclass SQLAlchemyGeneralSQLQueryService(ABC):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n        self.foreign_table_mapping = foreign_table_mapping\n\n    def get_many(self, *,\n                 join_mode,\n                 query,\n                 target_model=None,\n                 abstract_param=None\n                 ) -> BinaryExpression:\n        filter_args = query\n        limit = filter_args.pop('limit', None)\n        offset = filter_args.pop('offset', None)\n        order_by_columns = filter_args.pop('order_by_columns', None)\n        model = self.model\n        if target_model:\n            model = self.foreign_table_mapping[target_model]\n        filter_list: List[BinaryExpression] = find_query_builder(param=filter_args,\n                                                                 model=model)\n        path_filter_list: List[BinaryExpression] = path_query_builder(params=abstract_param,\n                                                                      model=self.foreign_table_mapping)\n        join_table_instance_list: list = self.get_join_select_fields(join_mode)\n\n\n        if not isinstance(self.model, Table):\n            model = model.__table__\n\n        stmt = select(*[model] + join_table_instance_list).filter(and_(*filter_list+path_filter_list))\n        if order_by_columns:\n            order_by_query_list = []\n\n            for order_by_column in order_by_columns:\n                if not order_by_column:\n                    continue\n                sort_column, order_by = (order_by_column.replace(' ', '').split(':') + [None])[:2]\n                if not hasattr(self.model_columns, sort_column):\n                    raise UnknownColumn(f'column {sort_column} is not exited')\n                if not order_by:\n                    order_by_query_list.append(getattr(self.model_columns, sort_column).asc())\n                elif order_by.upper() == Ordering.DESC.upper():\n                    order_by_query_list.append(getattr(self.model_columns, sort_column).desc())\n                elif order_by.upper() == Ordering.ASC.upper():\n                    order_by_query_list.append(getattr(self.model_columns, sort_column).asc())\n                else:\n                    raise UnknownOrderType(f\"Unknown order type {order_by}, only accept DESC or ASC\")\n            if order_by_query_list:\n                stmt = stmt.order_by(*order_by_query_list)\n        stmt = stmt.limit(limit).offset(offset)\n        stmt = self.get_join_by_excpression(stmt, join_mode=join_mode)\n        return stmt\n\n    def get_one(self, *,\n                extra_args: dict,\n                filter_args: dict,\n                join_mode=None\n                ) -> BinaryExpression:\n        filter_list: List[BinaryExpression] = find_query_builder(param=filter_args,\n                                                                 model=self.model_columns)\n\n        extra_query_expression: List[BinaryExpression] = find_query_builder(param=extra_args,\n                                                                            model=self.model)\n        join_table_instance_list: list = self.get_join_select_fields(join_mode)\n        model = self.model\n        if not isinstance(self.model, Table):\n            model = model.__table__\n        stmt = select(*[model] + join_table_instance_list).where(and_(*filter_list + extra_query_expression))\n        # stmt = session.query(*[model] + join_table_instance_list).filter(and_(*filter_list + extra_query_expression))\n        stmt = self.get_join_by_excpression(stmt, join_mode=join_mode)\n        return stmt\n\n    def create(self, *,\n               insert_arg,\n               create_one=True,\n               ) -> List[BinaryExpression]:\n        insert_arg_dict: Union[list, dict] = insert_arg\n        if not create_one:\n            insert_arg_list: list = insert_arg_dict.pop('insert', None)\n            insert_arg_dict = []\n            for i in insert_arg_list:\n                insert_arg_dict.append(i.__dict__)\n        if not isinstance(insert_arg_dict, list):\n            insert_arg_dict = [insert_arg_dict]\n\n        insert_arg_dict: list[dict] = [clean_input_fields(model=self.model_columns, param=insert_arg)\n                                       for insert_arg in insert_arg_dict]\n        if isinstance(insert_arg_dict, list):\n            new_data = []\n            for i in insert_arg_dict:\n                new_data.append(self.model(**i))\n        return new_data\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n    def insert_one(self, *,\n                   insert_args) -> BinaryExpression:\n        insert_args = insert_args\n        update_columns = clean_input_fields(insert_args,\n                                            self.model_columns)\n        inserted_instance = self.model(**update_columns)\n        return inserted_instance\n\n    def get_join_select_fields(self, join_mode=None):\n        join_table_instance_list = []\n        if not join_mode:\n            return join_table_instance_list\n        for _, table_instance in join_mode.items():\n            for local_reference in table_instance['local_reference_pairs_set']:\n                if 'exclude' in local_reference and local_reference['exclude']:\n                    continue\n                for column in local_reference['reference_table_columns']:\n                    foreign_table_name = local_reference['reference']['reference_table']\n                    join_table_instance_list.append(\n                        column.label(foreign_table_name + '_foreign_____' + str(column).split('.')[1]))\n        return join_table_instance_list\n\n    def get_join_by_excpression(self, stmt: BinaryExpression, join_mode=None) -> BinaryExpression:\n        if not join_mode:\n            return stmt\n        for join_table, data in join_mode.items():\n            for local_reference in data['local_reference_pairs_set']:\n                local = local_reference['local']['local_column']\n                reference = local_reference['reference']['reference_column']\n                local_column = getattr(local_reference['local_table_columns'], local)\n                reference_column = getattr(local_reference['reference_table_columns'], reference)\n                table = local_reference['reference_table']\n                stmt = stmt.join(table, local_column == reference_column)\n        return stmt\n\n    # def delete(self,\n    #            *,\n    #            delete_args: dict,\n    #            session,\n    #            primary_key: dict = None,\n    #            ) -> BinaryExpression:\n    #     filter_list: List[BinaryExpression] = find_query_builder(param=delete_args,\n    #                                                              model=self.model_columns)\n    #     if primary_key:\n    #         filter_list += find_query_builder(param=primary_key,\n    #                                           model=self.model_columns)\n    #\n    #     delete_instance = session.query(self.model).where(and_(*filter_list))\n    #     return delete_instance\n\n    def model_query(self,\n                    *,\n                    session,\n                    extra_args: dict = None,\n                    filter_args: dict = None,\n                    ) -> BinaryExpression:\n\n        '''\n        used for delette and update\n        '''\n\n        filter_list: List[BinaryExpression] = find_query_builder(param=filter_args,\n                                                                 model=self.model_columns)\n        if extra_args:\n            filter_list += find_query_builder(param=extra_args,\n                                              model=self.model_columns)\n        stmt = select(self.model).where(and_(*filter_list))\n        return stmt\n\n    def get_one_with_foreign_pk(self, *,\n                                 join_mode,\n                                 query,\n                                 target_model,\n                                 abstract_param=None\n                                 ) -> BinaryExpression:\n        model = self.foreign_table_mapping[target_model]\n        filter_list: List[BinaryExpression] = find_query_builder(param=query,\n                                                                 model=model)\n        path_filter_list: List[BinaryExpression] = path_query_builder(params=abstract_param,\n                                                                      model=self.foreign_table_mapping)\n        join_table_instance_list: list = self.get_join_select_fields(join_mode)\n\n        if not isinstance(self.model, Table):\n            model = model.__table__\n\n        stmt = select(*[model] + join_table_instance_list).filter(and_(*filter_list + path_filter_list))\n\n        stmt = self.get_join_by_excpression(stmt, join_mode=join_mode)\n        return stmt\n\n\n    # def update(self, *,\n    #            update_args,\n    #            extra_query,\n    #            session,\n    #            primary_key=None,\n    #            ) -> BinaryExpression:\n    #\n    #\n    #     filter_list: List[BinaryExpression] = find_query_builder(param=extra_query,\n    #                                                              model=self.model_columns)\n    #     if primary_key:\n    #         primary_key = primary_key\n    #         filter_list += find_query_builder(param=primary_key, model=self.model_columns)\n    #     update_stmt = update(self.model).where(and_(*filter_list)).values(update_args)\n    #     update_stmt = update_stmt.execution_options(synchronize_session=False)\n    #     return update_stmt\n\n\nclass SQLAlchemyPGSQLQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super(SQLAlchemyPGSQLQueryService,\n              self).__init__(model=model,\n                             async_mode=async_mode,\n                             foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        insert_arg_dict: Union[list, dict] = insert_arg\n\n        insert_with_conflict_handle = insert_arg_dict.pop('on_conflict', None)\n        if not upsert_one:\n            insert_arg_list: list = insert_arg_dict.pop('insert', None)\n            insert_arg_dict = []\n            for i in insert_arg_list:\n                insert_arg_dict.append(i.__dict__)\n\n        if not isinstance(insert_arg_dict, list):\n            insert_arg_dict: list[dict] = [insert_arg_dict]\n        insert_arg_dict: list[dict] = [clean_input_fields(model=self.model_columns, param=insert_arg)\n                                       for insert_arg in insert_arg_dict]\n        insert_stmt = insert(self.model).values(insert_arg_dict)\n\n        if unique_fields and insert_with_conflict_handle:\n            update_columns = clean_input_fields(insert_with_conflict_handle.__dict__.get('update_columns', None),\n                                                self.model_columns)\n            if not update_columns:\n                raise UpdateColumnEmptyException('update_columns parameter must be a non-empty list ')\n            conflict_update_dict = {}\n            for columns in update_columns:\n                conflict_update_dict[columns] = getattr(insert_stmt.excluded, columns)\n\n            conflict_list = clean_input_fields(model=self.model_columns, param=unique_fields)\n            conflict_update_dict = clean_input_fields(model=self.model_columns, param=conflict_update_dict)\n            insert_stmt = insert_stmt.on_conflict_do_update(index_elements=conflict_list,\n                                                            set_=conflict_update_dict\n                                                            )\n        insert_stmt = insert_stmt.returning(text('*'))\n        return insert_stmt\n\n\nclass SQLAlchemySQLITEQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n\nclass SQLAlchemyMySQLQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n\nclass SQLAlchemyMariaDBQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n\nclass SQLAlchemyOracleQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n\nclass SQLAlchemyMSSqlQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n\n\nclass SQLAlchemyNotSupportQueryService(SQLAlchemyGeneralSQLQueryService):\n\n    def __init__(self, *, model, async_mode, foreign_table_mapping):\n        \"\"\"\n        :param model: declarative_base model\n        :param async_mode: bool\n        \"\"\"\n        super().__init__(model=model,\n                         async_mode=async_mode,\n                         foreign_table_mapping=foreign_table_mapping)\n        self.model = model\n        self.model_columns = model\n        self.async_mode = async_mode\n\n    def upsert(self, *,\n               insert_arg,\n               unique_fields: List[str],\n               upsert_one=True,\n               ) -> BinaryExpression:\n        raise NotImplementedError\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/abstract_route.py",
    "content": "from abc import abstractmethod, ABC\nfrom http import HTTPStatus\nfrom typing import Union\n\nfrom fastapi import \\\n    Depends, \\\n    Response\nfrom sqlalchemy.exc import IntegrityError\nfrom starlette.requests import Request\n\n\nclass SQLAlchemyGeneralSQLBaseRouteSource(ABC):\n    \"\"\" This route will support the SQL SQLAlchemy dialects. \"\"\"\n\n    @classmethod\n    def find_one(cls, api,\n                 *,\n                 path,\n                 query_service,\n                 parsing_service,\n                 execute_service,\n                 async_mode,\n                 response_model,\n                 dependencies,\n                 request_url_param_model,\n                 request_query_model,\n                 db_session):\n\n        if not async_mode:\n            @api.get(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            def get_one_by_primary_key(response: Response,\n                                       request: Request,\n                                       url_param=Depends(request_url_param_model),\n                                       query=Depends(request_query_model),\n                                       session=Depends(db_session)):\n\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_one(filter_args=query.__dict__,\n                                             extra_args=url_param.__dict__,\n                                             join_mode=join)\n                query_result = execute_service.execute(session, stmt)\n                response_result = parsing_service.find_one(response_model=response_model,\n                                                           sql_execute_result=query_result,\n                                                           fastapi_response=response,\n                                                           session=session,\n                                                           join_mode=join)\n                return response_result\n        else:\n            @api.get(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            async def async_get_one_by_primary_key(response: Response,\n                                                   request: Request,\n                                                   url_param=Depends(request_url_param_model),\n                                                   query=Depends(request_query_model),\n                                                   session=Depends(db_session)):\n\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_one(filter_args=query.__dict__,\n                                             extra_args=url_param.__dict__,\n                                             join_mode=join)\n                query_result = await execute_service.async_execute(session, stmt)\n\n                response_result = await parsing_service.async_find_one(response_model=response_model,\n                                                                       sql_execute_result=query_result,\n                                                                       fastapi_response=response,\n                                                                       session=session,\n                                                                       join_mode=join)\n                return response_result\n\n    @classmethod\n    def find_many(cls, api, *,\n                  query_service,\n                  parsing_service,\n                  execute_service,\n                  async_mode,\n                  path,\n                  response_model,\n                  dependencies,\n                  request_query_model,\n                  db_session):\n\n        if async_mode:\n            @api.get(path, dependencies=dependencies, response_model=response_model)\n            async def async_get_many(response: Response,\n                                     request: Request,\n                                     query=Depends(request_query_model),\n                                     session=Depends(\n                                         db_session)\n                                     ):\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_many(query=query.__dict__, join_mode=join)\n\n                query_result = await execute_service.async_execute(session, stmt)\n\n                parsed_response = await parsing_service.async_find_many(response_model=response_model,\n                                                                        sql_execute_result=query_result,\n                                                                        fastapi_response=response,\n                                                                        join_mode=join,\n                                                                        session=session)\n                return parsed_response\n        else:\n            @api.get(path, dependencies=dependencies, response_model=response_model)\n            def get_many(response: Response,\n                         request: Request,\n                         query=Depends(request_query_model),\n                         session=Depends(\n                             db_session)\n                         ):\n                join = query.__dict__.pop('join_foreign_table', None)\n\n                stmt = query_service.get_many(query=query.__dict__, join_mode=join)\n                query_result = execute_service.execute(session, stmt)\n                parsed_response = parsing_service.find_many(response_model=response_model,\n                                                            sql_execute_result=query_result,\n                                                            fastapi_response=response,\n                                                            join_mode=join,\n                                                            session=session)\n                return parsed_response\n\n    @abstractmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @abstractmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n\n        raise NotImplementedError\n\n    @classmethod\n    def create_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        if async_mode:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_one(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                # stmt = query_service.create(insert_arg=query)\n\n                new_inserted_data = query_service.create(insert_arg=query.__dict__)\n\n                execute_service.add_all(session, new_inserted_data)\n                try:\n                    await execute_service.async_flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return await parsing_service.async_create_one(response_model=response_model,\n                                                              sql_execute_result=new_inserted_data,\n                                                              fastapi_response=response,\n                                                              session=session)\n        else:\n\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_one(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n\n                new_inserted_data = query_service.create(insert_arg=query.__dict__)\n\n                execute_service.add_all(session, new_inserted_data)\n\n                try:\n                    execute_service.flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return parsing_service.create_one(response_model=response_model,\n                                                  sql_execute_result=new_inserted_data,\n                                                  fastapi_response=response,\n                                                  session=session)\n\n    @classmethod\n    def create_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n\n        if async_mode:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_many(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                inserted_data = query_service.create(insert_arg=query.__dict__,\n                                                     create_one=False)\n\n                execute_service.add_all(session, inserted_data)\n\n                try:\n                    await execute_service.async_flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return await parsing_service.async_create_many(response_model=response_model,\n                                                               sql_execute_result=inserted_data,\n                                                               fastapi_response=response,\n                                                               session=session)\n        else:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_many(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n\n                # inserted_data = query.__dict__['insert']\n                update_list = query.__dict__\n                inserted_data = query_service.create(insert_arg=update_list,\n                                                     create_one=False)\n\n                execute_service.add_all(session, inserted_data)\n\n                try:\n                    execute_service.flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return parsing_service.create_many(response_model=response_model,\n                                                   sql_execute_result=inserted_data,\n                                                   fastapi_response=response,\n                                                   session=session)\n\n    @classmethod\n    def delete_one(cls, api, *,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   path,\n                   response_model,\n                   dependencies,\n                   request_query_model,\n                   request_url_model,\n                   db_session, ):\n\n        if async_mode:\n            @api.delete(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            async def async_delete_one_by_primary_key(response: Response,\n                                                      request: Request,\n                                                      query=Depends(request_query_model),\n                                                      request_url_param_model=Depends(request_url_model),\n                                                      session=Depends(db_session)):\n                # delete_instance = query_service.model_query(\n                #     filter_args=request_url_param_model.__dict__,\n                #     extra_args=query.__dict__,\n                #     session=session)\n                filter_stmt = query_service.model_query(filter_args=request_url_param_model.__dict__,\n                                                        extra_args=query.__dict__,\n                                                        session=session)\n\n                tmp = await session.execute(filter_stmt)\n                delete_instance = tmp.scalar()\n\n                return await parsing_service.async_delete_one(response_model=response_model,\n                                                              sql_execute_result=delete_instance,\n                                                              fastapi_response=response,\n                                                              session=session)\n\n        else:\n            @api.delete(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            def delete_one_by_primary_key(response: Response,\n                                          request: Request,\n                                          query=Depends(request_query_model),\n                                          request_url_param_model=Depends(request_url_model),\n                                          session=Depends(db_session)):\n                filter_stmt = query_service.model_query(filter_args=request_url_param_model.__dict__,\n                                                        extra_args=query.__dict__,\n                                                        session=session)\n                delete_instance = session.execute(filter_stmt).scalar()\n\n                return parsing_service.delete_one(response_model=response_model,\n                                                  sql_execute_result=delete_instance,\n                                                  fastapi_response=response,\n                                                  session=session)\n\n    @classmethod\n    def delete_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    execute_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_query_model,\n                    db_session):\n        if async_mode:\n            @api.delete(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            async def async_delete_many_by_query(response: Response,\n                                                 request: Request,\n                                                 query=Depends(request_query_model),\n                                                 session=Depends(db_session)):\n                filter_stmt = query_service.model_query(filter_args=query.__dict__,\n                                                        session=session)\n\n                tmp = await session.execute(filter_stmt)\n                data_instance = [i for i in tmp.scalars()]\n                return await parsing_service.async_delete_many(response_model=response_model,\n                                                               sql_execute_results=data_instance,\n                                                               fastapi_response=response,\n                                                               session=session)\n        else:\n\n            @api.delete(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            def delete_many_by_query(response: Response,\n                                     request: Request,\n                                     query=Depends(request_query_model),\n                                     session=Depends(db_session)):\n                filter_stmt = query_service.model_query(filter_args=query.__dict__,\n                                                        session=session)\n\n                delete_instance = [i for i in session.execute(filter_stmt).scalars()]\n\n                return parsing_service.delete_many(response_model=response_model,\n                                                   sql_execute_results=delete_instance,\n                                                   fastapi_response=response,\n                                                   session=session)\n\n    @classmethod\n    def post_redirect_get(cls, api, *,\n                          dependencies,\n                          request_body_model,\n                          db_session,\n                          crud_service,\n                          result_parser,\n                          execute_service,\n                          async_mode,\n                          response_model):\n        if async_mode:\n            @api.post(\"\", status_code=303, response_class=Response, dependencies=dependencies)\n            async def async_create_one_and_redirect_to_get_one_api_with_primary_key(\n                    request: Request,\n                    insert_args: request_body_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                new_inserted_data = crud_service.insert_one(insert_args=insert_args.__dict__)\n\n                execute_service.add(session, new_inserted_data)\n                try:\n                    await execute_service.async_flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return await result_parser.async_post_redirect_get(response_model=response_model,\n                                                                   sql_execute_result=new_inserted_data,\n                                                                   fastapi_request=request,\n                                                                   session=session)\n        else:\n            @api.post(\"\", status_code=303, response_class=Response, dependencies=dependencies)\n            def create_one_and_redirect_to_get_one_api_with_primary_key(\n                    request: Request,\n                    insert_args: request_body_model = Depends(),\n                    session=Depends(db_session),\n            ):\n\n                new_inserted_data = crud_service.insert_one(insert_args=insert_args.__dict__)\n\n                execute_service.add(session, new_inserted_data)\n                try:\n                    execute_service.flush(session)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n                return result_parser.post_redirect_get(response_model=response_model,\n                                                       sql_execute_result=new_inserted_data,\n                                                       fastapi_request=request,\n                                                       session=session)\n\n    @classmethod\n    def patch_one(cls, api, *,\n                  path,\n                  response_model,\n                  dependencies,\n                  request_url_param_model,\n                  request_body_model,\n                  request_query_model,\n                  execute_service,\n                  db_session,\n                  crud_service,\n                  result_parser,\n                  async_mode):\n        if async_mode:\n\n            @api.patch(path,\n                       status_code=200,\n                       response_model=Union[response_model],\n                       dependencies=dependencies)\n            async def async_partial_update_one_by_primary_key(\n                    response: Response,\n                    primary_key: request_url_param_model = Depends(),\n                    patch_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                filter_stmt = crud_service.model_query(filter_args=primary_key.__dict__,\n                                                       extra_args=extra_query.__dict__,\n                                                       session=session)\n\n                data_instance = await session.execute(filter_stmt)\n                data_instance = data_instance.scalar()\n\n                try:\n                    return await result_parser.async_update(response_model=response_model,\n                                                            sql_execute_result=data_instance,\n                                                            update_args=patch_data.__dict__,\n                                                            fastapi_response=response,\n                                                            session=session,\n                                                            update_one=True)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n        else:\n            @api.patch(path,\n                       status_code=200,\n                       response_model=Union[response_model],\n                       dependencies=dependencies)\n            def partial_update_one_by_primary_key(\n                    response: Response,\n                    primary_key: request_url_param_model = Depends(),\n                    patch_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                filter_stmt = crud_service.model_query(filter_args=primary_key.__dict__,\n                                                       extra_args=extra_query.__dict__,\n                                                       session=session)\n\n                update_instance = session.execute(filter_stmt).scalar()\n\n                try:\n                    return result_parser.update(response_model=response_model,\n                                                sql_execute_result=update_instance,\n                                                update_args=patch_data.__dict__,\n                                                fastapi_response=response,\n                                                session=session,\n                                                update_one=True)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n    @classmethod\n    def patch_many(cls, api, *,\n                   path,\n                   response_model,\n                   dependencies,\n                   request_body_model,\n                   request_query_model,\n                   db_session,\n                   crud_service,\n                   result_parser,\n                   execute_service,\n                   async_mode):\n        if async_mode:\n            @api.patch(path,\n                       status_code=200,\n                       response_model=response_model,\n                       dependencies=dependencies)\n            async def async_partial_update_many_by_query(\n                    response: Response,\n                    patch_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session)\n            ):\n\n                filter_stmt = crud_service.model_query(filter_args=extra_query.__dict__,\n                                                       session=session)\n\n                tmp = await session.execute(filter_stmt)\n                data_instance = [i for i in tmp.scalars()]\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NO_CONTENT)\n                try:\n                    return await result_parser.async_update(response_model=response_model,\n                                                            sql_execute_result=data_instance,\n                                                            fastapi_response=response,\n                                                            update_args=patch_data.__dict__,\n                                                            session=session,\n                                                            update_one=False)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n        else:\n            @api.patch(path,\n                       status_code=200,\n                       response_model=response_model,\n                       dependencies=dependencies)\n            def partial_update_many_by_query(\n                    response: Response,\n                    patch_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session)\n            ):\n                filter_stmt = crud_service.model_query(filter_args=extra_query.__dict__,\n                                                       session=session)\n\n                data_instance = [i for i in session.execute(filter_stmt).scalars()]\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NO_CONTENT)\n                try:\n                    return result_parser.update(response_model=response_model,\n                                                sql_execute_result=data_instance,\n                                                fastapi_response=response,\n                                                update_args=patch_data.__dict__,\n                                                session=session,\n                                                update_one=False)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n    @classmethod\n    def put_one(cls, api, *,\n                path,\n                request_url_param_model,\n                request_body_model,\n                response_model,\n                dependencies,\n                request_query_model,\n                db_session,\n                crud_service,\n                result_parser,\n                execute_service,\n                async_mode):\n        if async_mode:\n            @api.put(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            async def async_entire_update_by_primary_key(\n                    response: Response,\n                    primary_key: request_url_param_model = Depends(),\n                    update_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                filter_stmt = crud_service.model_query(filter_args=primary_key.__dict__,\n                                                       extra_args=extra_query.__dict__,\n                                                       session=session)\n\n                data_instance = await session.execute(filter_stmt)\n                data_instance = data_instance.scalar()\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NOT_FOUND)\n                try:\n                    return await result_parser.async_update(response_model=response_model,\n                                                            sql_execute_result=data_instance,\n                                                            fastapi_response=response,\n                                                            update_args=update_data.__dict__,\n                                                            session=session,\n                                                            update_one=True)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n        else:\n            @api.put(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            def entire_update_by_primary_key(\n                    response: Response,\n                    primary_key: request_url_param_model = Depends(),\n                    update_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                filter_stmt = crud_service.model_query(filter_args=primary_key.__dict__,\n                                                       extra_args=extra_query.__dict__,\n                                                       session=session)\n\n                data_instance = session.execute(filter_stmt).scalar()\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NOT_FOUND)\n                try:\n                    return result_parser.update(response_model=response_model,\n                                                sql_execute_result=data_instance,\n                                                fastapi_response=response,\n                                                update_args=update_data.__dict__,\n                                                session=session,\n                                                update_one=True)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n    @classmethod\n    def put_many(cls, api, *,\n                 path,\n                 response_model,\n                 dependencies,\n                 request_query_model,\n                 request_body_model,\n                 db_session,\n                 crud_service,\n                 result_parser,\n                 execute_service,\n                 async_mode):\n        if async_mode:\n            @api.put(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            async def async_entire_update_many_by_query(\n                    response: Response,\n                    update_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n                filter_stmt = crud_service.model_query(filter_args=extra_query.__dict__,\n                                                       session=session)\n                tmp = await session.execute(filter_stmt)\n                data_instance = [i for i in tmp.scalars()]\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NO_CONTENT)\n                try:\n                    return await result_parser.async_update(response_model=response_model,\n                                                            sql_execute_result=data_instance,\n                                                            fastapi_response=response,\n                                                            update_args=update_data.__dict__,\n                                                            session=session,\n                                                            update_one=False)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n        else:\n            @api.put(path, status_code=200, response_model=response_model, dependencies=dependencies)\n            def entire_update_many_by_query(\n                    response: Response,\n                    update_data: request_body_model = Depends(),\n                    extra_query: request_query_model = Depends(),\n                    session=Depends(db_session),\n            ):\n\n                filter_stmt = crud_service.model_query(filter_args=extra_query.__dict__,\n                                                       session=session)\n\n                data_instance = [i for i in session.execute(filter_stmt).scalars()]\n\n                if not data_instance:\n                    return Response(status_code=HTTPStatus.NO_CONTENT)\n                try:\n                    return result_parser.update(response_model=response_model,\n                                                sql_execute_result=data_instance,\n                                                fastapi_response=response,\n                                                update_args=update_data.__dict__,\n                                                session=session,\n                                                update_one=False)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n\n                # return result_parser.update_many(response_model=response_model,\n                #                                  sql_execute_result=query_result,\n                #                                  fastapi_response=response,\n                #                                  session=session)\n\n    @classmethod\n    def find_one_foreign_tree(cls, api, *,\n                              query_service,\n                              parsing_service,\n                              execute_service,\n                              async_mode,\n                              path,\n                              response_model,\n                              dependencies,\n                              request_query_model,\n                              request_url_param_model,\n                              function_name,\n                              db_session):\n\n        if async_mode:\n            @api.get(path, dependencies=dependencies, response_model=response_model, name=function_name)\n            async def async_get_one_with_foreign_tree(response: Response,\n                                                      request: Request,\n                                                      url_param=Depends(request_url_param_model),\n                                                      query=Depends(request_query_model),\n                                                      session=Depends(\n                                                          db_session)\n                                                      ):\n                target_model = request.url.path.split(\"/\")[-2]\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_one_with_foreign_pk(query=query.__dict__,\n                                                             join_mode=join,\n                                                             abstract_param=url_param.__dict__,\n                                                             target_model=target_model)\n\n                query_result = await execute_service.async_execute(session, stmt)\n\n                parsed_response = await parsing_service.async_find_one(response_model=response_model,\n                                                                       sql_execute_result=query_result,\n                                                                       fastapi_response=response,\n                                                                       join_mode=join,\n                                                                       session=session)\n                return parsed_response\n        else:\n            @api.get(path, dependencies=dependencies, response_model=response_model, name=function_name)\n            def get_one_with_foreign_tree(response: Response,\n                                          request: Request,\n                                          url_param=Depends(request_url_param_model),\n                                          query=Depends(request_query_model),\n                                          session=Depends(\n                                              db_session)\n                                          ):\n                target_model = request.url.path.split(\"/\")[-2]\n                join = query.__dict__.pop('join_foreign_table', None)\n\n                stmt = query_service.get_one_with_foreign_pk(query=query.__dict__,\n                                                             join_mode=join,\n                                                             abstract_param=url_param.__dict__,\n                                                             target_model=target_model)\n                query_result = execute_service.execute(session, stmt)\n                parsed_response = parsing_service.find_one(response_model=response_model,\n                                                           sql_execute_result=query_result,\n                                                           fastapi_response=response,\n                                                           join_mode=join,\n                                                           session=session)\n                return parsed_response\n\n    @classmethod\n    def find_many_foreign_tree(cls, api, *,\n                               query_service,\n                               parsing_service,\n                               execute_service,\n                               async_mode,\n                               path,\n                               response_model,\n                               dependencies,\n                               request_query_model,\n                               request_url_param_model,\n                               function_name,\n                               db_session):\n\n        if async_mode:\n            @api.get(path, dependencies=dependencies, response_model=response_model, name=function_name)\n            async def async_get_many_with_foreign_tree(response: Response,\n                                                       request: Request,\n                                                       url_param=Depends(request_url_param_model),\n                                                       query=Depends(request_query_model),\n                                                       session=Depends(\n                                                           db_session)\n                                                       ):\n                target_model = request.url.path.split(\"/\")[-1]\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_many(query=query.__dict__, join_mode=join, abstract_param=url_param.__dict__,\n                                              target_model=target_model)\n\n                query_result = await execute_service.async_execute(session, stmt)\n\n                parsed_response = await parsing_service.async_find_many(response_model=response_model,\n                                                                        sql_execute_result=query_result,\n                                                                        fastapi_response=response,\n                                                                        join_mode=join,\n                                                                        session=session)\n                return parsed_response\n        else:\n            @api.get(path, dependencies=dependencies, response_model=response_model, name=function_name)\n            def get_many_with_foreign_tree(response: Response,\n                                           request: Request,\n                                           url_param=Depends(request_url_param_model),\n                                           query=Depends(request_query_model),\n                                           session=Depends(\n                                               db_session)\n                                           ):\n                target_model = request.url.path.split(\"/\")[-1]\n                join = query.__dict__.pop('join_foreign_table', None)\n                stmt = query_service.get_many(query=query.__dict__, join_mode=join, abstract_param=url_param.__dict__,\n                                              target_model=target_model)\n                query_result = execute_service.execute(session, stmt)\n                parsed_response = parsing_service.find_many(response_model=response_model,\n                                                            sql_execute_result=query_result,\n                                                            fastapi_response=response,\n                                                            join_mode=join,\n                                                            session=session)\n\n                return parsed_response\n\n\nclass SQLAlchemyPGSQLRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        if async_mode:\n\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_one_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list)\n\n                try:\n                    query_result = await execute_service.async_execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT, content=err_msg)\n                    return result\n                return await parsing_service.async_upsert_one(response_model=response_model,\n                                                              sql_execute_result=query_result,\n                                                              fastapi_response=response,\n                                                              session=session)\n        else:\n\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_one_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list)\n                try:\n                    query_result = execute_service.execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT, content=err_msg)\n                    return result\n                return parsing_service.upsert_one(response_model=response_model,\n                                                  sql_execute_result=query_result,\n                                                  fastapi_response=response,\n                                                  session=session)\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n\n        if async_mode:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_many_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list,\n                                            upsert_one=False)\n                try:\n                    query_result = await execute_service.async_execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT, content=err_msg)\n                    return result\n                return await parsing_service.async_upsert_many(response_model=response_model,\n                                                               sql_execute_result=query_result,\n                                                               fastapi_response=response,\n                                                               session=session)\n        else:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_many_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list,\n                                            upsert_one=False)\n                try:\n                    query_result = execute_service.execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT, content=err_msg)\n                    return result\n                return parsing_service.upsert_many(response_model=response_model,\n                                                   sql_execute_result=query_result,\n                                                   fastapi_response=response,\n                                                   session=session)\n\n\nclass SQLAlchemySQLLiteRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        if async_mode:\n\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_one_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list)\n\n                try:\n                    query_result = await execute_service.async_execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return await parsing_service.async_upsert_one(response_model=response_model,\n                                                              sql_execute_result=query_result,\n                                                              fastapi_response=response,\n                                                              session=session)\n        else:\n\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_one_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list)\n                try:\n                    query_result = execute_service.execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return parsing_service.upsert_one(response_model=response_model,\n                                                  sql_execute_result=query_result,\n                                                  fastapi_response=response,\n                                                  session=session)\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n\n        if async_mode:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            async def async_insert_many_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list,\n                                            upsert_one=False)\n                try:\n                    query_result = await execute_service.async_execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return await parsing_service.async_upsert_many(response_model=response_model,\n                                                               sql_execute_result=query_result,\n                                                               fastapi_response=response,\n                                                               session=session)\n        else:\n            @api.post(path, status_code=201, response_model=response_model, dependencies=dependencies)\n            def insert_many_and_support_upsert(\n                    response: Response,\n                    request: Request,\n                    query: request_body_model = Depends(request_body_model),\n                    session=Depends(db_session)\n            ):\n\n                stmt = query_service.upsert(insert_arg=query.__dict__,\n                                            unique_fields=unique_list,\n                                            upsert_one=False)\n                try:\n                    query_result = execute_service.execute(session, stmt)\n                except IntegrityError as e:\n                    err_msg, = e.orig.args\n                    if 'unique constraint' not in err_msg.lower():\n                        raise e\n                    result = Response(status_code=HTTPStatus.CONFLICT)\n                    return result\n                return parsing_service.upsert_many(response_model=response_model,\n                                                   sql_execute_result=query_result,\n                                                   fastapi_response=response,\n                                                   session=session)\n\n\nclass SQLAlchemyMySQLRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n        raise NotImplementedError\n\n\nclass SQLAlchemyMariadbRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n        raise NotImplementedError\n\n\nclass SQLAlchemyOracleRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n        raise NotImplementedError\n\n\nclass SQLAlchemyMSSQLRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n        raise NotImplementedError\n\n\nclass SQLAlchemyNotSupportRouteSource(SQLAlchemyGeneralSQLBaseRouteSource):\n    '''\n    This route will support the SQL SQLAlchemy dialects\n    '''\n\n    @classmethod\n    def upsert_one(cls, api, *,\n                   path,\n                   query_service,\n                   parsing_service,\n                   execute_service,\n                   async_mode,\n                   response_model,\n                   request_body_model,\n                   dependencies,\n                   db_session,\n                   unique_list):\n        raise NotImplementedError\n\n    @classmethod\n    def upsert_many(cls, api, *,\n                    query_service,\n                    parsing_service,\n                    async_mode,\n                    path,\n                    response_model,\n                    dependencies,\n                    request_body_model,\n                    db_session,\n                    unique_list,\n                    execute_service):\n        raise NotImplementedError\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/covert_model.py",
    "content": "from sqlalchemy.ext.declarative import declarative_base\n\nfrom sqlalchemy.sql.schema import Table\n\n\ndef convert_table_to_model(db_model):\n    NO_PRIMARY_KEY = False\n    if not isinstance(db_model, Table):\n        return db_model, NO_PRIMARY_KEY\n    db_name = str(db_model.fullname)\n    table_dict = {'__table__': db_model,\n                  '__tablename__': db_name}\n\n    if not db_model.primary_key:\n        table_dict['__mapper_args__'] = {\n            \"primary_key\": [i for i in db_model._columns]\n        }\n        NO_PRIMARY_KEY = True\n\n    for i in db_model.c:\n        col, = i.expression.base_columns\n        table_dict[str(i.key)] = col\n\n    return type(f'{db_name}DeclarativeBaseClass', (declarative_base(),), table_dict), NO_PRIMARY_KEY\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/crud_model.py",
    "content": "from typing import (Optional,\n                    Dict,\n                    List)\n\nfrom pydantic import BaseModel\nfrom pydantic.main import ModelMetaclass\n\nfrom .exceptions import (RequestMissing,\n                         InvalidRequestMethod)\nfrom .type import CrudMethods\n\n\nclass RequestResponseModel(BaseModel):\n    requestUrlParamModel: Optional[ModelMetaclass]\n    requestRelationshipUrlParamField: Optional[List[str]]\n    requestQueryModel: Optional[ModelMetaclass]\n    requestBodyModel: Optional[ModelMetaclass]\n    responseModel: Optional[ModelMetaclass]\n    jsonRequestFieldModel: Optional[ModelMetaclass]\n    jsonbRequestFieldModel: Optional[ModelMetaclass]\n    arrayRequestFieldModel: Optional[ModelMetaclass]\n    foreignListModel: Optional[List[dict]]\n\n\nclass CRUDModel(BaseModel):\n    GET: Optional[Dict[CrudMethods, RequestResponseModel]]\n    POST: Optional[Dict[CrudMethods, RequestResponseModel]]\n    PUT: Optional[Dict[CrudMethods, RequestResponseModel]]\n    PATCH: Optional[Dict[CrudMethods, RequestResponseModel]]\n    DELETE: Optional[Dict[CrudMethods, RequestResponseModel]]\n    FIND_MANY_WITH_FOREIGN_TREE: Optional[Dict[CrudMethods, RequestResponseModel]]\n    PRIMARY_KEY_NAME: Optional[str]\n    UNIQUE_LIST: Optional[List[str]]\n\n    def get_available_request_method(self):\n        return [i for i in self.dict(exclude_unset=True, ).keys() if i in [\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]]\n\n    def get_model_by_request_method(self, request_method):\n        available_methods = self.dict()\n        if request_method not in available_methods.keys():\n            raise InvalidRequestMethod(f'{request_method} is not an available request method')\n        if not available_methods[request_method]:\n            raise RequestMissing(\n                f'{request_method} is not available, '\n                f'make sure the CRUDModel contains this request method')\n        _ = available_methods[request_method]\n        return _\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/exceptions.py",
    "content": "from fastapi import HTTPException\n\n\nclass FindOneApiNotRegister(HTTPException):\n    pass\n\n\nclass CRUDBuilderException(BaseException):\n    pass\n\n\nclass RequestMissing(CRUDBuilderException):\n    pass\n\n\nclass PrimaryMissing(CRUDBuilderException):\n    pass\n\n\nclass UnknownOrderType(CRUDBuilderException):\n    pass\n\n\nclass UpdateColumnEmptyException(CRUDBuilderException):\n    pass\n\n\nclass UnknownColumn(CRUDBuilderException):\n    pass\n\n\nclass QueryOperatorNotFound(CRUDBuilderException):\n    pass\n\n\nclass UnknownError(CRUDBuilderException):\n    pass\n\n\nclass ConflictColumnsCannotHit(CRUDBuilderException):\n    pass\n\n\nclass MultipleSingleUniqueNotSupportedException(CRUDBuilderException):\n    pass\n\n\nclass SchemaException(CRUDBuilderException):\n    pass\n\n\nclass CompositePrimaryKeyConstraintNotSupportedException(CRUDBuilderException):\n    pass\n\n\nclass MultiplePrimaryKeyNotSupportedException(CRUDBuilderException):\n    pass\n\n\nclass ColumnTypeNotSupportedException(CRUDBuilderException):\n    pass\n\n\nclass InvalidRequestMethod(CRUDBuilderException):\n    pass\n\n\n#\n# class NotFoundError(MongoQueryError):\n#     def __init__(self, Collection: Type[ModelType], model: BaseModel):\n#         detail = \"does not exist\"\n#         super().__init__(Collection, model, detail)\n#\n#\n#\n# class DuplicatedError(MongoQueryError):\n#     def __init__(self, Collection: Type[ModelType], model: BaseModel):\n#         detail = \"was already existed\"\n#         super().__init__(Collection, model, detail)\n\nclass FDDRestHTTPException(HTTPException):\n    \"\"\"Baseclass for all HTTP exceptions in FDD Rest API.  This exception can be called as WSGI\n        application to render a default error page or you can catch the subclasses\n        of it independently and render nicer error messages.\n        \"\"\"\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/memory_sql.py",
    "content": "import asyncio\nimport string\nimport random\nfrom typing import Generator\n\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom sqlalchemy.pool import StaticPool\n\n\nclass MemorySql():\n    def __init__(self, async_mode: bool = False):\n        \"\"\"\n\n        @type async_mode: bool\n        used to build sync or async memory sql connection\n        \"\"\"\n        self.async_mode = async_mode\n        SQLALCHEMY_DATABASE_URL = f\"sqlite{'+aiosqlite' if async_mode else ''}://\"\n        if not async_mode:\n            self.engine = create_engine(SQLALCHEMY_DATABASE_URL,\n                                        future=True,\n                                        echo=True,\n                                        pool_pre_ping=True,\n                                        pool_recycle=7200,\n                                        connect_args={\"check_same_thread\": False},\n                                        poolclass=StaticPool)\n            self.sync_session = sessionmaker(bind=self.engine,\n                                             autocommit=False, )\n        else:\n            self.engine = create_async_engine(SQLALCHEMY_DATABASE_URL,\n                                              future=True,\n                                              echo=True,\n                                              pool_pre_ping=True,\n                                              pool_recycle=7200,\n                                              connect_args={\"check_same_thread\": False},\n                                              poolclass=StaticPool)\n            self.sync_session = sessionmaker(autocommit=False,\n                                             autoflush=False,\n                                             bind=self.engine,\n                                             class_=AsyncSession)\n\n    def create_memory_table(self, Mode: 'declarative_base()'):\n        if not self.async_mode:\n            Mode.__table__.create(self.engine, checkfirst=True)\n        else:\n            async def create_table(engine, model):\n                async with engine.begin() as conn:\n                    await conn.run_sync(model._sa_registry.metadata.create_all)\n\n            loop = asyncio.get_event_loop()\n            loop.run_until_complete(create_table(self.engine, Mode))\n\n    def get_memory_db_session(self) -> Generator:\n        try:\n            db = self.sync_session()\n            yield db\n        except Exception as e:\n            db.rollback()\n            raise e\n        finally:\n            db.close()\n\n    async def async_get_memory_db_session(self):\n        async with self.sync_session() as session:\n            yield session\n\nasync_memory_db = MemorySql(True)\nsync_memory_db = MemorySql()"
  },
  {
    "path": "src/fastapi_quickcrud/misc/schema_builder.py",
    "content": "import uuid\nimport warnings\nfrom copy import deepcopy\nfrom dataclasses import (make_dataclass,\n                         field)\nfrom enum import auto\nfrom typing import (Optional,\n                    Any)\nfrom typing import (Type,\n                    Dict,\n                    List,\n                    Tuple,\n                    TypeVar,\n                    NewType,\n                    Union)\n\nimport pydantic\nfrom fastapi import (Body,\n                     Query)\nfrom pydantic import (BaseModel,\n                      create_model,\n                      BaseConfig)\nfrom pydantic.dataclasses import dataclass as pydantic_dataclass\nfrom sqlalchemy import UniqueConstraint, Table, Column\nfrom sqlalchemy import inspect\nfrom sqlalchemy.orm import DeclarativeMeta\nfrom sqlalchemy.orm import declarative_base\nfrom strenum import StrEnum\n\nfrom .covert_model import convert_table_to_model\nfrom .exceptions import (SchemaException,\n                         ColumnTypeNotSupportedException)\nfrom .type import (MatchingPatternInStringBase,\n                   RangeFromComparisonOperators,\n                   Ordering,\n                   RangeToComparisonOperators,\n                   ExtraFieldTypePrefix,\n                   ExtraFieldType,\n                   ItemComparisonOperators, PGSQLMatchingPatternInString, SqlType, )\n\nFOREIGN_PATH_PARAM_KEYWORD = \"__pk__\"\nBaseModelT = TypeVar('BaseModelT', bound=BaseModel)\nDataClassT = TypeVar('DataClassT', bound=Any)\nDeclarativeClassT = NewType('DeclarativeClassT', declarative_base)\nTableNameT = NewType('TableNameT', str)\nResponseModelT = NewType('ResponseModelT', BaseModel)\nForeignKeyName = NewType('ForeignKeyName', str)\nTableInstance = NewType('TableInstance', Table)\n\n\nclass ExcludeUnsetBaseModel(BaseModel):\n    def dict(self, *args, **kwargs):\n        if kwargs and kwargs.get(\"exclude_none\") is not None:\n            kwargs[\"exclude_unset\"] = True\n            return BaseModel.dict(self, *args, **kwargs)\n\n\nclass OrmConfig(BaseConfig):\n    orm_mode = True\n\n\ndef _add_orm_model_config_into_pydantic_model(pydantic_model, **kwargs) -> BaseModelT:\n    validators = kwargs.get('validators', None)\n    config = kwargs.get('config', None)\n    field_definitions = {\n        name_: (field_.outer_type_, field_.field_info.default)\n        for name_, field_ in pydantic_model.__fields__.items()\n    }\n    return create_model(f'{pydantic_model.__name__}WithValidators',\n                        **field_definitions,\n                        __config__=config,\n                        __validators__=validators)\n\n\n# def _add_validators(model: Type[BaseModelT], validators, **kwargs) -> Type[BaseModelT]:\n#     \"\"\"\n#     Create a new BaseModel with the exact same fields as `model`\n#     but making them all optional and no default\n#     \"\"\"\n#\n#     config = kwargs.get('config', None)\n#\n#     field_definitions = {\n#         name_: (field_.outer_type_, field_.field_info.default)\n#         for name_, field_ in model.__fields__.items()\n#     }\n#     return create_model(f'{model.__name__}WithValidators',\n#                         **field_definitions,\n#                         __config__=config,\n#                         __validators__={**validators})\n\ndef _model_from_dataclass(kls: DataClassT) -> Type[BaseModel]:\n    \"\"\" Converts a stdlib dataclass to a pydantic BaseModel. \"\"\"\n\n    return pydantic_dataclass(kls).__pydantic_model__\n\n\ndef _to_require_but_default(model: Type[BaseModelT]) -> Type[BaseModelT]:\n    \"\"\"\n    Create a new BaseModel with the exact same fields as `model`\n    but making them all require but there are default value\n    \"\"\"\n    config = model.Config\n    field_definitions = {}\n    for name_, field_ in model.__fields__.items():\n        field_definitions[name_] = (field_.outer_type_, field_.field_info.default)\n    return create_model(f'{model.__name__}RequireButDefault', **field_definitions,\n                        __config__=config)  # type: ignore[arg-type]\n\n\ndef _filter_none(request_or_response_object):\n    received_request = deepcopy(request_or_response_object.__dict__)\n    if 'insert' in received_request:\n        insert_item_without_null = []\n        for received_insert in received_request['insert']:\n            received_insert_ = deepcopy(received_insert)\n            for received_insert_item, received_insert_value in received_insert_.__dict__.items():\n                if hasattr(received_insert_value, '__module__'):\n                    if received_insert_value.__module__ == 'fastapi.params' or received_insert_value is None:\n                        delattr(received_insert, received_insert_item)\n                elif received_insert_value is None:\n                    delattr(received_insert, received_insert_item)\n\n            insert_item_without_null.append(received_insert)\n        setattr(request_or_response_object, 'insert', insert_item_without_null)\n    else:\n        for name, value in received_request.items():\n            if hasattr(value, '__module__'):\n                if value.__module__ == 'fastapi.params' or value is None:\n                    delattr(request_or_response_object, name)\n            elif value is None:\n                delattr(request_or_response_object, name)\n\n\nclass ApiParameterSchemaBuilder:\n    unsupported_data_types = [\"BLOB\"]\n    partial_supported_data_types = [\"INTERVAL\", \"JSON\", \"JSONB\"]\n\n    def __init__(self, db_model: Type, sql_type, exclude_column=None, constraints=None, exclude_primary_key=False,\n                 foreign_include=False):\n        self.constraints = constraints\n        self.exclude_primary_key = exclude_primary_key\n        if exclude_column is None:\n            self._exclude_column = []\n        else:\n            self._exclude_column = exclude_column\n        self.alias_mapper: Dict[str, str] = {}  # Table not support alias\n        if self.exclude_primary_key:\n            self.__db_model: Table = db_model\n            self.__db_model_table: Table = db_model.__table__\n            self.__columns = db_model.__table__.c\n            self.db_name: str = db_model.__tablename__\n        else:\n            self.__db_model: DeclarativeClassT = db_model\n            self.__db_model_table: Table = db_model.__table__\n            self.db_name: str = db_model.__tablename__\n            self.__columns = db_model.__table__.c\n        model = self.__db_model\n        self.primary_key_str, self._primary_key_dataclass_model, self._primary_key_field_definition \\\n            = self._extract_primary()\n        self.unique_fields: List[str] = self._extract_unique()\n        self.uuid_type_columns = []\n        self.str_type_columns = []\n        self.number_type_columns = []\n        self.datetime_type_columns = []\n        self.timedelta_type_columns = []\n        self.bool_type_columns = []\n        self.json_type_columns = []\n        self.array_type_columns = []\n        self.foreign_table_response_model_sets: Dict[TableNameT, ResponseModelT] = {}\n        self.all_field: List[dict] = self._extract_all_field()\n        self.sql_type = sql_type\n\n        if not foreign_include:\n            foreign_include = []\n        self.foreign_include = foreign_include\n        self.foreign_mapper = self.__foreign_mapper_builder()\n        self.relation_level = self._extra_relation_level()\n        self.table_of_foreign, self.reference_mapper = self.extra_foreign_table()\n\n    def __foreign_mapper_builder(self):\n        foreign_mapper = {}\n        if self.exclude_primary_key:\n            return foreign_mapper\n        for db_model in self.foreign_include:\n            db_model, NO_PRIMARY_KEY = convert_table_to_model(db_model)\n            tmp = {}\n            table_name = self.__get_table_name(db_model)\n            tmp[\"model\"] = db_model\n            foreign_mapper[table_name] = db_model\n            tmp[\"db_model\"] = db_model\n            tmp[\"db_model_table\"] = db_model.__table__\n            tmp[\"db_name\"] = db_model.__tablename__\n            tmp[\"columns\"] = db_model.__table__.c\n            tmp[\"all_fields\"] = self._extract_all_field(tmp[\"columns\"])\n            tmp[\"primary_key\"] = self._extract_primary(tmp[\"db_model_table\"])\n            foreign_mapper[table_name] = tmp\n        return foreign_mapper\n\n    def __get_table_name_from_table(self, table):\n        return table.name\n\n    def __get_table_name_from_model(self, table):\n        return table.__tablename__\n\n    def __get_table_name(self, table):\n        if isinstance(table, Table):\n            return self.__get_table_name_from_table(table)\n        else:\n            return self.__get_table_name_from_model(table)\n\n    def extra_foreign_table(self, db_model=None) -> Dict[ForeignKeyName, dict]:\n        if db_model is None:\n            db_model = self.__db_model\n        if self.exclude_primary_key:\n            return self._extra_foreign_table_from_table()\n        else:\n            return self._extra_foreign_table_from_declarative_base(db_model)\n\n    def _extract_primary(self, db_model_table=None) -> Union[tuple, Tuple[Union[str, Any],\n                                                                          DataClassT,\n                                                                          Tuple[Union[str, Any],\n                                                                                Union[Type[uuid.UUID], Any],\n                                                                                Optional[Any]]]]:\n        if db_model_table == None:\n            db_model_table = self.__db_model_table\n        primary_list = db_model_table.primary_key.columns.values()\n        if not primary_list or self.exclude_primary_key:\n            return (None, None, None)\n        if len(primary_list) > 1:\n            raise SchemaException(\n                f'multiple primary key / or composite not supported; {self.db_name} ')\n        primary_key_column, = primary_list\n        column_type = str(primary_key_column.type)\n        try:\n            python_type = primary_key_column.type.python_type\n            if column_type in self.unsupported_data_types:\n                raise ColumnTypeNotSupportedException(\n                    f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n            if column_type in self.partial_supported_data_types:\n                warnings.warn(\n                    f'The type of column {primary_key_column.key} ({column_type}) '\n                    f'is not support data query (as a query parameters )')\n\n        except NotImplementedError:\n            if column_type == \"UUID\":\n                python_type = uuid.UUID\n            else:\n                raise ColumnTypeNotSupportedException(\n                    f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n        # handle if python type is UUID\n        if python_type.__name__ in ['str',\n                                    'int',\n                                    'float',\n                                    'Decimal',\n                                    'UUID',\n                                    'bool',\n                                    'date',\n                                    'time',\n                                    'datetime']:\n            column_type = python_type\n        else:\n            raise ColumnTypeNotSupportedException(\n                f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n\n        default = self._extra_default_value(primary_key_column)\n        description = self._get_field_description(primary_key_column)\n        if default is ...:\n            warnings.warn(\n                f'The column of {primary_key_column.key} has not default value '\n                f'and it is not nullable and in exclude_list'\n                f'it may throw error when you insert data ')\n        primary_column_name = str(primary_key_column.key)\n        primary_field_definitions = (primary_column_name, column_type, default)\n\n        primary_columns_model: DataClassT = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PrimaryKeyModel',\n                                                           [(primary_field_definitions[0],\n                                                             primary_field_definitions[1],\n                                                             Query(primary_field_definitions[2],\n                                                                   description=description))],\n                                                           namespace={\n                                                               '__post_init__': lambda\n                                                                   self_object: self._value_of_list_to_str(\n                                                                   self_object, self.uuid_type_columns)\n                                                           })\n\n        assert primary_column_name and primary_columns_model and primary_field_definitions\n        return primary_column_name, primary_columns_model, primary_field_definitions\n\n    def _extract_unique(self) -> List[str]:\n        # get the unique columns with alias name\n\n        # service change alias to original\n        #   handle:\n        #       composite unique constraint\n        #       single unique\n        #   exception:\n        #       use composite unique constraint if more than one column using unique\n        #       can not use composite unique constraint and single unique at same time\n        #\n        unique_constraint = None\n        if not self.constraints:\n            return []\n        for constraint in self.constraints:\n            if isinstance(constraint, UniqueConstraint):\n                if unique_constraint:\n                    raise SchemaException(\n                        \"Only support one unique constraint/ Use unique constraint and composite unique constraint \"\n                        \"at same time is not supported / Use  composite unique constraint if there are more than one unique constraint\")\n                unique_constraint = constraint\n        if unique_constraint:\n            unique_column_name_list = []\n            for constraint_column in unique_constraint.columns:\n                column_name = str(constraint_column.key)\n                unique_column_name = column_name\n                unique_column_name_list.append(unique_column_name)\n            return unique_column_name_list\n        else:\n            return []\n\n    @staticmethod\n    def _get_field_description(column: Column) -> str:\n        if not hasattr(column, 'comment'):\n            return \"\"\n        return column.comment\n\n    def _extract_all_field(self, columns=None) -> List[dict]:\n        fields: List[dict] = []\n        if not columns:\n            columns = self.__columns\n        elif isinstance(columns, DeclarativeMeta):\n            columns = columns.__table__.c\n        elif isinstance(columns, Table):\n            columns = columns.c\n        for column in columns:\n            column_name = str(column.key)\n            column_foreign = [i.target_fullname for i in column.foreign_keys]\n            default = self._extra_default_value(column)\n            if column_name in self._exclude_column:\n                continue\n            column_type = str(column.type)\n            description = self._get_field_description(column)\n            try:\n                python_type = column.type.python_type\n                if column_type in self.unsupported_data_types:\n                    raise ColumnTypeNotSupportedException(\n                        f'The type of column {column_name} ({column_type}) not supported yet')\n                if column_type in self.partial_supported_data_types:\n                    warnings.warn(\n                        f'The type of column {column_name} ({column_type}) '\n                        f'is not support data query (as a query parameters )')\n            except NotImplementedError:\n                if column_type == \"UUID\":\n                    python_type = uuid.UUID\n                else:\n                    raise ColumnTypeNotSupportedException(\n                        f'The type of column {column_name} ({column_type}) not supported yet')\n                    # string filter\n\n            if python_type.__name__ in ['str']:\n                self.str_type_columns.append(column_name)\n            # uuid filter\n            elif python_type.__name__ in ['UUID']:\n                self.uuid_type_columns.append(column_name)\n            # number filter\n            elif python_type.__name__ in ['int', 'float', 'Decimal']:\n                self.number_type_columns.append(column_name)\n            # date filter\n            elif python_type.__name__ in ['date', 'time', 'datetime']:\n                self.datetime_type_columns.append(column_name)\n            # timedelta filter\n            elif python_type.__name__ in ['timedelta']:\n                self.timedelta_type_columns.append(column_name)\n            # bool filter\n            elif python_type.__name__ in ['bool']:\n                self.bool_type_columns.append(column_name)\n            # json filter\n            elif python_type.__name__ in ['dict']:\n                self.json_type_columns.append(column_name)\n            # array filter\n            elif python_type.__name__ in ['list']:\n                self.array_type_columns.append(column_name)\n                base_column_detail, = column.base_columns\n                if hasattr(base_column_detail.type, 'item_type'):\n                    item_type = base_column_detail.type.item_type.python_type\n                    fields.append({'column_name': column_name,\n                                   'column_type': List[item_type],\n                                   'column_default': default,\n                                   'column_description': description})\n                    continue\n            else:\n                raise ColumnTypeNotSupportedException(\n                    f'The type of column {column_name} ({column_type}) not supported yet')\n\n            if column_type == \"JSONB\":\n                fields.append({'column_name': column_name,\n                               'column_type': Union[python_type, list],\n                               'column_default': default,\n                               'column_description': description,\n                               'column_foreign': column_foreign})\n            else:\n                fields.append({'column_name': column_name,\n                               'column_type': python_type,\n                               'column_default': default,\n                               'column_description': description,\n                               'column_foreign': column_foreign})\n\n        return fields\n\n    def _extra_foreign_table_from_table(self) -> Dict[str, Table]:\n        foreign_key_table = {}\n        reference_mapper = {}\n        for column in self.__columns:\n            if column.foreign_keys:\n                foreign_column, = column.foreign_keys\n                foreign_table = foreign_column.column.table\n                all_fields_ = self._extract_all_field(foreign_table.c)\n                foreign_table_name = str(foreign_table.__str__())\n                local = str(foreign_column.parent).split('.')\n                reference = foreign_column.target_fullname.split('.')\n\n                class BaseClass(object):\n                    def __init__(self):\n                        pass\n\n                TableClass = type(f'{foreign_table_name}', (BaseClass,), {})\n                # table_class = mapper(TableClass, foreign_table)\n\n                local_reference_pairs = [{'local': {\"local_table\": local[0],\n                                                    \"local_column\": local[1]},\n                                          \"reference\": {\"reference_table\": reference[0],\n                                                        \"reference_column\": reference[1]},\n                                          'reference_table': foreign_table,\n                                          'reference_table_columns': foreign_table.c,\n                                          'local_table': foreign_column.parent.table,\n                                          'local_table_columns': foreign_column.parent.table.c}]\n\n                reference_mapper[local[1]] = {\"foreign_table\": foreign_table_name,\n                                              \"foreign_table_name\": foreign_table_name}\n                # foreign_key_table[foreign_table_name] = foreign_table\n                # all_column = {}\n                column_label = {}\n                for i in foreign_table.c:\n                    column_name = str(i).split('.')[1]\n                    setattr(TableClass, column_name, i)\n                    column_label[column_name] = i\n\n                foreign_key_table[foreign_table_name] = {'local_reference_pairs_set': local_reference_pairs,\n                                                         'fields': all_fields_,\n                                                         'instance': foreign_table,\n                                                         'db_column': TableClass,\n                                                         'column_label': column_label}\n\n                response_fields = []\n                for i in all_fields_:\n                    response_fields.append((i['column_name'],\n                                            i['column_type'],\n                                            None))\n                response_model_dataclass = make_dataclass(\n                    f'foreign_{foreign_table_name + str(uuid.uuid4())}_FindManyResponseItemModel',\n                    response_fields,\n                )\n                response_item_model = _model_from_dataclass(response_model_dataclass)\n\n                response_item_model = _add_orm_model_config_into_pydantic_model(response_item_model,\n                                                                                config=OrmConfig)\n                # response_item_model = _add_validators(response_item_model,\n                #                                            config=OrmConfig)\n                response_model = create_model(\n                    f'foreign_{foreign_table_name + str(uuid.uuid4())}_UpsertManyResponseListModel',\n                    **{'__root__': (List[response_item_model], None)}\n                )\n\n                self.foreign_table_response_model_sets[foreign_table_name] = response_model\n                foreign_key_table[foreign_table_name] = {'local_reference_pairs_set': local_reference_pairs,\n                                                         'fields': all_fields_,\n                                                         'instance': foreign_table,\n                                                         'db_column': foreign_table}\n\n        return foreign_key_table, reference_mapper\n\n    def _extra_relation_level(self, model=None, processed_table=None) -> Dict[str, Table]:\n        if model is None:\n            model = self.__db_model\n        if not processed_table:\n            processed_table = []\n        mapper = inspect(model)\n        relation_level = []\n        for r in mapper.relationships:\n\n            target_table = r.target\n            target_model, _ = convert_table_to_model(target_table)\n            target_table_name = target_model.__tablename__\n            if target_table_name and target_table_name not in processed_table and target_table_name in self.foreign_mapper:\n                processed_table.append(str(mapper.local_table))\n                if self.foreign_mapper[target_table_name][\"db_name\"] not in relation_level:\n                    relation_level.append(self.foreign_mapper[target_table_name][\"db_name\"])\n                relation_level += self._extra_relation_level(self.foreign_mapper[target_table_name][\"db_model\"],\n                                                             processed_table=processed_table\n                                                             )\n        return relation_level\n\n    def _extra_foreign_table_from_declarative_base(self, model) -> Dict[str, Table]:\n        mapper = inspect(model)\n        foreign_key_table = {}\n        reference_mapper = {}\n        for r in mapper.relationships:\n            local, = r.local_columns\n            local = mapper.get_property_by_column(local).expression\n            local_table = str(local).split('.')[0]\n            local_column = str(local).split('.')[1]\n            local_table_instance = local.table\n\n            foreign_table = r.mapper.class_\n            foreign_table_name = foreign_table.__tablename__\n            foreign_secondary_table_name = ''\n            if r.secondary_synchronize_pairs:\n                # foreign_table_name = r.secondary.key\n                foreign_secondary_table_name = str(r.secondary.key)\n\n            local_reference_pairs = []\n            '''\n                        for i in r.synchronize_pairs:\n                if r.secondary_synchronize_pairs:\n                    local = str(i[0]).split('.')\n                    reference = str(i[1]).split('.')\n                    local_table_instance = i[0].table\n                    reference_table_instance = i[1].table\n                else:\n                    local = str(r.local).split('.')\n                    reference = str(i[0]).split('.')\n                    local_table_instance = r.local.table\n                    reference_table_instance = i[0].table\n                local_table = local[0]\n                local_column = local[1]\n                reference_table = reference[0]\n                reference_column = reference[1]\n                self.reference_mapper[local_column] = foreign_table_name\n                local_reference_pairs.append({'local': {\"local_table\": local_table,\n                                                        \"local_column\": local_column},\n                                              \"reference\": {\"reference_table\": reference_table,\n                                                            \"reference_column\": reference_column},\n                                              'local_table': local_table_instance,\n                                              'local_table_columns': local_table_instance.c,\n                                              'reference_table': reference_table_instance,\n                                              'reference_table_columns': reference_table_instance.c})\n\n            '''\n            for i in r.synchronize_pairs:\n                for column in i:\n                    table_name_ = str(column).split('.')[0]\n                    column_name_ = str(column).split('.')[1]\n                    if table_name_ not in [foreign_secondary_table_name, foreign_table_name]:\n                        continue\n\n                    reference_table = table_name_\n                    reference_column = column_name_\n                    reference_table_instance = column.table\n                    if r.secondary_synchronize_pairs:\n\n                        exclude = True\n                    else:\n\n                        reference_mapper[local_column] = {\"foreign_table\": foreign_table,\n                                                          \"foreign_table_name\": foreign_table_name}\n                        exclude = False\n                    local_reference_pairs.append({'local': {\"local_table\": local_table,\n                                                            \"local_column\": local_column},\n                                                  \"reference\": {\"reference_table\": reference_table,\n                                                                \"reference_column\": reference_column},\n                                                  'local_table': local_table_instance,\n                                                  'local_table_columns': local_table_instance.c,\n                                                  'reference_table': reference_table_instance,\n                                                  'reference_table_columns': reference_table_instance.c,\n                                                  'exclude': exclude})\n            for i in r.secondary_synchronize_pairs:\n                local_table_: str = None\n                local_column_: str = None\n                reference_table_: str = None\n                reference_column_: str = None\n                local_table_instance_: Table = None\n                reference_table_instance_: Table = None\n                for column in i:\n\n                    table_name_ = str(column).split('.')[0]\n                    column_name_ = str(column).split('.')[1]\n                    if table_name_ == foreign_secondary_table_name:\n                        local_table_ = str(column).split('.')[0]\n                        local_column_ = str(column).split('.')[1]\n                        local_table_instance_ = column.table\n                    if table_name_ == foreign_table_name:\n                        reference_table_ = str(column).split('.')[0]\n                        reference_column_ = str(column).split('.')[1]\n                        reference_table_instance_ = column.table\n\n                reference_mapper[local_column_] = {\"foreign_table\": foreign_table,\n                                                        \"foreign_table_name\": foreign_table_name}\n                local_reference_pairs.append({'local': {\"local_table\": local_table_,\n                                                        \"local_column\": local_column_},\n                                              \"reference\": {\"reference_table\": reference_table_,\n                                                            \"reference_column\": reference_column_},\n                                              'local_table': local_table_instance_,\n                                              'local_table_columns': local_table_instance_.c,\n                                              'reference_table': reference_table_instance_,\n                                              'reference_table_columns': reference_table_instance_.c,\n                                              'exclude': False})\n\n            all_fields_ = self._extract_all_field(foreign_table.__table__.c)\n            response_fields = []\n            for i in all_fields_:\n                response_fields.append((i['column_name'],\n                                        i['column_type'],\n                                        None))\n            response_model_dataclass = make_dataclass(\n                f'foreign_{foreign_table_name + str(uuid.uuid4())}_FindManyResponseItemModel',\n                response_fields,\n            )\n            response_item_model = _model_from_dataclass(response_model_dataclass)\n\n            response_item_model = _add_orm_model_config_into_pydantic_model(response_item_model,\n                                                                            config=OrmConfig)\n\n            response_model = create_model(\n                f'foreign_{foreign_table_name + str(uuid.uuid4())}_GetManyResponseForeignModel',\n                **{'__root__': (Union[List[response_item_model], None], None)}\n            )\n            self.foreign_table_response_model_sets[foreign_table] = response_model\n            foreign_key_table[foreign_table_name] = {'local_reference_pairs_set': local_reference_pairs,\n                                                     'fields': all_fields_,\n                                                     'instance': foreign_table,\n                                                     'db_column': foreign_table}\n        return foreign_key_table, reference_mapper\n\n    @staticmethod\n    def _value_of_list_to_str(request_or_response_object, columns):\n        received_request = deepcopy(request_or_response_object.__dict__)\n        if isinstance(columns, str):\n            columns = [columns]\n        if 'insert' in request_or_response_object.__dict__:\n            insert_str_list = []\n            for insert_item in request_or_response_object.__dict__['insert']:\n                for column in columns:\n                    for insert_item_column, _ in insert_item.__dict__.items():\n                        if column in insert_item_column:\n                            value_ = insert_item.__dict__[insert_item_column]\n                            if value_ is not None:\n                                if isinstance(value_, list):\n                                    str_value_ = [str(i) for i in value_]\n                                else:\n                                    str_value_ = str(value_)\n                                setattr(insert_item, insert_item_column, str_value_)\n                insert_str_list.append(insert_item)\n            setattr(request_or_response_object, 'insert', insert_str_list)\n        else:\n            for column in columns:\n                for received_column_name, _ in received_request.items():\n                    if column in received_column_name:\n                        value_ = received_request[received_column_name]\n                        if value_ is not None:\n                            if isinstance(value_, list):\n                                str_value_ = [str(i) for i in value_]\n                            else:\n                                str_value_ = str(value_)\n                            setattr(request_or_response_object, received_column_name, str_value_)\n\n    @staticmethod\n    def _assign_join_table_instance(request_or_response_object, join_table_mapping):\n        received_request = deepcopy(request_or_response_object.__dict__)\n        join_table_replace = {}\n        if 'join_foreign_table' in received_request:\n            for join_table in received_request['join_foreign_table']:\n                if join_table in join_table_mapping:\n                    join_table_replace[str(join_table)] = join_table_mapping[join_table]\n            setattr(request_or_response_object, 'join_foreign_table', join_table_replace)\n\n    @staticmethod\n    def _get_many_string_matching_patterns_description_builder():\n        return '''<br >Composite string field matching pattern<h5/> \n                   <br /> Allow to select more than one pattern for string query\n                   <br /> <a> https://www.postgresql.org/docs/9.3/functions-matching.html <a/>'''\n\n    @staticmethod\n    def _get_many_order_by_columns_description_builder(all_columns, regex_validation, primary_name):\n        return f'''<br> support column: \n            <br> {all_columns} <hr><br> support ordering:  \n            <br> {list(map(str, Ordering))} \n            <hr> \n            <br />example: \n            <br />&emsp;&emsp;{primary_name}:ASC\n            <br />&emsp;&emsp;{primary_name}: DESC \n            <br />&emsp;&emsp;{primary_name}    :    DESC\n            <br />&emsp;&emsp;{primary_name} (default sort by ASC)'''\n\n    @staticmethod\n    def _extra_default_value(column):\n        if not column.nullable:\n            if column.default is not None:\n                default = column.default.arg\n            elif column.server_default is not None:\n                default = None\n            elif column.primary_key and column.autoincrement == True:\n                default = None\n            else:\n                default = ...\n        else:\n            if column.default is not None:\n                default = column.default.arg\n            else:\n                default = None\n        return default\n\n    def _assign_str_matching_pattern(self, field_of_param: dict, result_: List[dict]) -> List[dict]:\n        if self.sql_type == SqlType.postgresql:\n            operator = List[PGSQLMatchingPatternInString]\n        else:\n            operator = List[MatchingPatternInStringBase]\n\n        for i in [\n            {'column_name': field_of_param['column_name'] + ExtraFieldTypePrefix.Str + ExtraFieldType.Matching_pattern,\n             'column_type': Optional[operator],\n             'column_default': [MatchingPatternInStringBase.case_sensitive],\n             'column_description': \"\"},\n            {'column_name': field_of_param['column_name'] + ExtraFieldTypePrefix.Str,\n             'column_type': Optional[List[field_of_param['column_type']]],\n             'column_default': None,\n             'column_description': field_of_param['column_description']}\n        ]:\n            result_.append(i)\n        return result_\n\n    @staticmethod\n    def _assign_list_comparison(field_of_param, result_: List[dict]) -> List[dict]:\n        for i in [\n            {\n                'column_name': field_of_param[\n                                   'column_name'] + f'{ExtraFieldTypePrefix.List}{ExtraFieldType.Comparison_operator}',\n                'column_type': Optional[ItemComparisonOperators],\n                'column_default': ItemComparisonOperators.In,\n                'column_description': \"\"},\n            {'column_name': field_of_param['column_name'] + ExtraFieldTypePrefix.List,\n             'column_type': Optional[List[field_of_param['column_type']]],\n             'column_default': None,\n             'column_description': field_of_param['column_description']}\n\n        ]:\n            result_.append(i)\n        return result_\n\n    @staticmethod\n    def _assign_range_comparison(field_of_param, result_: List[dict]) -> List[dict]:\n        for i in [\n            {'column_name': field_of_param[\n                                'column_name'] + f'{ExtraFieldTypePrefix.From}{ExtraFieldType.Comparison_operator}',\n             'column_type': Optional[RangeFromComparisonOperators],\n             'column_default': RangeFromComparisonOperators.Greater_than_or_equal_to,\n             'column_description': \"\"},\n\n            {'column_name': field_of_param[\n                                'column_name'] + f'{ExtraFieldTypePrefix.To}{ExtraFieldType.Comparison_operator}',\n             'column_type': Optional[RangeToComparisonOperators],\n             'column_default': RangeToComparisonOperators.Less_than.Less_than_or_equal_to,\n             'column_description': \"\"},\n        ]:\n            result_.append(i)\n\n        for i in [\n            {'column_name': field_of_param['column_name'] + ExtraFieldTypePrefix.From,\n             'column_type': Optional[NewType(ExtraFieldTypePrefix.From, field_of_param['column_type'])],\n             'column_default': None,\n             'column_description': field_of_param['column_description']},\n\n            {'column_name': field_of_param['column_name'] + ExtraFieldTypePrefix.To,\n             'column_type': Optional[NewType(ExtraFieldTypePrefix.To, field_of_param['column_type'])],\n             'column_default': None,\n             'column_description': field_of_param['column_description']}\n        ]:\n            result_.append(i)\n        return result_\n\n    def _assign_foreign_join(self, result_, table_of_foreign=None) -> List[Union[Tuple, Dict]]:\n        if table_of_foreign is None:\n            table_of_foreign = self.table_of_foreign\n        if not self.table_of_foreign:\n            return result_\n        table_name_enum = StrEnum('TableName' + str(uuid.uuid4()),\n                                  {table_name: auto() for table_name in table_of_foreign})\n\n        result_.append(('join_foreign_table', Optional[List[table_name_enum]], Query(None)))\n        return result_\n\n    def _get_fizzy_query_param(self, exclude_column: List[str] = None, fields=None) -> List[dict]:\n        if not fields:\n            fields = self.all_field\n        if not exclude_column:\n            exclude_column = []\n        fields_: List[dict] = deepcopy(fields)\n        result = []\n        for field_ in fields_:\n            if field_['column_name'] in exclude_column:\n                continue\n            if \"column_foreign\" in field_ and field_['column_foreign']:\n                jump = False\n                for foreign in field_['column_foreign']:\n                    if foreign in exclude_column:\n                        jump = True\n                if jump:\n                    continue\n            field_['column_default'] = None\n            if field_['column_name'] in self.str_type_columns:\n                result = self._assign_str_matching_pattern(field_, result)\n                result = self._assign_list_comparison(field_, result)\n\n            elif field_['column_name'] in self.uuid_type_columns or \\\n                    field_['column_name'] in self.bool_type_columns:\n                result = self._assign_list_comparison(field_, result)\n\n            elif field_['column_name'] in self.number_type_columns or \\\n                    field_['column_name'] in self.datetime_type_columns:\n                result = self._assign_range_comparison(field_, result)\n                result = self._assign_list_comparison(field_, result)\n\n        return result\n\n    def _assign_pagination_param(self, result_: List[tuple]) -> List[Union[Tuple, Dict]]:\n        all_column_ = [i['column_name'] for i in self.all_field]\n\n        regex_validation = \"(?=(\" + '|'.join(all_column_) + r\")?\\s?:?\\s*?(?=(\" + '|'.join(\n            list(map(str, Ordering))) + r\"))?)\"\n        columns_with_ordering = pydantic.constr(regex=regex_validation)\n        for i in [\n            ('limit', Optional[int], Query(None)),\n            ('offset', Optional[int], Query(None)),\n            ('order_by_columns', Optional[List[columns_with_ordering]], Query(\n                # [f\"{self._primary_key}:ASC\"],\n                None,\n                description=self._get_many_order_by_columns_description_builder(\n                    all_columns=all_column_,\n                    regex_validation=regex_validation,\n                    primary_name='any name of column')))\n        ]:\n            result_.append(i)\n        return result_\n\n    def upsert_one(self) -> Tuple:\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        request_fields = []\n        response_fields = []\n\n        # Create on_conflict Model\n        all_column_ = [i['column_name'] for i in self.all_field]\n        conflict_columns = ('update_columns',\n                            Optional[List[str]],\n                            Body(set(all_column_) - set(self.unique_fields),\n                                 description='update_columns should contain which columns you want to update '\n                                             'when the unique columns got conflict'))\n        conflict_model = make_dataclass(\n            f'{self.db_name + str(uuid.uuid4())}_Upsert_one_request_update_columns_when_conflict_request_body_model',\n            [conflict_columns])\n        on_conflict_handle = [('on_conflict', Optional[conflict_model],\n                               Body(None))]\n\n        # Create Request and Response Model\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            request_fields.append((i['column_name'],\n                                   i['column_type'],\n                                   Body(i['column_default'], description=i['column_description'])))\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'], description=i['column_description'])))\n\n        # Ready the uuid to str validator\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        #\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_Upsert_one_request_model',\n                                            request_fields + on_conflict_handle,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [i(self_object)\n                                                                                      for i in request_validation]\n                                            })\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_Upsert_one_response_model',\n                                                  response_fields)\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_model = _to_require_but_default(response_model_pydantic)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n        return None, request_body_model, response_model\n\n    def upsert_many(self) -> Tuple:\n        insert_fields = []\n        response_fields = []\n\n        # Create on_conflict Model\n        all_column_ = [i['column_name'] for i in self.all_field]\n        conflict_columns = ('update_columns',\n                            Optional[List[str]],\n                            Body(set(all_column_) - set(self.unique_fields),\n                                 description='update_columns should contain which columns you want to update '\n                                             'when the unique columns got conflict'))\n        conflict_model = make_dataclass(\n            f'{self.db_name + str(uuid.uuid4())}_Upsert_many_request_update_columns_when_conflict_request_body_model',\n            [conflict_columns])\n        on_conflict_handle = [('on_conflict', Optional[conflict_model],\n                               Body(None))]\n\n        # Ready the Request and Response Model\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            insert_fields.append((i['column_name'],\n                                  i['column_type'],\n                                  field(default=Body(i['column_default'], description=i['column_description']))))\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n\n        insert_item_field_model_pydantic = make_dataclass(\n            f'{self.db_name + str(uuid.uuid4())}_UpsertManyInsertItemRequestModel',\n            insert_fields\n        )\n\n        # Create List Model with contains item\n        insert_list_field = [('insert', List[insert_item_field_model_pydantic], Body(...))]\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpsertManyRequestBody',\n                                            insert_list_field + on_conflict_handle\n                                            ,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]}\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpsertManyResponseItemModel',\n                                                  response_fields)\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_item_model = _to_require_but_default(response_model_pydantic)\n        response_item_model = _add_orm_model_config_into_pydantic_model(response_item_model, config=OrmConfig)\n\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_UpsertManyResponseListModel',\n            **{'__root__': (List[response_item_model], None)}\n        )\n\n        return None, request_body_model, response_model\n\n    def create_one(self) -> Tuple:\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        request_fields = []\n        response_fields = []\n\n\n        # Create Request and Response Model\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            request_fields.append((i['column_name'],\n                                   i['column_type'],\n                                   Body(i['column_default'], description=i['column_description'])))\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'], description=i['column_description'])))\n\n        # Ready the uuid to str validator\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        #\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_Create_one_request_model',\n                                            request_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [i(self_object)\n                                                                                      for i in request_validation]\n                                            })\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_Create_one_response_model',\n                                                  response_fields)\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_model = _to_require_but_default(response_model_pydantic)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n        return None, request_body_model, response_model\n\n    def create_many(self) -> Tuple:\n        insert_fields = []\n        response_fields = []\n\n        # Ready the Request and Response Model\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            insert_fields.append((i['column_name'],\n                                  i['column_type'],\n                                  field(default=Body(i['column_default'], description=i['column_description']))))\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n\n        insert_item_field_model_pydantic = make_dataclass(\n            f'{self.db_name + str(uuid.uuid4())}_CreateManyInsertItemRequestModel',\n            insert_fields\n        )\n\n        # Create List Model with contains item\n        insert_list_field = [('insert', List[insert_item_field_model_pydantic], Body(...))]\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_CreateManyRequestBody',\n                                            insert_list_field\n                                            ,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]}\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpsertManyResponseItemModel',\n                                                  response_fields)\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_item_model = _to_require_but_default(response_model_pydantic)\n        response_item_model = _add_orm_model_config_into_pydantic_model(response_item_model, config=OrmConfig)\n\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_UpsertManyResponseListModel',\n            **{'__root__': (List[response_item_model], None)}\n        )\n\n        return None, request_body_model, response_model\n\n    def find_many(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param()\n        query_param: List[Tuple] = self._assign_pagination_param(query_param)\n        query_param: List[Union[Tuple, Dict]] = self._assign_foreign_join(query_param)\n\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        for local_column, refer_table_info in self.reference_mapper.items():\n            response_fields.append((f\"{refer_table_info['foreign_table_name']}_foreign\",\n                                    self.foreign_table_response_model_sets[refer_table_info['foreign_table']],\n                                    None))\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    None))\n            # i['column_type']))\n        request_fields = []\n        for i in query_param:\n            assert isinstance(i, Tuple) or isinstance(i, dict)\n            if isinstance(i, Tuple):\n                request_fields.append(i)\n            if isinstance(i, dict):\n                request_fields.append((i['column_name'],\n                                       i['column_type'],\n                                       Query(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.table_of_foreign:\n            request_validation.append(lambda self_object: self._assign_join_table_instance(self_object,\n                                                                                           self.table_of_foreign))\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_FindManyRequestBody',\n                                             request_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]}\n                                             )\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_FindManyResponseItemModel',\n                                                  response_fields,\n                                                  )\n        response_list_item_model = _model_from_dataclass(response_model_dataclass)\n        response_list_item_model = _add_orm_model_config_into_pydantic_model(response_list_item_model,\n                                                                             config=OrmConfig)\n\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_FindManyResponseListModel',\n            **{'__root__': (Union[List[response_list_item_model], Any], None), '__base__': ExcludeUnsetBaseModel}\n        )\n\n        return request_query_model, None, response_model\n\n    def _extra_relation_primary_key(self, relation_dbs):\n        primary_key_columns = []\n        foreign_table_name = \"\"\n        primary_column_names = []\n        for db_model_table in relation_dbs:\n            table_name = db_model_table.key\n            foreign_table_name += table_name + \"_\"\n            primary_list = db_model_table.primary_key.columns.values()\n            primary_key_column, = primary_list\n            column_type = str(primary_key_column.type)\n            try:\n                python_type = primary_key_column.type.python_type\n                if column_type in self.unsupported_data_types:\n                    raise ColumnTypeNotSupportedException(\n                        f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n                if column_type in self.partial_supported_data_types:\n                    warnings.warn(\n                        f'The type of column {primary_key_column.key} ({column_type}) '\n                        f'is not support data query (as a query parameters )')\n\n            except NotImplementedError:\n                if column_type == \"UUID\":\n                    python_type = uuid.UUID\n                else:\n                    raise ColumnTypeNotSupportedException(\n                        f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n            # handle if python type is UUID\n            if python_type.__name__ in ['str',\n                                        'int',\n                                        'float',\n                                        'Decimal',\n                                        'UUID',\n                                        'bool',\n                                        'date',\n                                        'time',\n                                        'datetime']:\n                column_type = python_type\n            else:\n                raise ColumnTypeNotSupportedException(\n                    f'The type of column {primary_key_column.key} ({column_type}) not supported yet')\n            default = self._extra_default_value(primary_key_column)\n            if default is ...:\n                warnings.warn(\n                    f'The column of {primary_key_column.key} has not default value '\n                    f'and it is not nullable and in exclude_list'\n                    f'it may throw error when you insert data ')\n            description = self._get_field_description(primary_key_column)\n            primary_column_name = str(primary_key_column.key)\n            alias_primary_column_name = table_name + FOREIGN_PATH_PARAM_KEYWORD + str(primary_key_column.key)\n            primary_column_names.append(alias_primary_column_name)\n            primary_key_columns.append((alias_primary_column_name, column_type, Query(default,\n                                                                                      description=description)))\n\n        # TODO test foreign uuid key\n        primary_columns_model: DataClassT = make_dataclass(f'{foreign_table_name + str(uuid.uuid4())}_PrimaryKeyModel',\n                                                           primary_key_columns,\n                                                           namespace={\n                                                               '__post_init__': lambda\n                                                                   self_object: self._value_of_list_to_str(\n                                                                   self_object, self.uuid_type_columns)\n                                                           })\n        assert primary_column_names and primary_columns_model and primary_key_columns\n        return primary_column_names, primary_columns_model, primary_key_columns\n\n    def find_one(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param(self.primary_key_str)\n        query_param: List[Union[Tuple, Dict]] = self._assign_foreign_join(query_param)\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n\n        for local_column, refer_table_info in self.reference_mapper.items():\n            response_fields.append((f\"{refer_table_info['foreign_table_name']}_foreign\",\n                                    self.foreign_table_response_model_sets[refer_table_info['foreign_table']],\n                                    None))\n\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n\n        request_fields = []\n        for i in query_param:\n            assert isinstance(i, dict) or isinstance(i, tuple)\n            if isinstance(i, Tuple):\n                request_fields.append(i)\n            else:\n                request_fields.append((i['column_name'],\n                                       i['column_type'],\n                                       Query(i['column_default'], description=i['column_description'])))\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        if self.table_of_foreign:\n            request_validation.append(lambda self_object: self._assign_join_table_instance(self_object,\n                                                                                           self.table_of_foreign))\n\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_FindOneRequestBody',\n                                             request_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_FindOneResponseModel',\n                                                  response_fields,\n                                                  namespace={\n                                                      '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                            for validator_ in\n                                                                                            request_validation]}\n                                                  )\n        response_model = _model_from_dataclass(response_model_dataclass)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_FindOneResponseListModel',\n            **{'__root__': (response_model, None), '__base__': ExcludeUnsetBaseModel}\n        )\n\n        return self._primary_key_dataclass_model, request_query_model, None, response_model, None\n\n    def delete_one(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param(self.primary_key_str)\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n\n        request_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_fields.append((i['column_name'],\n                                   i['column_type'],\n                                   Query(i['column_default'], description=i['column_description'])))\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n            response_validation = [lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                  self.uuid_type_columns)]\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_DeleteOneRequestBody',\n                                             request_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n        response_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_DeleteOneResponseModel',\n                                        response_fields,\n                                        namespace={\n                                            '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                  for validator_ in\n                                                                                  response_validation]}\n                                        )\n        response_model = _model_from_dataclass(response_model)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n        return self._primary_key_dataclass_model, request_query_model, None, response_model\n\n    def delete_many(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param()\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n\n        request_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_fields.append((i['column_name'],\n                                   i['column_type'],\n                                   Query(i['column_default'], description=i['column_description'])))\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n            response_validation = [lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                  self.uuid_type_columns)]\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_DeleteManyRequestBody',\n                                             request_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n        # response_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_DeleteManyResponseModel',\n        #                                 response_fields,\n        #                                 namespace={\n        #                                     '__post_init__': lambda self_object: [validator_(self_object)\n        #                                                                           for validator_ in\n        #                                                                           response_validation]}\n        #                                 )\n        response_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_DeleteManyResponseModel',\n                                        response_fields,\n                                        namespace={\n                                            '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                  for validator_ in\n                                                                                  response_validation]}\n                                        )\n        response_model = _model_from_dataclass(response_model)\n\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_DeleteManyResponseListModel',\n            **{'__root__': (List[response_model], None)}\n        )\n\n        return None, request_query_model, None, response_model\n\n    def patch(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param(self.primary_key_str)\n\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        request_body_fields = []\n\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n            if i['column_name'] != self.primary_key_str:\n                request_body_fields.append((i['column_name'],\n                                            i['column_type'],\n                                            Body(None, description=i['column_description'])))\n\n        request_query_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_query_fields.append((i['column_name'],\n                                         i['column_type'],\n                                         Query(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchOneRequestQueryBody',\n                                             request_query_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchOneRequestBodyBody',\n                                            request_body_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]\n                                            }\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchOneResponseModel',\n                                                  response_fields,\n                                                  namespace={\n                                                      '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                            for validator_ in\n                                                                                            request_validation]}\n                                                  )\n        response_model = _model_from_dataclass(response_model_dataclass)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        return self._primary_key_dataclass_model, request_query_model, request_body_model, response_model\n\n    def update_one(self) -> Tuple:\n        query_param: List[dict] = self._get_fizzy_query_param(self.primary_key_str)\n\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        request_body_fields = []\n\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n            if i['column_name'] != self.primary_key_str:\n                request_body_fields.append((i['column_name'],\n                                            i['column_type'],\n                                            Body(..., description=i['column_description'])))\n\n        request_query_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_query_fields.append((i['column_name'],\n                                         i['column_type'],\n                                         Query(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateOneRequestQueryBody',\n                                             request_query_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateOneRequestBodyBody',\n                                            request_body_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]\n                                            }\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateOneResponseModel',\n                                                  response_fields,\n                                                  namespace={\n                                                      '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                            for validator_ in\n                                                                                            request_validation]}\n                                                  )\n        response_model = _model_from_dataclass(response_model_dataclass)\n\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n        return self._primary_key_dataclass_model, request_query_model, request_body_model, response_model\n\n    def update_many(self) -> Tuple:\n        \"\"\"\n        In update many, it allow you update some columns into the same value in limit of a scope,\n        you can get the limit of scope by using request query.\n        And fill out the columns (except the primary key column and unique columns) you want to update\n        and the update value in the request body\n\n        The response will show you the update result\n        :return: url param dataclass model\n        \"\"\"\n        query_param: List[dict] = self._get_fizzy_query_param()\n\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        request_body_fields = []\n\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n            if i['column_name'] not in [self.primary_key_str]:\n                request_body_fields.append((i['column_name'],\n                                            i['column_type'],\n                                            Body(..., description=i['column_description'])))\n\n        request_query_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_query_fields.append((i['column_name'],\n                                         i['column_type'],\n                                         Query(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateManyRequestQueryBody',\n                                             request_query_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateManyRequestBodyBody',\n                                            request_body_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]\n                                            }\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_UpdateManyResponseModel',\n                                                  response_fields,\n                                                  )\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_model_pydantic = _add_orm_model_config_into_pydantic_model(response_model_pydantic, config=OrmConfig)\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_UpdateManyResponseListModel',\n            **{'__root__': (List[response_model_pydantic], None)}\n        )\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        return None, request_query_model, request_body_model, response_model\n\n    def patch_many(self) -> Tuple:\n        \"\"\"\n        In update many, it allow you update some columns into the same value in limit of a scope,\n        you can get the limit of scope by using request query.\n        And fill out the columns (except the primary key column and unique columns) you want to update\n        and the update value in the request body\n\n        The response will show you the update result\n        :return: url param dataclass model\n        \"\"\"\n        query_param: List[dict] = self._get_fizzy_query_param()\n\n        response_fields = []\n        all_field = deepcopy(self.all_field)\n        request_body_fields = []\n\n        for i in all_field:\n            response_fields.append((i['column_name'],\n                                    i['column_type'],\n                                    Body(i['column_default'])))\n            if i['column_name'] not in [self.primary_key_str]:\n                request_body_fields.append((i['column_name'],\n                                            i['column_type'],\n                                            Body(None, description=i['column_description'])))\n\n        request_query_fields = []\n        for i in query_param:\n            assert isinstance(i, dict)\n            request_query_fields.append((i['column_name'],\n                                         i['column_type'],\n                                         Query(i['column_default'], description=i['column_description'])))\n\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        request_query_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchManyRequestQueryBody',\n                                             request_query_fields,\n                                             namespace={\n                                                 '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                       for validator_ in\n                                                                                       request_validation]\n                                             }\n                                             )\n\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchManyRequestBodyBody',\n                                            request_body_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                      for validator_ in\n                                                                                      request_validation]\n                                            }\n                                            )\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PatchManyResponseModel',\n                                                  response_fields,\n                                                  namespace={\n                                                      '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                            for validator_ in\n                                                                                            request_validation]}\n                                                  )\n        response_model_pydantic = _model_from_dataclass(response_model_dataclass)\n\n        response_model_pydantic = _add_orm_model_config_into_pydantic_model(response_model_pydantic, config=OrmConfig)\n        response_model = create_model(\n            f'{self.db_name + str(uuid.uuid4())}_PatchManyResponseListModel',\n            **{'__root__': (List[response_model_pydantic], None)}\n        )\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        return None, request_query_model, request_body_model, response_model\n\n    def post_redirect_get(self) -> Tuple:\n        request_validation = [lambda self_object: _filter_none(self_object)]\n        request_body_fields = []\n        response_body_fields = []\n\n        # Create Request and Response Model\n        all_field = deepcopy(self.all_field)\n        for i in all_field:\n            request_body_fields.append((i['column_name'],\n                                        i['column_type'],\n                                        Body(i['column_default'], description=i['column_description'])))\n            response_body_fields.append((i['column_name'],\n                                         i['column_type'],\n                                         Body(i['column_default'], description=i['column_description'])))\n\n        # Ready the uuid to str validator\n        if self.uuid_type_columns:\n            request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                     self.uuid_type_columns))\n        #\n        request_body_model = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PostAndRedirectRequestModel',\n                                            request_body_fields,\n                                            namespace={\n                                                '__post_init__': lambda self_object: [validator(self_object)\n                                                                                      for validator in\n                                                                                      request_validation]\n                                            })\n\n        response_model_dataclass = make_dataclass(f'{self.db_name + str(uuid.uuid4())}_PostAndRedirectResponseModel',\n                                                  response_body_fields)\n        response_model = _model_from_dataclass(response_model_dataclass)\n        response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n        return None, request_body_model, response_model\n\n    def foreign_tree_get_many(self) -> Tuple:\n        _tmp = []\n        path = \"\"\n        path += '/{' + self.db_name + FOREIGN_PATH_PARAM_KEYWORD + self.primary_key_str + '}'\n        path_model = [self.__db_model_table]\n        pk_list = [self.db_name + \".\" + self.primary_key_str]\n        total_table_of_foreign = {}\n        function_name = \"get_many_by_pk_from\"\n        for idx, relation in enumerate(self.relation_level):\n            table_detail = self.foreign_mapper[relation]\n            _all_fields = table_detail[\"all_fields\"]\n            _primary_key = table_detail[\"primary_key\"]\n            _db_name = table_detail[\"db_name\"]\n            _db_model = table_detail[\"db_model\"]\n            _db_model_table = table_detail[\"db_model_table\"]\n            _primary_key_dataclass_model = self._extra_relation_primary_key(path_model)\n            path_model.append(_db_model_table)\n            _query_param: List[dict] = self._get_fizzy_query_param(pk_list, _all_fields)\n            table_of_foreign, reference_mapper = self.extra_foreign_table(_db_model)\n            total_table_of_foreign.update(table_of_foreign)\n\n            _query_param: List[Union[Tuple, Dict]] = self._assign_foreign_join(_query_param, table_of_foreign)\n            response_fields = []\n            all_field = deepcopy(_all_fields)\n            path += '/' + _db_name + ''\n            function_name += \"_/_\" + _db_name\n            pk_list.append(_db_name + \".\" + _primary_key[0])\n\n            for i in all_field:\n                response_fields.append((i['column_name'],\n                                        i['column_type'],\n                                        Body(i['column_default'])))\n\n            request_fields = []\n            for i in _query_param:\n                assert isinstance(i, dict) or isinstance(i, tuple)\n                if isinstance(i, Tuple):\n                    request_fields.append(i)\n                else:\n                    request_fields.append((i['column_name'],\n                                           i['column_type'],\n                                           Query(i['column_default'], description=i['column_description'])))\n            request_validation = [lambda self_object: _filter_none(self_object)]\n\n            if table_of_foreign:\n                request_validation.append(lambda self_object: self._assign_join_table_instance(self_object,\n                                                                                               total_table_of_foreign))\n            if self.uuid_type_columns:\n                request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                         self.uuid_type_columns))\n            for local_column, refer_table_info in reference_mapper.items():\n                response_fields.append((f\"{refer_table_info['foreign_table_name']}_foreign\",\n                                        self.foreign_table_response_model_sets[refer_table_info['foreign_table']],\n                                        None))\n\n            request_query_model = make_dataclass(\n                f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindOneForeignTreeRequestBody',\n                request_fields,\n                namespace={\n                    '__post_init__': lambda self_object: [validator_(self_object)\n                                                          for validator_ in\n                                                          request_validation]}\n            )\n            response_model_dataclass = make_dataclass(f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindOneResponseModel',\n                                                      response_fields,\n                                                      namespace={\n                                                          '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                                for validator_ in\n                                                                                                request_validation]}\n                                                      )\n            response_model = _model_from_dataclass(response_model_dataclass)\n            response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n            response_model = create_model(\n                f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindManyResponseListModel',\n                **{'__root__': (Union[List[response_model], Any], None), '__base__': ExcludeUnsetBaseModel}\n            )\n\n            _response_model = {}\n\n            _response_model[\"primary_key_dataclass_model\"] = _primary_key_dataclass_model[1]\n            _response_model[\"request_query_model\"] = request_query_model\n            _response_model[\"response_model\"] = response_model\n            _response_model[\"path\"] = path\n            _response_model[\"function_name\"] = function_name\n            _tmp.append(_response_model)\n            path += '/{' + _db_name + FOREIGN_PATH_PARAM_KEYWORD + _primary_key[0] + '}'\n\n        return _tmp\n\n    def foreign_tree_get_one(self) -> Tuple:\n        _tmp = []\n        path = \"\"\n        path += '/{' + self.db_name + FOREIGN_PATH_PARAM_KEYWORD + self.primary_key_str + '}'\n        path_model = [self.__db_model_table]\n        pk_list = [self.db_name + \".\" + self.primary_key_str]\n        total_table_of_foreign = {}\n        function_name = \"get_one_by_pk_from\"\n\n        for relation in self.relation_level:\n            table_detail = self.foreign_mapper[relation]\n            _all_fields = table_detail[\"all_fields\"]\n            _primary_key = table_detail[\"primary_key\"]\n            _db_name = table_detail[\"db_name\"]\n            _db_model = table_detail[\"db_model\"]\n            _db_model_table = table_detail[\"db_model_table\"]\n            path_model.append(_db_model_table)\n            _primary_key_dataclass_model = self._extra_relation_primary_key(path_model)\n            _query_param: List[dict] = self._get_fizzy_query_param([_primary_key[0]] + pk_list, _all_fields)\n            table_of_foreign, reference_mapper = self.extra_foreign_table(_db_model)\n            total_table_of_foreign.update(table_of_foreign)\n            _query_param: List[Union[Tuple, Dict]] = self._assign_foreign_join(_query_param, table_of_foreign)\n            response_fields = []\n            all_field = deepcopy(_all_fields)\n\n            path += '/' + _db_name + ''\n            path += '/{' + _db_name + FOREIGN_PATH_PARAM_KEYWORD + _primary_key[0] + '}'\n            function_name += \"_/_\" + _db_name\n\n            pk_list.append(_db_name + \".\" + _primary_key[0])\n            for i in all_field:\n                response_fields.append((i['column_name'],\n                                        i['column_type'],\n                                        Body(i['column_default'])))\n\n            request_fields = []\n            for i in _query_param:\n                assert isinstance(i, dict) or isinstance(i, tuple)\n                if isinstance(i, Tuple):\n                    request_fields.append(i)\n                else:\n                    request_fields.append((i['column_name'],\n                                           i['column_type'],\n                                           Query(i['column_default'], description=i['column_description'])))\n            request_validation = [lambda self_object: _filter_none(self_object)]\n\n            if table_of_foreign:\n                request_validation.append(lambda self_object: self._assign_join_table_instance(self_object,\n                                                                                               total_table_of_foreign))\n            if self.uuid_type_columns:\n                request_validation.append(lambda self_object: self._value_of_list_to_str(self_object,\n                                                                                         self.uuid_type_columns))\n\n            for local_column, refer_table_info in reference_mapper.items():\n                response_fields.append((f\"{refer_table_info['foreign_table_name']}_foreign\",\n                                        self.foreign_table_response_model_sets[refer_table_info['foreign_table']],\n                                        None))\n\n            request_query_model = make_dataclass(f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindOneRequestBody',\n                                                 request_fields,\n                                                 namespace={\n                                                     '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                           for validator_ in\n                                                                                           request_validation]\n                                                 }\n                                                 )\n\n            response_model_dataclass = make_dataclass(f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindOneResponseModel',\n                                                      response_fields,\n                                                      namespace={\n                                                          '__post_init__': lambda self_object: [validator_(self_object)\n                                                                                                for validator_ in\n                                                                                                request_validation]}\n                                                      )\n            response_model = _model_from_dataclass(response_model_dataclass)\n            response_model = _add_orm_model_config_into_pydantic_model(response_model, config=OrmConfig)\n\n            response_model = create_model(\n                f'{\"_\".join(pk_list) + str(uuid.uuid4())}_FindOneResponseListModel',\n                **{'__root__': (response_model, None), '__base__': ExcludeUnsetBaseModel}\n            )\n            _response_model = {}\n            _response_model[\"primary_key_dataclass_model\"] = _primary_key_dataclass_model[1]\n            _response_model[\"request_query_model\"] = request_query_model\n            _response_model[\"response_model\"] = response_model\n            _response_model[\"path\"] = path\n            _response_model[\"function_name\"] = function_name\n            _tmp.append(_response_model)\n        return _tmp\n"
  },
  {
    "path": "src/fastapi_quickcrud/misc/type.py",
    "content": "from enum import Enum, auto\nfrom itertools import chain\n\nfrom strenum import StrEnum\n\nfrom .exceptions import InvalidRequestMethod\n\n\nclass SqlType(StrEnum):\n    postgresql = auto()\n    mysql = auto()\n    mariadb = auto()\n    sqlite = auto()\n    oracle = auto()\n    mssql = auto()\n\nclass Ordering(StrEnum):\n    DESC = auto()\n    ASC = auto()\n\n\nclass CrudMethods(Enum):\n    FIND_ONE = \"FIND_ONE\"\n    FIND_MANY = \"FIND_MANY\"\n    UPDATE_ONE = \"UPDATE_ONE\"\n    UPDATE_MANY = \"UPDATE_MANY\"\n    PATCH_ONE = \"PATCH_ONE\"\n    PATCH_MANY = \"PATCH_MANY\"\n    UPSERT_ONE = \"UPSERT_ONE\"\n    UPSERT_MANY = \"UPSERT_MANY\"\n    CREATE_ONE = \"CREATE_ONE\"\n    CREATE_MANY = \"CREATE_MANY\"\n    DELETE_ONE = \"DELETE_ONE\"\n    DELETE_MANY = \"DELETE_MANY\"\n    POST_REDIRECT_GET = \"POST_REDIRECT_GET\"\n    FIND_ONE_WITH_FOREIGN_TREE = \"FIND_ONE_WITH_FOREIGN_TREE\"\n    FIND_MANY_WITH_FOREIGN_TREE = \"FIND_MANY_WITH_FOREIGN_TREE\"\n\n    @staticmethod\n    def get_table_full_crud_method():\n        return [CrudMethods.FIND_MANY, CrudMethods.CREATE_MANY, CrudMethods.UPDATE_MANY, CrudMethods.PATCH_MANY,\n                CrudMethods.DELETE_MANY]\n\n    @staticmethod\n    def get_declarative_model_full_crud_method():\n        return [CrudMethods.FIND_MANY, CrudMethods.FIND_ONE,\n                CrudMethods.UPDATE_MANY, CrudMethods.UPDATE_ONE,\n                CrudMethods.PATCH_MANY, CrudMethods.PATCH_ONE, CrudMethods.CREATE_MANY,\n                 CrudMethods.DELETE_MANY, CrudMethods.DELETE_ONE, CrudMethods.FIND_ONE_WITH_FOREIGN_TREE,\n                 CrudMethods.FIND_MANY_WITH_FOREIGN_TREE]\n\n\nclass RequestMethods(Enum):\n    GET = \"GET\"\n    POST = \"POST\"\n    PUT = \"PUT\"\n    PATCH = \"PATCH\"\n    DELETE = \"DELETE\"\n\n\nclass CRUDRequestMapping(Enum):\n    FIND_ONE = RequestMethods.GET\n    FIND_ONE_WITH_FOREIGN_TREE = RequestMethods.GET\n\n    FIND_MANY = RequestMethods.GET\n    FIND_MANY_WITH_FOREIGN_TREE = RequestMethods.GET\n\n    UPDATE_ONE = RequestMethods.PUT\n    UPDATE_MANY = RequestMethods.PUT\n\n    PATCH_ONE = RequestMethods.PATCH\n    PATCH_MANY = RequestMethods.PATCH\n\n    CREATE_ONE = RequestMethods.POST\n    CREATE_MANY = RequestMethods.POST\n\n    UPSERT_ONE = RequestMethods.POST\n    UPSERT_MANY = RequestMethods.POST\n\n    DELETE_ONE = RequestMethods.DELETE\n    DELETE_MANY = RequestMethods.DELETE\n\n    GET_VIEW = RequestMethods.GET\n    POST_REDIRECT_GET = RequestMethods.POST\n\n    @classmethod\n    def get_request_method_by_crud_method(cls, value):\n        crud_methods = cls.__dict__\n        if value not in crud_methods:\n            raise InvalidRequestMethod(\n                f'{value} is not an available request method, Please use CrudMethods to select available crud method')\n        return crud_methods[value].value\n\n\nclass ExtraFieldType(StrEnum):\n    Comparison_operator = '_____comparison_operator'\n    Matching_pattern = '_____matching_pattern'\n\n\nclass ExtraFieldTypePrefix(StrEnum):\n    List = '____list'\n    From = '____from'\n    To = '____to'\n    Str = '____str'\n\n\nclass RangeFromComparisonOperators(StrEnum):\n    Greater_than = auto()\n    Greater_than_or_equal_to = auto()\n\n\nclass RangeToComparisonOperators(StrEnum):\n    Less_than = auto()\n    Less_than_or_equal_to = auto()\n\n\nclass ItemComparisonOperators(StrEnum):\n    Equal = auto()\n    Not_equal = auto()\n    In = auto()\n    Not_in = auto()\n\n\nclass MatchingPatternInStringBase(StrEnum):\n    case_insensitive = auto()\n    case_sensitive = auto()\n    not_case_insensitive = auto()\n    not_case_sensitive = auto()\n    contains = auto()\n\n\nclass PGSQLMatchingPattern(StrEnum):\n    match_regex_with_case_sensitive = auto()\n    match_regex_with_case_insensitive = auto()\n    does_not_match_regex_with_case_sensitive = auto()\n    does_not_match_regex_with_case_insensitive = auto()\n    similar_to = auto()\n    not_similar_to = auto()\n\n\nPGSQLMatchingPatternInString = StrEnum('PGSQLMatchingPatternInString',\n                                       {Pattern: auto() for Pattern in\n                                        chain(MatchingPatternInStringBase, PGSQLMatchingPattern)})\n\n\nclass JSONMatchingMode(str, Enum):\n    match_the_key_value = 'match_the_key_value'\n    match_the_value_if_not_null_by_key = 'match_the_value_if_not_null_by_key'\n    custom_query = 'custom_query'\n\n\nclass JSONBMatchingMode(str, Enum):\n    match_the_key_value = 'match_the_key_value'\n    match_the_value_if_not_null_by_key = 'match_the_value_if_not_null_by_key'\n    custom_query = 'custom_query'\n\n\nclass SessionObject(StrEnum):\n    sqlalchemy = auto()\n    databases = auto()\n\nFOREIGN_PATH_PARAM_KEYWORD = \"__pk__\""
  },
  {
    "path": "src/fastapi_quickcrud/misc/utils.py",
    "content": "from itertools import groupby\nfrom typing import Type, List, Union, TypeVar, Optional\n\nfrom pydantic import BaseModel, BaseConfig\nfrom sqlalchemy import Column, Integer\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.sql.elements import \\\n    or_, \\\n    BinaryExpression\n\nfrom sqlalchemy.sql.schema import Table\n\nfrom .covert_model import convert_table_to_model\nfrom .crud_model import RequestResponseModel, CRUDModel\nfrom .exceptions import QueryOperatorNotFound, PrimaryMissing, UnknownColumn\nfrom .schema_builder import ApiParameterSchemaBuilder\nfrom .type import \\\n    CrudMethods, \\\n    CRUDRequestMapping, \\\n    MatchingPatternInStringBase, \\\n    ExtraFieldType, \\\n    RangeFromComparisonOperators, \\\n    ExtraFieldTypePrefix, \\\n    RangeToComparisonOperators, \\\n    ItemComparisonOperators, PGSQLMatchingPatternInString, SqlType, FOREIGN_PATH_PARAM_KEYWORD\n\nBase = TypeVar(\"Base\", bound=declarative_base)\n\nBaseModelT = TypeVar('BaseModelT', bound=BaseModel)\n\n__all__ = [\n    'sqlalchemy_to_pydantic',\n    # 'sqlalchemy_table_to_pydantic',\n    'find_query_builder',\n    'Base',\n    'clean_input_fields',\n    'group_find_many_join',\n    'convert_table_to_model']\n\nunsupported_data_types = [\"BLOB\"]\npartial_supported_data_types = [\"INTERVAL\", \"JSON\", \"JSONB\"]\n\n\ndef clean_input_fields(param: Union[dict, list], model: Base):\n    assert isinstance(param, dict) or isinstance(param, list) or isinstance(param, set)\n\n    if isinstance(param, dict):\n        stmt = {}\n        for column_name, value in param.items():\n            if column_name == '__initialised__':\n                continue\n            column = getattr(model, column_name)\n            actual_column_name = column.expression.key\n            stmt[actual_column_name] = value\n        return stmt\n    if isinstance(param, list) or isinstance(param, set):\n        stmt = []\n        for column_name in param:\n            if not hasattr(model, column_name):\n                raise UnknownColumn(f'column {column_name} is not exited')\n            column = getattr(model, column_name)\n            actual_column_name = column.expression.key\n            stmt.append(actual_column_name)\n        return stmt\n\n\ndef find_query_builder(param: dict, model: Base) -> List[Union[BinaryExpression]]:\n    query = []\n    for column_name, value in param.items():\n        if ExtraFieldType.Comparison_operator in column_name or ExtraFieldType.Matching_pattern in column_name:\n            continue\n        if ExtraFieldTypePrefix.List in column_name:\n            type_ = ExtraFieldTypePrefix.List\n        elif ExtraFieldTypePrefix.From in column_name:\n            type_ = ExtraFieldTypePrefix.From\n        elif ExtraFieldTypePrefix.To in column_name:\n            type_ = ExtraFieldTypePrefix.To\n        elif ExtraFieldTypePrefix.Str in column_name:\n            type_ = ExtraFieldTypePrefix.Str\n        else:\n            query.append((getattr(model, column_name) == value))\n            # raise Exception('known error')\n            continue\n        sub_query = []\n        table_column_name = column_name.replace(type_, \"\")\n        operator_column_name = column_name + process_type_map[type_]\n        operators = param.get(operator_column_name, None)\n        if not operators:\n            raise QueryOperatorNotFound(f'The query operator of {column_name} not found!')\n        if not isinstance(operators, list):\n            operators = [operators]\n        for operator in operators:\n            sub_query.append(process_map[operator](getattr(model, table_column_name), value))\n        query.append((or_(*sub_query)))\n    return query\n\n\nclass OrmConfig(BaseConfig):\n    orm_mode = True\n\n\ndef sqlalchemy_to_pydantic(\n        db_model: Type, *,\n        crud_methods: List[CrudMethods],\n        sql_type: str = SqlType.postgresql,\n        exclude_columns: List[str] = None,\n        constraints=None,\n        foreign_include: Optional[any] = None,\n        exclude_primary_key=False) -> CRUDModel:\n    db_model, _ = convert_table_to_model(db_model)\n    if exclude_columns is None:\n        exclude_columns = []\n    if foreign_include is None:\n        foreign_include = {}\n    request_response_mode_set = {}\n    model_builder = ApiParameterSchemaBuilder(db_model,\n                                              constraints=constraints,\n                                              exclude_column=exclude_columns,\n                                              sql_type=sql_type,\n                                              foreign_include=foreign_include,\n                                              exclude_primary_key=exclude_primary_key)\n\n    REQUIRE_PRIMARY_KEY_CRUD_METHOD = [CrudMethods.DELETE_ONE.value,\n                                       CrudMethods.FIND_ONE.value,\n                                       CrudMethods.PATCH_ONE.value,\n                                       CrudMethods.POST_REDIRECT_GET.value,\n                                       CrudMethods.UPDATE_ONE.value]\n    for crud_method in crud_methods:\n        request_url_param_model = None\n        request_body_model = None\n        response_model = None\n        request_query_model = None\n        foreignListModel = None\n        if crud_method.value in REQUIRE_PRIMARY_KEY_CRUD_METHOD and not model_builder.primary_key_str:\n            raise PrimaryMissing(f\"The generation of this API [{crud_method.value}] requires a primary key\")\n\n        if crud_method.value == CrudMethods.UPSERT_ONE.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.upsert_one()\n        elif crud_method.value == CrudMethods.UPSERT_MANY.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.upsert_many()\n        elif crud_method.value == CrudMethods.CREATE_ONE.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.create_one()\n        elif crud_method.value == CrudMethods.CREATE_MANY.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.create_many()\n        elif crud_method.value == CrudMethods.DELETE_ONE.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.delete_one()\n        elif crud_method.value == CrudMethods.DELETE_MANY.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.delete_many()\n        elif crud_method.value == CrudMethods.FIND_ONE.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model, \\\n            relationship_list = model_builder.find_one()\n        elif crud_method.value == CrudMethods.FIND_MANY.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.find_many()\n        elif crud_method.value == CrudMethods.POST_REDIRECT_GET.value:\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.post_redirect_get()\n        elif crud_method.value == CrudMethods.PATCH_ONE.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.patch()\n        elif crud_method.value == CrudMethods.UPDATE_ONE.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.update_one()\n        elif crud_method.value == CrudMethods.UPDATE_MANY.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.update_many()\n        elif crud_method.value == CrudMethods.PATCH_MANY.value:\n            request_url_param_model, \\\n            request_query_model, \\\n            request_body_model, \\\n            response_model = model_builder.patch_many()\n        elif crud_method.value == CrudMethods.FIND_ONE_WITH_FOREIGN_TREE.value:\n            foreignListModel = model_builder.foreign_tree_get_one()\n        elif crud_method.value == CrudMethods.FIND_MANY_WITH_FOREIGN_TREE.value:\n            foreignListModel = model_builder.foreign_tree_get_many()\n\n        request_response_models = {'requestBodyModel': request_body_model,\n                                   'responseModel': response_model,\n                                   'requestQueryModel': request_query_model,\n                                   'requestUrlParamModel': request_url_param_model,\n                                   'foreignListModel': foreignListModel}\n        request_response_model = RequestResponseModel(**request_response_models)\n        request_method = CRUDRequestMapping.get_request_method_by_crud_method(crud_method.value).value\n        if request_method not in request_response_mode_set:\n            request_response_mode_set[request_method] = {}\n        request_response_mode_set[request_method][crud_method.value] = request_response_model\n    return CRUDModel(\n        **{**request_response_mode_set,\n           **{\"PRIMARY_KEY_NAME\": model_builder.primary_key_str,\n              \"UNIQUE_LIST\": model_builder.unique_fields}})\n\n\n# def get_many_string_matching_patterns_description_builder() -> str:\n#     return '''<br >Composite string field matching pattern<h5/>\n#            <br /> Allow to select more than one pattern for string query'''\n\n\n# def get_many_order_by_columns_description_builder(*, all_columns, regex_validation, primary_name) -> str:\n#     return f'''<br> support column:\n#     <br> {all_columns} <hr><br> support ordering:\n#     <br> {list(map(str, Ordering))}\n#     <hr>\n#     <br> field input validation regex\n#     <br> {regex_validation}\n#     <hr>\n#     <br />example:\n#     <br />&emsp;&emsp;{primary_name}:ASC\n#     <br />&emsp;&emsp;{primary_name}: DESC\n#     <br />&emsp;&emsp;{primary_name}    :    DESC\n#     <br />&emsp;&emsp;{primary_name} (default sort by ASC)'''\n\n\nprocess_type_map = {\n    ExtraFieldTypePrefix.List: ExtraFieldType.Comparison_operator,\n    ExtraFieldTypePrefix.From: ExtraFieldType.Comparison_operator,\n    ExtraFieldTypePrefix.To: ExtraFieldType.Comparison_operator,\n    ExtraFieldTypePrefix.Str: ExtraFieldType.Matching_pattern,\n}\n\nprocess_map = {\n    RangeFromComparisonOperators.Greater_than:\n        lambda field, value: field > value,\n\n    RangeFromComparisonOperators.Greater_than_or_equal_to:\n        lambda field, value: field >= value,\n\n    RangeToComparisonOperators.Less_than:\n        lambda field, value: field < value,\n\n    RangeToComparisonOperators.Less_than_or_equal_to:\n        lambda field, value: field <= value,\n\n    ItemComparisonOperators.Equal:\n        lambda field, values: or_(field == value for value in values),\n\n    ItemComparisonOperators.Not_equal:\n        lambda field, values: or_(field != value for value in values),\n\n    ItemComparisonOperators.In:\n        lambda field, values: or_(field.in_(values)),\n\n    ItemComparisonOperators.Not_in:\n        lambda field, values: or_(field.notin_(values)),\n\n    MatchingPatternInStringBase.case_insensitive:\n        lambda field, values: or_(field.ilike(value) for value in values),\n\n    MatchingPatternInStringBase.case_sensitive:\n        lambda field, values: or_(field.like(value) for value in values),\n\n    MatchingPatternInStringBase.not_case_insensitive:\n        lambda field, values: or_(field.not_ilike(value) for value in values),\n\n    MatchingPatternInStringBase.not_case_sensitive:\n        lambda field, values: or_(field.not_like(value) for value in values),\n\n    MatchingPatternInStringBase.contains:\n        lambda field, values: or_(field.contains(value) for value in values),\n\n    PGSQLMatchingPatternInString.similar_to:\n        lambda field, values: or_(field.op(\"SIMILAR TO\")(value) for value in values),\n\n    PGSQLMatchingPatternInString.not_similar_to:\n        lambda field, values: or_(field.op(\"NOT SIMILAR TO\")(value) for value in values),\n\n    PGSQLMatchingPatternInString.match_regex_with_case_sensitive:\n        lambda field, values: or_(field.op(\"~\")(value) for value in values),\n\n    PGSQLMatchingPatternInString.match_regex_with_case_insensitive:\n        lambda field, values: or_(field.op(\"~*\")(value) for value in values),\n\n    PGSQLMatchingPatternInString.does_not_match_regex_with_case_sensitive:\n        lambda field, values: or_(field.op(\"!~\")(value) for value in values),\n\n    PGSQLMatchingPatternInString.does_not_match_regex_with_case_insensitive:\n        lambda field, values: or_(field.op(\"!~*\")(value) for value in values)\n}\n\n\ndef table_to_declarative_base(db_model):\n    db_name = str(db_model.fullname)\n    Base = declarative_base()\n    if not db_model.primary_key:\n        db_model.append_column(Column('__id', Integer, primary_key=True, autoincrement=True))\n    table_dict = {'__tablename__': db_name}\n    for i in db_model.c:\n        _, = i.expression.base_columns\n        _.table = None\n        table_dict[str(i.key)] = _\n    tmp = type(f'{db_name}', (Base,), table_dict)\n    tmp.__table__ = db_model\n    return tmp\n\n\ndef group_find_many_join(list_of_dict: List[dict]) -> List[dict]:\n    def group_by_foreign_key(item):\n        tmp = {}\n        for k, v in item.items():\n            if '_foreign' not in k:\n                tmp[k] = v\n        return tmp\n\n    response_list = []\n    for key, group in groupby(list_of_dict, group_by_foreign_key):\n        response = {}\n        for i in group:\n            for k, v in i.items():\n                if '_foreign' in k:\n                    if k not in response:\n                        response[k] = [v]\n                    else:\n                        response[k].append(v)\n            for response_ in response:\n                i.pop(response_, None)\n            result = {**i, **response}\n        response_list.append(result)\n    return response_list\n\n\ndef path_query_builder(params, model) -> List[Union[BinaryExpression]]:\n    query = []\n    if not params:\n        return query\n    for param_name, param_value in params.items():\n        table_with_column = param_name.split(FOREIGN_PATH_PARAM_KEYWORD)\n        assert len(table_with_column) == 2\n        table_name, column_name = table_with_column\n        table_model = model[table_name]\n        query.append((getattr(table_model, column_name) == param_value))\n    return query\n"
  },
  {
    "path": "tests/__init__.py",
    "content": ""
  },
  {
    "path": "tests/conf/__init__.py",
    "content": ""
  },
  {
    "path": "tests/conf/config.py",
    "content": "import os\nimport pathlib\n\n\nENV_FILE_PATH = pathlib.Path(__file__).parent / \"dev.env\"\nassert ENV_FILE_PATH.exists()\n\n\nclass BaseConfig:\n    POSTGRES_HOST = \"\"\n    POSTGRES_USER = \"\"\n    POSTGRES_PASSWORD = \"\"\n    POSTGRES_DB = \"\"\n    POSTGRES_PORT = \"\"\n\n    def __init__(self):\n        self._apply_dot_env()\n        self._apply_env_vars()\n        self.POSTGRES_URI = f\"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}\"\n        print(self.POSTGRES_URI)\n\n    def _apply_dot_env(self):\n        with open(ENV_FILE_PATH) as fp:\n            for line in fp.readlines():\n                line = line.strip(\" \\n\")\n\n                if not line.startswith(\"#\"):\n                    k, v = line.split(\"=\", 1)\n\n                    if hasattr(self, k) and not getattr(self, k):\n                        setattr(self, k, v)\n\n    def _apply_env_vars(self):\n        for k, v in os.environ.items():\n            if hasattr(self, k):\n                setattr(self, k, v)"
  },
  {
    "path": "tests/conf/dev.docker-compose.yml",
    "content": "version: \"3.9\"\n\nservices:\n    db:\n      image: postgres\n      restart: always\n      env_file:\n        - dev.env\n      ports:\n        - 5432:5432"
  },
  {
    "path": "tests/conf/dev.env",
    "content": "POSTGRES_HOST=localhost\nPOSTGRES_DB=test\nPOSTGRES_USER=postgres\nPOSTGRES_PASSWORD=password\nPOSTGRES_PORT=5432"
  },
  {
    "path": "tests/test_implementations/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/other/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/__init__.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.orm import declarative_base\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_memory'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date)\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    # interval_value = Column(INTERVAL)\n    # json_value = Column(JSON)\n    # jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    # uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    # xml_value = Column(NullType)\n    # array_value = Column(ARRAY(Integer()))\n    # array_str__value = Column(ARRAY(String()))\n    # box_valaue = Column(NullType)\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/foreign_tree/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/foreign_tree/test_relationship_m2m.py",
    "content": "import asyncio\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table, CHAR\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.misc.type import SqlType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.pool import StaticPool\n\nengine = create_async_engine('sqlite+aiosqlite://',\n                             future=True,\n                             echo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200,\n                             connect_args={\"check_same_thread\": False},\n                             poolclass=StaticPool)\n\nsession = sessionmaker(autocommit=False,\n                       autoflush=False,\n                       bind=engine,\n                       class_=AsyncSession)\n\n\nasync def get_transaction_session():\n    async with session() as s:\n        yield s\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    child = Column(CHAR(10))\n    parent = relationship(\"Parent\",\n                          secondary=association_table)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    parent = Column(CHAR(10))\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    child_second = Column(CHAR(10))\n    children_second = relationship(\"Parent\",\n                                   secondary=association_table_second)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"],\n                                       sql_type=SqlType.sqlite,\n                                       foreign_include=[Parent],\n                                       async_mode=True\n\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n                                                          async_mode=True\n\n                                                          )\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n                                                          async_mode=True\n\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"],\n                                              sql_type=SqlType.sqlite,\n                                              async_mode=True\n\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n                                        foreign_include=[Child],\n                                        sql_type=SqlType.sqlite,\n                                        async_mode=True\n\n                                        )\ncrud_route_parent2 = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=Parent,\n                                         prefix=\"/parent\",\n                                         tags=[\"parent\"],\n                                         foreign_include=[ChildSecond],\n                                         sql_type=SqlType.sqlite,\n                                         async_mode=True\n\n                                         )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"],\n                                             sql_type=SqlType.sqlite,\n                                             async_mode=True\n\n                                             )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child, crud_route_parent2,\n  crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_1():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right/0?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&join_foreign_table=test_left\"\n    test_api_4 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=child1&child____list_____comparison_operator=In&child____list=child1\"\n    test_api_5 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Equal&child____list=child1\"\n    test_api_7 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In&child____list=child1\"\n    test_api_8 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In&child____list=child1&join_foreign_table=test_left\"\n    test_api_9 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Not_in&child____list=child1\"\n    test_api_10 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Not_equal&child____list=child1\"\n    test_api_11 = \"/parent/1/test_right/1?child____str_____matching_pattern=not_case_insensitive&child____str=child1&child____list_____comparison_operator=In\"\n\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_10, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_11, headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_one_2():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right_second/0?child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right_second/1\"\n    test_api_3 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&join_foreign_table=test_left\"\n    test_api_4 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In&child_second____list=child_second1\"\n    test_api_5 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Equal&child_second____list=child_second1\"\n    test_api_7 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In&child_second____list=child_second1\"\n    test_api_8 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In&child_second____list=child_second1&join_foreign_table=test_left\"\n    test_api_9 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Not_in&child_second____list=child_second1\"\n    test_api_10 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Not_equal&child_second____list=child_second1\"\n    test_api_11 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=not_case_insensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In\"\n\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_10, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_11, headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_many_1():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=1&id____to=2&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_4 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=8&id____to=9&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_5 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&id____list=0&id____list=1&id____list=2&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____str=child1&child____list_____comparison_operator=In\"\n    test_api_7 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____str=child%25&child____list_____comparison_operator=In\"\n    test_api_8 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&child____list=child2\"\n    test_api_9 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&join_foreign_table=test_left\"\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1},\n                               {'child': 'child2', 'id': 2},\n                               {'child': 'child3', 'id': 3},\n                               {'child': 'child4', 'id': 4}]\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}, {'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}, {'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}]\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1},\n                               {'child': 'child2', 'id': 2},\n                               {'child': 'child3', 'id': 3},\n                               {'child': 'child4', 'id': 4}]\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1',\n                                'id': 1,\n                                'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}]\n\n\ndef test_get_many_2():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=1&id____to=2&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_4 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=8&id____to=9&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_5 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&id____list=0&id____list=1&id____list=2&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In\"\n    test_api_7 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second%25&child_second____list_____comparison_operator=In\"\n    test_api_8 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&child_second____list=child_second2\"\n    test_api_9 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&join_foreign_table=test_left\"\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1},\n                               {'child_second': 'child_second2', 'id': 2},\n                               {'child_second': 'child_second3', 'id': 3},\n                               {'child_second': 'child_second4', 'id': 4}]\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}, {'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}, {'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}]\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1},\n                               {'child_second': 'child_second2', 'id': 2},\n                               {'child_second': 'child_second3', 'id': 3},\n                               {'child_second': 'child_second4', 'id': 4}]\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1',\n                                'id': 1,\n                                'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}]\n\n\ndef setup_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n            db = module.session()\n\n            db.add(Child(id=1, child=\"child1\"))\n            db.add(Child(id=2, child=\"child2\"))\n            db.add(Child(id=3, child=\"child3\"))\n            db.add(Child(id=4, child=\"child4\"))\n            await db.flush()\n\n            db.add(Parent(id=1, parent=\"parent1\"))\n            db.add(Parent(id=2, parent=\"parent2\"))\n            db.add(Parent(id=3, parent=\"parent3\"))\n            db.add(Parent(id=4, parent=\"parent4\"))\n            await db.flush()\n            await db.execute(association_table.insert().values(left_id=1, right_id=1))\n            await db.execute(association_table.insert().values(left_id=2, right_id=2))\n            await db.execute(association_table.insert().values(left_id=3, right_id=3))\n            await db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n            db.add(ChildSecond(id=1, child_second=\"child_second1\"))\n            db.add(ChildSecond(id=2, child_second=\"child_second2\"))\n            db.add(ChildSecond(id=3, child_second=\"child_second3\"))\n            db.add(ChildSecond(id=4, child_second=\"child_second4\"))\n            await db.flush()\n\n            await db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n            await db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n            await db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n            await db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n            await db.commit()\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_create_many_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import UntitledTable256, app\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(crud_methods=[CrudMethods.CREATE_MANY],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n                                       autocommit=True,\n                                       async_mode=True\n                                       )\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '[ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"varchar_value\": \"string\"}, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\",  \"varchar_value\": \"string\"}, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\",  \"varchar_value\": \"string\"} ]'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '[ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] '\n    data_ = json.loads(data)\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(sample_data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(insert_data))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_create_one_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_models=UntitledTable256Model,\n    prefix=\"/test_creation_one\",\n    tags=[\"test\"],\n    async_mode=True\n)\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_models=UntitledTable256Model,\n    prefix=\"/test_creation_many\",\n    tags=[\"test\"],\n    async_mode=True\n)\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_models=UntitledTable256Model,\n    prefix=\"/test_post_direct_get\",\n    tags=[\"test\"],\n    async_mode=True\n)\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_models=UntitledTable256Model,\n    prefix=\"/test\",\n    tags=[\"test\"],\n    async_mode=True\n)\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\n\ntest_create_many = crud_router_builder(\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_delete_data = crud_router_builder(\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                            \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                            \"varchar_value\": \"string\",\n                            \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                          \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                            \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_delete_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_one\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                       \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    response_data = response.json()\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownColumn, UnknownOrderType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud.misc.utils import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n                                       exclude_columns=['bytea_value'],\n    async_mode=True\n                                       )\n\ntest_find_many = crud_router_builder(db_model=UntitledTable256,\n                                     prefix=\"/test_get_many\",\n                                     tags=[\"test\"],\n                                       exclude_columns=['bytea_value'],\n    async_mode=True\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string')}\n    data = [insert_sample_item for i in range(num)]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    assert response.status_code == 204\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         _ = response.json()\n    #         assert i in _\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response_data\n        # for i in char_test_sample_data:\n        #     assert i not in response_data\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n        #\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to',\n    #               \"char_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to',\n    #               \"char_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"char_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"char_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=strinG\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to',\n    #               \"varchar_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to',\n    #               \"varchar_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"varchar_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"varchar_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to',\n    #               \"text_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to',\n    #               \"text_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"text_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"text_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two+0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two+0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        \n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key']  == init\n        init -= 1\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_get_one_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846Z\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n    #     headers=headers)\n    # assert response.status_code == 200\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 200\n# try find the data by primary key but false by uuid\n# def test_get_by_primary_key_with_false_uuid_query_param():\n#     # In operator\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9', headers=headers)\n#     assert response.status_code == 200\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6', headers=headers)\n#     assert response.status_code == 404\n#     # not In operator\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n#     assert response.status_code == 404\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n#     assert response.status_code == 200\n\n\n    # # Equal operator\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    # assert response.status_code == 404\n    # # not Equal operator\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    # assert response.status_code == 200\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 200\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n    a = sample_primary_key\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846Z&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856Z&timestamp_value____to=2021-07-26T02:17:46.986Z&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_other_default_value.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint\nfrom sqlalchemy.orm import declarative_base\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, default=datetime.now())\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, default=10)\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, default=99)\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.CREATE_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.CREATE_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = ''' [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\"}, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\"},{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\"} ] '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n         \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n         \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    # for k, v in response_data.items():\n    #     if k in change:\n    #         if isinstance(v, str):\n    #             v = v.strip()\n    #         response_ = json.dumps(v).strip()\n    #         request_ = json.dumps(change[k]).strip()\n    #         assert request_ == response_\n    return response_data\n\n\ndef test_create_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_other_set_description.py",
    "content": "import json\nimport os\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, func\nfrom sqlalchemy.orm import declarative_base\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date,  default=datetime.now())\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False,  default=10.10)\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger,  default=99)\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\nmodel_1 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.FIND_MANY,\n                                     CrudMethods.CREATE_MANY,\n                                     CrudMethods.UPDATE_ONE,\n                                     CrudMethods.UPDATE_MANY,\n                                     CrudMethods.PATCH_MANY,\n                                     CrudMethods.PATCH_ONE,\n                                     CrudMethods.DELETE_MANY,\n                                     CrudMethods.DELETE_ONE,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_1,\n                              prefix=\"/test\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\nmodel_2 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.CREATE_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_2,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\nmodel_3 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_3,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"],\n                              async_mode=True\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''[\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      },\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      },\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      }\n   ]\n\n    '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n         \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n         \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0,\n             \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_other_single_unique.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, func\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nclass UUIDTable(Base):\n    __tablename__ = 'test_single_unique_table_model'\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False,default = False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, default=datetime.now())\n    float4_value = Column(Float, nullable=False,unique=True)\n    float8_value = Column(Float(53), nullable=False,  default=10.10)\n    int2_value = Column(SmallInteger, nullable=True)\n    int4_value = Column(Integer, nullable=True)\n    int8_value = Column(BigInteger,  default=99)\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\n\n\nmodel_1 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.FIND_MANY,\n                                     CrudMethods.CREATE_MANY,\n                                     CrudMethods.UPDATE_ONE,\n                                     CrudMethods.UPDATE_MANY,\n                                     CrudMethods.PATCH_MANY,\n                                     CrudMethods.PATCH_ONE,\n                                     CrudMethods.DELETE_MANY,\n                                     CrudMethods.DELETE_ONE,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_1,\n                              prefix=\"/test\",\n                              tags=[\"test\"],\n    async_mode=True\n                              )\n\nmodel_2 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.CREATE_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_2,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"],\n    async_mode=True\n                              )\n\nmodel_3 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_3,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"],\n    async_mode=True\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''[\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":0.12,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   },\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":1.2,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   },\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":9.3,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   }\n] '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                          \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n           \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n        \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                    \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                     \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                     \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n          \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n           \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                         \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                          \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_patch_data = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_patch_many\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                            \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                          \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                           \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                            \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                            \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import  app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_patch_one\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                    \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_post_redirect_get_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test_post_direct_get\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_model=UntitledTable256,\n                                                             crud_models=UntitledTable256Model,\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             tags=[\"test\"],\n    async_mode=True\n                                                             )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_get_data, test_post_and_redirect_get_without_get]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\", \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                            \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"varchar_value\": \"string\",\n                           \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                            \"varchar_value\": \"string\",\n                            \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                           \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                           \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                            \"varchar_value\": \"string\",\n                            \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert  response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_async_test/test_put_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import  app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n    async_mode=True\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"],\n    async_mode=True\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n    async_mode=True\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_one\",\n                                       tags=[\"test\"],\n    async_mode=True\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                       \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                    \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =[\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                       \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/__init__.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_memory'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10,collation='NOCASE'))\n    date_value = Column(Date)\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, default=10.10)\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, default=99)\n    # interval_value = Column(INTERVAL)\n    # json_value = Column(JSON)\n    # jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    # uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    # xml_value = Column(NullType)\n    # array_value = Column(ARRAY(Integer()))\n    # array_str__value = Column(ARRAY(String()))\n    # box_valaue = Column(NullType)\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/foreign_tree/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/foreign_tree/test_relationship_m2m.py",
    "content": "from fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table, CHAR\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.misc.type import SqlType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.pool import StaticPool\n\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    child = Column(CHAR(10))\n    parent = relationship(\"Parent\",\n                          secondary=association_table)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    parent = Column(CHAR(10))\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    child_second = Column(CHAR(10))\n    children_second = relationship(\"Parent\",\n                                   secondary=association_table_second)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"],\n                                       sql_type=SqlType.sqlite,\n                                       foreign_include=[Parent],\n\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n\n                                                          )\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"],\n                                              sql_type=SqlType.sqlite,\n\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n                                        foreign_include=[Child, ],\n                                        sql_type=SqlType.sqlite,\n\n                                        )\ncrud_route_parent2 = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=Parent,\n                                         prefix=\"/parent\",\n                                         tags=[\"parent\"],\n                                         foreign_include=[ChildSecond],\n                                         sql_type=SqlType.sqlite,\n\n                                         )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"],\n                                             sql_type=SqlType.sqlite,\n\n                                             )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child, crud_route_parent2,\n  crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_1():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right/0?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&join_foreign_table=test_left\"\n    test_api_4 = \"parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=child1&child____list_____comparison_operator=In&child____list=child1\"\n    test_api_5 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Equal&child____list=child1\"\n    test_api_7 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In&child____list=child1\"\n    test_api_8 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=In&child____list=child1&join_foreign_table=test_left\"\n    test_api_9 = \"parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Not_in&child____list=child1\"\n    test_api_10 = \"/parent/1/test_right/1?child____str_____matching_pattern=case_sensitive&child____str=%25child%25&child____list_____comparison_operator=Not_equal&child____list=child1\"\n    test_api_11 = \"/parent/1/test_right/1?child____str_____matching_pattern=not_case_insensitive&child____str=child1&child____list_____comparison_operator=In\"\n\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1', 'id': 1}\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child': 'child1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_10, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_11, headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_one_2():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right_second/0?child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right_second/1\"\n    test_api_3 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&join_foreign_table=test_left\"\n    test_api_4 = \"parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In&child_second____list=child_second1\"\n    test_api_5 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Equal&child_second____list=child_second1\"\n    test_api_7 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In&child_second____list=child_second1\"\n    test_api_8 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=In&child_second____list=child_second1&join_foreign_table=test_left\"\n    test_api_9 = \"parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Not_in&child_second____list=child_second1\"\n    test_api_10 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=case_sensitive&child_second____str=%25child_second%25&child_second____list_____comparison_operator=Not_equal&child_second____list=child_second1\"\n    test_api_11 = \"/parent/1/test_right_second/1?child_second____str_____matching_pattern=not_case_insensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In\"\n\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1', 'id': 1}\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {'child_second': 'child_second1',\n                               'id': 1,\n                               'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_10, headers=headers)\n    assert response.status_code == 404\n\n    response = client.get(test_api_11, headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_many_1():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=1&id____to=2&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_4 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=8&id____to=9&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_5 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&id____list=0&id____list=1&id____list=2&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____str=child1&child____list_____comparison_operator=In\"\n    test_api_7 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____str=child%25&child____list_____comparison_operator=In\"\n    test_api_8 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&child____list=child2\"\n    test_api_9 = \"/parent/1/test_right?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child____str_____matching_pattern=case_sensitive&child____list_____comparison_operator=In&join_foreign_table=test_left\"\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1},\n                               {'child': 'child2', 'id': 2},\n                               {'child': 'child3', 'id': 3},\n                               {'child': 'child4', 'id': 4}]\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}, {'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}, {'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1}]\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1', 'id': 1},\n                               {'child': 'child2', 'id': 2},\n                               {'child': 'child3', 'id': 3},\n                               {'child': 'child4', 'id': 4}]\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child2', 'id': 2}]\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child': 'child1',\n                                'id': 1,\n                                'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}]\n\n\ndef test_get_many_2():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    test_api_1 = \"/parent/0/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_2 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_3 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=1&id____to=2&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_4 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____from=8&id____to=9&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_5 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&id____list=0&id____list=1&id____list=2&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In\"\n    test_api_6 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second1&child_second____list_____comparison_operator=In\"\n    test_api_7 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____str=child_second%25&child_second____list_____comparison_operator=In\"\n    test_api_8 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&child_second____list=child_second2\"\n    test_api_9 = \"/parent/1/test_right_second?id____from_____comparison_operator=Greater_than_or_equal_to&id____to_____comparison_operator=Less_than_or_equal_to&id____list_____comparison_operator=In&child_second____str_____matching_pattern=case_sensitive&child_second____list_____comparison_operator=In&join_foreign_table=test_left\"\n    response = client.get(test_api_1, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_2, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1},\n                               {'child_second': 'child_second2', 'id': 2},\n                               {'child_second': 'child_second3', 'id': 3},\n                               {'child_second': 'child_second4', 'id': 4}]\n\n    response = client.get(test_api_3, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}, {'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_4, headers=headers)\n    assert response.status_code == 204\n\n    response = client.get(test_api_5, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}, {'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_6, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1}]\n\n    response = client.get(test_api_7, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1', 'id': 1},\n                               {'child_second': 'child_second2', 'id': 2},\n                               {'child_second': 'child_second3', 'id': 3},\n                               {'child_second': 'child_second4', 'id': 4}]\n\n    response = client.get(test_api_8, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second2', 'id': 2}]\n\n    response = client.get(test_api_9, headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_second': 'child_second1',\n                                'id': 1,\n                                'test_left_foreign': [{'id': 1, 'parent': 'parent1'}]}]\n\n\ndef setup_module(module):\n    Child.__table__.create(module.engine, checkfirst=True)\n    ChildSecond.__table__.create(module.engine, checkfirst=True)\n    Parent.__table__.create(module.engine, checkfirst=True)\n    association_table.create(module.engine, checkfirst=True)\n    association_table_second.create(module.engine, checkfirst=True)\n    db = module.session()\n\n    db.add(Child(id=1, child=\"child1\"))\n    db.add(Child(id=2, child=\"child2\"))\n    db.add(Child(id=3, child=\"child3\"))\n    db.add(Child(id=4, child=\"child4\"))\n    db.flush()\n\n    db.add(Parent(id=1, parent=\"parent1\"))\n    db.add(Parent(id=2, parent=\"parent2\"))\n    db.add(Parent(id=3, parent=\"parent3\"))\n    db.add(Parent(id=4, parent=\"parent4\"))\n    db.flush()\n    db.execute(association_table.insert().values(left_id=1, right_id=1))\n    db.execute(association_table.insert().values(left_id=2, right_id=2))\n    db.execute(association_table.insert().values(left_id=3, right_id=3))\n    db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n    db.add(ChildSecond(id=1, child_second=\"child_second1\"))\n    db.add(ChildSecond(id=2, child_second=\"child_second2\"))\n    db.add(ChildSecond(id=3, child_second=\"child_second3\"))\n    db.add(ChildSecond(id=4, child_second=\"child_second4\"))\n    db.flush()\n\n    db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n    db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n    db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n    db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n    q = db.execute('''\n                    SELECT \n        name\n    FROM \n        sqlite_master \n                    ''')\n\n    available_tables = q.fetchall()\n    db.commit()\n\n\ndef teardown_module(module):\n    association_table.drop(engine, checkfirst=True)\n    association_table_second.drop(engine, checkfirst=True)\n    ChildSecond.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_extra.py",
    "content": "import json\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table, String\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.misc.type import SqlType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass User(Base):\n    __tablename__ = 'test_users'\n    id = Column(Integer, primary_key=True, autoincrement=True, unique=True)\n    name = Column(String, nullable=False)\n    email = Column(String, nullable=False)\n\n\nfriend = Table(\n    'test_friend', Base.metadata,\n    Column('id', ForeignKey('test_users.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('friend_name', String, nullable=False)\n)\n\ncrud_route_1 = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=User,\n                                   prefix=\"/user\",\n                                   tags=[\"User\"]\n                                   )\ncrud_route_2 = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=friend,\n                                   prefix=\"/friend\",\n                                   tags=[\"friend\"]\n                                   )\n\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_1,crud_route_2]]\n\nclient = TestClient(app)\n\n\ndef test_():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n    data = '[{\"id\": 1,\"name\": \"string\",\"email\": \"string\"}]'\n    response = client.post('/user', headers=headers, data=data)\n    assert response.status_code == 201\n    assert response.json() == [{\"id\": 1,\"name\": \"string\",\"email\": \"string\"}]\n\n\n    data  =' [{\"id\": 1,\"friend_name\": \"string\"}]'\n    response = client.post('/friend', headers=headers, data = data)\n    assert response.status_code == 201\n    assert response.json() == [\n  {\n    \"id\": 1,\n    \"friend_name\": \"string\"\n  }\n]\n\n    response = client.get('/friend?join_foreign_table=test_users', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_users_foreign\": [\n      {\n        \"id\": 1,\n        \"name\": \"string\",\n        \"email\": \"string\"\n      }\n    ],\n    \"id\": 1,\n    \"friend_name\": \"string\"\n  }\n]\n\n\n\ndef setup_module(module):\n    User.__table__.create(module.engine, checkfirst=True)\n    friend.create(module.engine, checkfirst=True)\n\n\ndef teardown_module(module):\n    friend.drop(engine, checkfirst=True)\n    User.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_m2m.py",
    "content": "from fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"],\n\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"],\n\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"],\n\n                                             )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child,\n  crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_second_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right&join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n    response = client.get('/parent/1?join_foreign_table=test_right&join_foreign_table=test_right_second',\n                          headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"test_right_second_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"id\": 1\n    }\n\n\ndef test_get_association_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_left&join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n\ndef test_get_association_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association_table_second?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n    response = client.get('/association_table_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'left_id_second': 1, 'right_id_second': 1, 'test_left_foreign': [{'id': 1}]},\n {'left_id_second': 2, 'right_id_second': 2, 'test_left_foreign': [{'id': 2}]},\n {'left_id_second': 3, 'right_id_second': 3, 'test_left_foreign': [{'id': 3}]},\n {'left_id_second': 4, 'right_id_second': 4, 'test_left_foreign': [{'id': 4}]}]\n\n    response = client.get('/association_table_second?join_foreign_table=test_left&join_foreign_table=test_right_second',\n                          headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'left_id_second': 1,\n  'right_id_second': 1,\n  'test_left_foreign': [{'id': 1}],\n  'test_right_second_foreign': [{'id': 1}]},\n {'left_id_second': 2,\n  'right_id_second': 2,\n  'test_left_foreign': [{'id': 2}],\n  'test_right_second_foreign': [{'id': 2}]},\n {'left_id_second': 3,\n  'right_id_second': 3,\n  'test_left_foreign': [{'id': 3}],\n  'test_right_second_foreign': [{'id': 3}]},\n {'left_id_second': 4,\n  'right_id_second': 4,\n  'test_left_foreign': [{'id': 4}],\n  'test_right_second_foreign': [{'id': 4}]}]\n\n    response = client.get('/association_table_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n\n\ndef test_get_child_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"id\": 1\n    }\n\n\ndef setup_module(module):\n    Child.__table__.create(module.engine, checkfirst=True)\n    ChildSecond.__table__.create(module.engine, checkfirst=True)\n    Parent.__table__.create(module.engine, checkfirst=True)\n    association_table.create(module.engine, checkfirst=True)\n    association_table_second.create(module.engine, checkfirst=True)\n    db = module.session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.add(Parent(id=3))\n    db.add(Parent(id=4))\n    db.flush()\n    db.execute(association_table.insert().values(left_id=1, right_id=1))\n    db.execute(association_table.insert().values(left_id=2, right_id=2))\n    db.execute(association_table.insert().values(left_id=3, right_id=3))\n    db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n    db.add(ChildSecond(id=1))\n    db.add(ChildSecond(id=2))\n    db.add(ChildSecond(id=3))\n    db.add(ChildSecond(id=4))\n    db.flush()\n\n    db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n    db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n    db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n    db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n    q = db.execute('''\n                    SELECT \n        name\n    FROM \n        sqlite_master \n                    ''')\n\n    available_tables = q.fetchall()\n    db.commit()\n\n\ndef teardown_module(module):\n    association_table.drop(engine, checkfirst=True)\n    association_table_second.drop(engine, checkfirst=True)\n    ChildSecond.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_m2m_back_populates.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    parent = relationship(\"Parent\",\n                          secondary=association_table,\n                          back_populates=\"children\")\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    parent_second = relationship(\"Parent\",\n                                 secondary=association_table_second,\n                                 back_populates=\"children_second\")\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                            secondary=association_table,\n                            back_populates=\"parent\")\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second,\n                                   back_populates=\"parent_second\")\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"]\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=ChildSecond,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"]\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"]\n                                             )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child,\n  crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n    response = client.get('/parent/1?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_second_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n    response = client.get('/parent/1?join_foreign_table=test_right&join_foreign_table=test_right_second',\n                          headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_right_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"test_right_second_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n\ndef test_get_association_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_left&join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n\ndef test_get_association_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association_table_second?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n    response = client.get('/association_table_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'left_id_second': 1, 'right_id_second': 1, 'test_left_foreign': [{'id': 1}]},\n {'left_id_second': 2, 'right_id_second': 2, 'test_left_foreign': [{'id': 2}]},\n {'left_id_second': 3, 'right_id_second': 3, 'test_left_foreign': [{'id': 3}]},\n {'left_id_second': 4, 'right_id_second': 4, 'test_left_foreign': [{'id': 4}]}]\n\n    response = client.get('/association_table_second?join_foreign_table=test_left&join_foreign_table=test_right_second',\n                          headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'left_id_second': 1,\n  'right_id_second': 1,\n  'test_left_foreign': [{'id': 1}],\n  'test_right_second_foreign': [{'id': 1}]},\n {'left_id_second': 2,\n  'right_id_second': 2,\n  'test_left_foreign': [{'id': 2}],\n  'test_right_second_foreign': [{'id': 2}]},\n {'left_id_second': 3,\n  'right_id_second': 3,\n  'test_left_foreign': [{'id': 3}],\n  'test_right_second_foreign': [{'id': 3}]},\n {'left_id_second': 4,\n  'right_id_second': 4,\n  'test_left_foreign': [{'id': 4}],\n  'test_right_second_foreign': [{'id': 4}]}]\n\n    response = client.get('/association_table_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n\n\ndef test_get_child_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"id\": 1\n    }\n\n    response = client.get('/child_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n        \"test_left_foreign\": [\n            {\n                \"id\": 1\n            }\n        ],\n        \"id\": 1\n    }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    ChildSecond.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n    association_table.create(engine, checkfirst=True)\n    association_table_second.create(engine, checkfirst=True)\n    db = session()\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.add(Parent(id=3))\n    db.add(Parent(id=4))\n    db.flush()\n    db.execute(association_table.insert().values(left_id=1, right_id=1))\n    db.execute(association_table.insert().values(left_id=2, right_id=2))\n    db.execute(association_table.insert().values(left_id=3, right_id=3))\n    db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n    db.add(ChildSecond(id=1))\n    db.add(ChildSecond(id=2))\n    db.add(ChildSecond(id=3))\n    db.add(ChildSecond(id=4))\n    db.flush()\n\n    db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n    db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n    db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n    db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n\n    db.commit()\n\n    print()\n\n\ndef teardown_module(module):\n    association_table.drop(engine, checkfirst=True)\n    association_table_second.drop(engine, checkfirst=True)\n    ChildSecond.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_m2o.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_m2o'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o.id'))\n    child = relationship(\"Child\")\n\n\nclass Child(Base):\n    __tablename__ = 'child_m2o'\n    id = Column(Integer, primary_key=True)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_id\": 1\n        }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_m2o_back_populates.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o_back_populates.id'))\n    child = relationship(\"Child\", back_populates=\"parents\")\n\nclass Child(Base):\n    __tablename__ = 'child_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    parents = relationship(\"Parent\", back_populates=\"child\")\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'id': 1,\n  'parent_m2o_back_populates_foreign': [{'child_id': 1, 'id': 1},\n                                        {'child_id': 1, 'id': 2}]},\n {'id': 2,\n  'parent_m2o_back_populates_foreign': [{'child_id': 2, 'id': 3},\n                                        {'child_id': 2, 'id': 4}]}]\n    response = client.get('/child/1?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n\n    assert response.json() == {\n    \"parent_m2o_back_populates_foreign\": [\n      {\n        \"id\": 1,\n        \"child_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"child_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"child_id\": 1\n  }\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_m2o_back_refer.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Child(Base):\n    __tablename__ = 'child_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\nclass Parent(Base):\n    __tablename__ = 'parent_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o_back_populates.id'))\n    child = relationship(\"Child\", backref=\"child_m2o_back_populates\")\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"child_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"child_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 3,\n                    \"child_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"child_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/child/1?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"parent_m2o_back_populates_foreign\": [\n      {\n        \"id\": 1,\n        \"child_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"child_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"child_id\": 1\n  }\n\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_o2m.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\")\n\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many.id'))\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_o2m_back_populates.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many_back_populates'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many_back_populates'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many_back_populates.id'))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() ==  {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_o2m_back_ref.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", backref=\"child_one_to_many_back_ref\")\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many_back_ref.id'))\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many_back_ref', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_one_to_many_back_ref_foreign': [{'id': 1, 'parent_id': 1},\n                                         {'id': 2, 'parent_id': 1}],\n  'id': 1},\n {'child_one_to_many_back_ref_foreign': [{'id': 3, 'parent_id': 2},\n                                         {'id': 4, 'parent_id': 2}],\n  'id': 2}]\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many_back_ref', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_back_ref_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/join_relationship/test_relationship_o2o.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nfrom sqlalchemy.pool import StaticPool\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True)\n\n    # one-to-many collection\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'))\n\n    # many-to-one scalar\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n    def test_function(self, *args, **kwargs ):\n        print(\"hello\")\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'child_o2o_foreign': [{'id': 1, 'parent_id': 1}, {'id': 2, 'parent_id': 1}],\n  'id': 1},\n {'child_o2o_foreign': [{'id': 3, 'parent_id': 2}, {'id': 4, 'parent_id': 2}],\n  'id': 2}]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"child_o2o_foreign\": [\n      {\n        \"id\": 1,\n        \"parent_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"parent_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [{'id': 1, 'parent_id': 1, 'parent_o2o_foreign': [{'id': 1}]},\n {'id': 2, 'parent_id': 1, 'parent_o2o_foreign': [{'id': 1}]},\n {'id': 3, 'parent_id': 2, 'parent_o2o_foreign': [{'id': 2}]},\n {'id': 4, 'parent_id': 2, 'parent_o2o_foreign': [{'id': 2}]}]\n    response = client.get('/child/1?join_foreign_table=parent_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() =={\n    \"id\": 1,\n    \"parent_o2o_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"parent_id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n    ]\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"parent_id\": 1\n  }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine)\n    Child.__table__.create(engine)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n    print()\n\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_create_many_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import UntitledTable256, app\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(crud_methods=[CrudMethods.CREATE_MANY,\n                                                     ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n                                       autocommit=True\n                                       )\n\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '[ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"varchar_value\": \"string\"}, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\",  \"varchar_value\": \"string\"}, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\",  \"varchar_value\": \"string\"} ]'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '[ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] '\n    data_ = json.loads(data)\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(sample_data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(insert_data))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_create_one_api.py",
    "content": "import json\nimport random\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit, UnknownColumn, UpdateColumnEmptyException\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import  app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\ntest_create_one = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_methods=[\n        CrudMethods.CREATE_ONE\n    ],\n    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n    prefix=\"/test_creation_one\",\n    tags=[\"test\"],\n    autocommit=True\n)\n\ntest_create_many = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_methods=[\n        CrudMethods.CREATE_MANY,\n    ],\n    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n    prefix=\"/test_creation_many\",\n    tags=[\"test\"],\n    autocommit=True\n)\n\ntest_post_and_redirect_get = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_methods=[\n        CrudMethods.POST_REDIRECT_GET\n    ],\n    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n    prefix=\"/test_post_direct_get\",\n    tags=[\"test\"],\n    autocommit=True\n)\n\ntest_get_data = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_methods=[\n        CrudMethods.FIND_ONE\n    ],\n    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n    prefix=\"/test\",\n    tags=[\"test\"],\n    autocommit=True\n)\n\ntest_delete_data = crud_router_builder(\n    db_model=UntitledTable256,\n    crud_methods=[\n        CrudMethods.DELETE_MANY\n    ],\n    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n    prefix=\"/test_delete_many\",\n    tags=[\"test\"],\n    autocommit=True\n)\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_delete_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                       \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    response_data = response.json()\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownColumn, UnknownOrderType\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n                                       exclude_columns=['bytea_value']\n                                       )\n\ntest_find_many = crud_router_builder(db_model=UntitledTable256,\n                                     prefix=\"/test_get_many\",\n                                     tags=[\"test\"],\n                                     exclude_columns=['bytea_value']\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string')}\n    data = [insert_sample_item for i in range(num)]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    assert response.status_code == 204\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         _ = response.json()\n    #         assert i in _\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"char_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response_data\n        # for i in char_test_sample_data:\n        #     assert i not in response_data\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n        #\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to',\n    #               \"char_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to',\n    #               \"char_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"char_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"char_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"char_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"varchar_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=strinG\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i not in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        # for i in char_str_sample_data:\n        #     assert i in response.json()\n        # for i in char_test_sample_data:\n        #     assert i in response.json()\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to',\n    #               \"varchar_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to',\n    #               \"varchar_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"varchar_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i not in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"varchar_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i not in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     # for i in char_str_sample_data:\n    #     #     assert i in response.json()\n    #     # for i in char_test_sample_data:\n    #     #     assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"varchar_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    # def match_regex_with_case_sensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_match_regex_with_case_sensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'str.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'tes.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # def match_regex_with_case_insensitive():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # does_not_match_regex_with_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'STR.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n    #               \"text_value____str\": 'TES.*'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n    # def similar_to():\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to',\n    #               \"text_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to',\n    #               \"text_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     # not_case_insensitive\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"text_value____str\": 'string%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #     for i in char_str_sample_data:\n    #         assert i not in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'not_similar_to',\n    #               \"text_value____str\": 'test%'}\n    #     query_string = urlencode(OrderedDict(**params))\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 5\n    #\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n    #\n    #     params = {\"primary_key____from\": min_key,\n    #               \"primary_key____to\": max_key,\n    #               \"text_value____str_____matching_pattern\": 'similar_to'}\n    #     query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n    #     response = client.get(f'/test_get_many?{query_string}')\n    #     response_data = response.json()\n    #     assert len(response_data) == 10\n    #     for i in char_str_sample_data:\n    #         assert i in response.json()\n    #     for i in char_test_sample_data:\n    #         assert i in response.json()\n\n    # match_regex_with_case_sensitive()\n    # match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    # similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key'] == init\n        init -= 1\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_get_one_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test\",\n                                      tags=[\"test\"]\n                                      )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846Z\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n\n    # sql lite\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%Tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n    #     headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n    #     headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(\n    #     f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n    #     headers=headers)\n    # assert response.status_code == 200\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 200\n# try find the data by primary key but false by uuid\n# def test_get_by_primary_key_with_false_uuid_query_param():\n#     # In operator\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9', headers=headers)\n#     assert response.status_code == 200\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6', headers=headers)\n#     assert response.status_code == 404\n#     # not In operator\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n#     assert response.status_code == 404\n#     response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n#     assert response.status_code == 200\n\n\n    # # Equal operator\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    # assert response.status_code == 404\n    # # not Equal operator\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    # assert response.status_code == 200\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # match regex with case insensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    # assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    # assert response.status_code == 200\n    # similar_to\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 200\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    # assert response.status_code == 404\n    # not_similar_to\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 404\n    # response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    # assert response.status_code == 200\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846Z&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856Z&timestamp_value____to=2021-07-26T02:17:46.986Z&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_other_default_value.py",
    "content": "import json\nimport os\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, func\nfrom sqlalchemy.orm import declarative_base\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'}, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=func.now())\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\nmodel_1 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.FIND_MANY,\n                                     CrudMethods.CREATE_MANY,\n                                     CrudMethods.UPDATE_ONE,\n                                     CrudMethods.UPDATE_MANY,\n                                     CrudMethods.PATCH_MANY,\n                                     CrudMethods.PATCH_ONE,\n                                     CrudMethods.DELETE_MANY,\n                                     CrudMethods.DELETE_ONE,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_1,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\nmodel_2 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.CREATE_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_2,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\nmodel_3 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_3,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = ''' [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\" }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\"},{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\"} ] '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n         \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n         \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n             \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n\n            {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n             \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n             \"numeric_value\": 0, \"text_value\": \"string\",\n             \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n             \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n             \"time_value\": \"18:18:18\",\n             \"timetz_value\": \"18:18:18+00:00\"},\n            ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_other_set_description.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, func\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key=Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=func.now())\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\n\nmodel_1 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.FIND_MANY,\n                                     CrudMethods.CREATE_MANY,\n                                     CrudMethods.UPDATE_ONE,\n                                     CrudMethods.UPDATE_MANY,\n                                     CrudMethods.PATCH_MANY,\n                                     CrudMethods.PATCH_ONE,\n                                     CrudMethods.DELETE_MANY,\n                                     CrudMethods.DELETE_ONE,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_1,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\nmodel_2 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.CREATE_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_2,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\nmodel_3 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_3,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''[\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      },\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      },\n      {\n         \"char_value\":\"string    \",\n         \"date_value\":\"2021-07-23\",\n         \"float4_value\":0,\n         \"float8_value\":0,\n         \"int2_value\":0,\n         \"int4_value\":0,\n         \"int8_value\":0,\n         \"numeric_value\":0,\n         \"text_value\":\"string\",\n         \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n         \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n         \"varchar_value\":\"string\"\n      }\n   ]\n\n    '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                       \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n          \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,  \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                       \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,  \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                      \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,  \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_other_single_unique.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, func\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\n\nclass UUIDTable(Base):\n    __tablename__ = 'test_single_unique_table_model'\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=func.now())\n    float4_value = Column(Float, nullable=False,unique=True)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=True)\n    int4_value = Column(Integer, nullable=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n\n\n\n\nmodel_1 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.FIND_MANY,\n                                     CrudMethods.CREATE_MANY,\n                                     CrudMethods.UPDATE_ONE,\n                                     CrudMethods.UPDATE_MANY,\n                                     CrudMethods.PATCH_MANY,\n                                     CrudMethods.PATCH_ONE,\n                                     CrudMethods.DELETE_MANY,\n                                     CrudMethods.DELETE_ONE,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_1 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_1,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\nmodel_2 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.CREATE_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_2 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_2,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\nmodel_3 = sqlalchemy_to_pydantic(UUIDTable,\n                                 crud_methods=[\n                                     CrudMethods.FIND_ONE,\n                                     CrudMethods.POST_REDIRECT_GET,\n                                 ],\n                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nroute_3 = crud_router_builder(db_model=UUIDTable,\n                              crud_models=model_3,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''[\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":0.12,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   },\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":1.2,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   },\n   {\n      \"bool_value\":true,\n      \"char_value\":\"string    \",\n      \"date_value\":\"2021-07-23\",\n      \"float4_value\":9.3,\n      \"float8_value\":0,\n      \"int2_value\":0,\n      \"int4_value\":0,\n      \"int8_value\":0,\n      \"numeric_value\":0,\n      \"text_value\":\"string\",\n      \"timestamp_value\":\"2021-07-23T02:38:24.963000\",\n      \"timestamptz_value\":\"2021-07-23T02:38:24.963000+00:00\",\n      \"varchar_value\":\"string\"\n   }\n] '''\n    data_dict = json.loads(data)\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                          \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n           \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n        \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                    \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                     \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                     \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n          \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n           \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                         \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                          \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_patch_data = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_patch_many\",\n                                      tags=[\"test\"]\n                                      )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                            \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                          \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10,\n                           \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                            \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                            \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import  app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_patch_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =  [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                    \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_post_redirect_get_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test_post_direct_get\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_model=UntitledTable256,\n                                                             crud_models=UntitledTable256Model,\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             tags=[\"test\"]\n                                                             )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_get_data, test_post_and_redirect_get_without_get]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19.0\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\", \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                         \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                            \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"varchar_value\": \"string\",\n                           \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                          \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                            \"varchar_value\": \"string\",\n                            \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                         \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"varchar_value\": \"string\",\n                           \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                           \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"varchar_value\": \"string\",\n                           \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ]\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                           \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                            \"varchar_value\": \"string\",\n                            \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert  response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/api_test/test_put_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_memory_sqlalchemy.api_test import  app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.CREATE_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_create_many = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                       \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                    \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                    \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data =[\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0,\n                        \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                       \"varchar_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10,\n                   \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_create_null_type.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True,primary_key=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(None)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    print(str(e))\n    assert 'The type of column array_str__value (NULL) not supported yet' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_create_specific_api_when_no_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\nUniqueConstraint('interval_value', 'numeric_value', 'text_value'),\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [PATCH_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.FIND_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [FIND_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.DELETE_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [DELETE_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPDATE_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [UPDATE_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.POST_REDIRECT_GET,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [POST_REDIRECT_GET] requires a primary key' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_create_table_with_more_than_one_unique_but_no_use_composite.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON, unique=True),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric, unique=True),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    assert 'nly support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_blob_type_column.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True,primary_key=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    print(str(e))\n    assert 'The type of column bytea_value (BLOB) not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_composite_primary.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        PrimaryKeyConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_more_than_one_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer,primary_key=True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10),primary_key=True,)\n    date_value = Column(Date, server_default=text(\"now()\"),primary_key=True,)\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_more_than_one_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException\n\nBase = declarative_base()\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_unique_and_composite_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_unsupported_type_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(LargeBinary, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_unsupported_type_pk_2.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(INTERVAL, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_unsupported_type_pk_3.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(JSON, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_memory_sqlalchemy/error_test/test_use_unsupported_type_pk_4.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(JSONB, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/__init__.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    # xml_value = Column(NullType)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n    # box_valaue = Column(NullType)\n\n\nUntitledTable256.__table__.create(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_m2m.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table, insert\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nassociation_table = Table('test_association', Base.metadata,\n    Column('left_id', ForeignKey('test_left.id')),\n    Column('right_id', ForeignKey('test_right.id'))\n)\n\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n    Column('left_id_second', ForeignKey('test_left.id')),\n    Column('right_id_second', ForeignKey('test_right_second.id'))\n)\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                    secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                    secondary=association_table_second)\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=association_table_second,\n                                       prefix=\"/association_table_second\",\n                                       tags=[\"association_table_second\"]\n                                       )\n\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child_second\",\n                                       tags=[\"child_second\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=association_table,\n                                        prefix=\"/association\",\n                                        tags=[\"association\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_association_table_second,crud_route_child_second,crud_route_parent, crud_route_child, crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n    response = client.get('/parent?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() ==         {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n    response = client.get('/parent?join_foreign_table=test_right&join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n    response = client.get('/parent/1?join_foreign_table=test_right&join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"test_right_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"test_right_second_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef test_get_association_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_right_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"left_id\": 1,\n    \"right_id\": 1\n  },\n  {\n    \"test_right_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"left_id\": 2,\n    \"right_id\": 2\n  },\n  {\n    \"test_right_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"left_id\": 3,\n    \"right_id\": 3\n  },\n  {\n    \"test_right_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"left_id\": 4,\n    \"right_id\": 4\n  }\n]\n\n    response = client.get('/association?join_foreign_table=test_left&join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"test_right_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"left_id\": 1,\n    \"right_id\": 1\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"test_right_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"left_id\": 2,\n    \"right_id\": 2\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"test_right_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"left_id\": 3,\n    \"right_id\": 3\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"test_right_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"left_id\": 4,\n    \"right_id\": 4\n  }\n]\n\ndef test_get_association_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association_table_second?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n    response = client.get('/association_table_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"left_id_second\": 1,\n    \"right_id_second\": 1\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"left_id_second\": 2,\n    \"right_id_second\": 2\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"left_id_second\": 3,\n    \"right_id_second\": 3\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"left_id_second\": 4,\n    \"right_id_second\": 4\n  }\n]\n\n\n    response = client.get('/association_table_second?join_foreign_table=test_left&join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"test_right_second_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"left_id_second\": 1,\n    \"right_id_second\": 1\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"test_right_second_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"left_id_second\": 2,\n    \"right_id_second\": 2\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"test_right_second_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"left_id_second\": 3,\n    \"right_id_second\": 3\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"test_right_second_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"left_id_second\": 4,\n    \"right_id_second\": 4\n  }\n]\n\n    response = client.get('/association_table_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"left_id_second\": 1,\n    \"right_id_second\": 1\n  },\n  {\n    \"left_id_second\": 2,\n    \"right_id_second\": 2\n  },\n  {\n    \"left_id_second\": 3,\n    \"right_id_second\": 3\n  },\n  {\n    \"left_id_second\": 4,\n    \"right_id_second\": 4\n  }\n]\n\ndef test_get_child_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    ChildSecond.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n    association_table.create(engine, checkfirst=True)\n    association_table_second.create(engine, checkfirst=True)\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.add(Parent(id=3))\n    db.add(Parent(id=4))\n    db.flush()\n    db.execute(association_table.insert().values(left_id = 1, right_id=1))\n    db.execute(association_table.insert().values(left_id = 2, right_id=2))\n    db.execute(association_table.insert().values(left_id = 3, right_id=3))\n    db.execute(association_table.insert().values(left_id = 4, right_id=4))\n\n    db.add(ChildSecond(id = 1))\n    db.add(ChildSecond(id = 2))\n    db.add(ChildSecond(id = 3))\n    db.add(ChildSecond(id = 4))\n    db.flush()\n\n    db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n    db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n    db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n    db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n\n    db.commit()\n\n\n\n\ndef teardown_module(module):\n    association_table.drop(engine, checkfirst=True)\n    association_table_second.drop(engine, checkfirst=True)\n    ChildSecond.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_m2m_back_populates.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    parent = relationship(\"Parent\",\n                          secondary=association_table,\n                          back_populates=\"children\")\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    parent_second = relationship(\"Parent\",\n                                 secondary=association_table_second,\n                                 back_populates=\"children_second\")\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                            secondary=association_table,\n                            back_populates=\"parent\")\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second,\n                                   back_populates=\"parent_second\")\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"]\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=ChildSecond,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"]\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"]\n                                             )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child,\n  crud_route_association]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n    response = client.get('/parent/1?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n    response = client.get('/parent/1?join_foreign_table=test_right&join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"id\": 1\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 2\n      }\n    ],\n    \"id\": 2\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 3\n      }\n    ],\n    \"id\": 3\n  },\n  {\n    \"test_left_foreign\": [\n      {\n        \"id\": 4\n      }\n    ],\n    \"id\": 4\n  }\n]\n\n\n\ndef test_get_association_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n    response = client.get('/association?join_foreign_table=test_left&join_foreign_table=test_right', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id\": 1,\n            \"right_id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id\": 2,\n            \"right_id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id\": 3,\n            \"right_id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id\": 4,\n            \"right_id\": 4\n        }\n    ]\n\n\ndef test_get_association_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/association_table_second?join_foreign_table=test_right_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n    response = client.get('/association_table_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n\n    response = client.get('/association_table_second?join_foreign_table=test_left&join_foreign_table=test_right_second',\n                          headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"test_right_second_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n\n    response = client.get('/association_table_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"left_id_second\": 1,\n            \"right_id_second\": 1\n        },\n        {\n            \"left_id_second\": 2,\n            \"right_id_second\": 2\n        },\n        {\n            \"left_id_second\": 3,\n            \"right_id_second\": 3\n        },\n        {\n            \"left_id_second\": 4,\n            \"right_id_second\": 4\n        }\n    ]\n\n\ndef test_get_child_many_second_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child_second', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\n    response = client.get('/child_second?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"id\": 2\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 3\n                }\n            ],\n            \"id\": 3\n        },\n        {\n            \"test_left_foreign\": [\n                {\n                    \"id\": 4\n                }\n            ],\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child_second/1?join_foreign_table=test_left', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"test_left_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    ChildSecond.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n    association_table.create(engine, checkfirst=True)\n    association_table_second.create(engine, checkfirst=True)\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.add(Parent(id=3))\n    db.add(Parent(id=4))\n    db.flush()\n    db.execute(association_table.insert().values(left_id=1, right_id=1))\n    db.execute(association_table.insert().values(left_id=2, right_id=2))\n    db.execute(association_table.insert().values(left_id=3, right_id=3))\n    db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n    db.add(ChildSecond(id=1))\n    db.add(ChildSecond(id=2))\n    db.add(ChildSecond(id=3))\n    db.add(ChildSecond(id=4))\n    db.flush()\n\n    db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n    db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n    db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n    db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n\n    db.commit()\n\n    print()\n\n\ndef teardown_module(module):\n    association_table.drop(engine, checkfirst=True)\n    association_table_second.drop(engine, checkfirst=True)\n    ChildSecond.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_m2o.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_m2o'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o.id'))\n    child = relationship(\"Child\")\n\n\nclass Child(Base):\n    __tablename__ = 'child_m2o'\n    id = Column(Integer, primary_key=True)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_id\": 1\n        }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_m2o_back_populates.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o_back_populates.id'))\n    child = relationship(\"Child\", back_populates=\"parents\")\n\nclass Child(Base):\n    __tablename__ = 'child_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    parents = relationship(\"Parent\", back_populates=\"child\")\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    a = response.json()\n    assert response.json() == [\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"child_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"child_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 3,\n                    \"child_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"child_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/child/1?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    a = response.json()\n\n    assert response.json() == {\n    \"parent_m2o_back_populates_foreign\": [\n      {\n        \"id\": 1,\n        \"child_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"child_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"child_id\": 1\n  }\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_m2o_back_refer.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Child(Base):\n    __tablename__ = 'child_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\nclass Parent(Base):\n    __tablename__ = 'parent_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o_back_populates.id'))\n    child = relationship(\"Child\", backref=\"child_m2o_back_populates\")\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"child_id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"child_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"child_id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"child_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"child_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"parent_m2o_back_populates_foreign\": [\n                {\n                    \"id\": 3,\n                    \"child_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"child_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/child/1?join_foreign_table=parent_m2o_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"parent_m2o_back_populates_foreign\": [\n      {\n        \"id\": 1,\n        \"child_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"child_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"child_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"child_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"child_id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"child_id\": 1\n  }\n\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n        {\n            \"id\": 3\n        },\n        {\n            \"id\": 4\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef setup_module(module):\n    Child.__table__.create(engine, checkfirst=True)\n    Parent.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Child(id=1))\n    db.add(Child(id=2))\n    db.add(Child(id=3))\n    db.add(Child(id=4))\n    db.flush()\n    db.add(Parent(id=1, child_id=1))\n    db.add(Parent(id=2, child_id=1))\n    db.add(Parent(id=3, child_id=2))\n    db.add(Parent(id=4, child_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Parent.__table__.drop(engine, checkfirst=True)\n    Child.__table__.drop(engine, checkfirst=True)\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_o2m.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\")\n\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many.id'))\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_o2m_back_populates.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many_back_populates'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many_back_populates'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many_back_populates.id'))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many_back_populates', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_back_populates_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() ==  {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_o2m_back_ref.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", backref=\"child_one_to_many_back_ref\")\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many_back_ref.id'))\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_one_to_many_back_ref', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_one_to_many_back_ref_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_one_to_many_back_ref_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n    response = client.get('/parent/1?join_foreign_table=child_one_to_many_back_ref', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"child_one_to_many_back_ref_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        }, {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }]\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n\ndef test_get_many_without_join():\n    query = {\"join_foreign_table\": \"child\"}\n    data = json.dumps(query)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        }\n    ]\n\n    response = client.get('/parent/1', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == {\n            \"id\": 1\n        }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine, checkfirst=True)\n    Child.__table__.create(engine, checkfirst=True)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/join_relationship/test_relationship_o2o.py",
    "content": "import json\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True)\n\n    # one-to-many collection\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'))\n\n    # many-to-one scalar\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n    def test_function(self, *args, **kwargs ):\n        print(\"hello\")\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\nfrom starlette.testclient import TestClient\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\nclient = TestClient(app)\n\n\ndef test_get_parent_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent?join_foreign_table=child_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"child_o2o_foreign\": [\n                {\n                    \"id\": 1,\n                    \"parent_id\": 1\n                },\n                {\n                    \"id\": 2,\n                    \"parent_id\": 1\n                }\n            ],\n            \"id\": 1\n        },\n        {\n            \"child_o2o_foreign\": [\n                {\n                    \"id\": 3,\n                    \"parent_id\": 2\n                },\n                {\n                    \"id\": 4,\n                    \"parent_id\": 2\n                }\n            ],\n            \"id\": 2\n        }\n    ]\n\n\n    response = client.get('/parent/1?join_foreign_table=child_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"child_o2o_foreign\": [\n      {\n        \"id\": 1,\n        \"parent_id\": 1\n      },\n      {\n        \"id\": 2,\n        \"parent_id\": 1\n      }\n    ],\n    \"id\": 1\n  }\n\n\ndef test_get_child_many_with_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child?join_foreign_table=parent_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_o2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_o2o_foreign\": [\n                {\n                    \"id\": 1\n                }\n            ],\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"parent_o2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_o2o_foreign\": [\n                {\n                    \"id\": 2\n                }\n            ],\n            \"parent_id\": 2\n        }\n    ]\n    response = client.get('/child/1?join_foreign_table=parent_o2o', headers=headers)\n    assert response.status_code == 200\n    assert response.json() =={\n    \"id\": 1,\n    \"parent_o2o_foreign\": [\n      {\n        \"id\": 1\n      }\n    ],\n    \"parent_id\": 1\n  }\n\n\ndef test_get_child_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/parent', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1\n        },\n        {\n            \"id\": 2\n        },\n    ]\n\n    response = client.get('/parent/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1\n  }\n\n\ndef test_get_parent_many_without_join():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.get('/child', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == [\n        {\n            \"id\": 1,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 2,\n            \"parent_id\": 1\n        },\n        {\n            \"id\": 3,\n            \"parent_id\": 2\n        },\n        {\n            \"id\": 4,\n            \"parent_id\": 2\n        }\n    ]\n\n    response = client.get('/child/1', headers=headers)\n    assert response.status_code == 200\n    assert response.json() == {\n    \"id\": 1,\n    \"parent_id\": 1\n  }\n\n\ndef setup_module(module):\n    Parent.__table__.create(engine)\n    Child.__table__.create(engine)\n\n    db = session()\n\n    db.add(Parent(id=1))\n    db.add(Parent(id=2))\n    db.flush()\n    db.add(Child(id=1, parent_id=1))\n    db.add(Child(id=2, parent_id=1))\n    db.add(Child(id=3, parent_id=2))\n    db.add(Child(id=4, parent_id=2))\n\n    db.commit()\n    print()\n\n\ndef teardown_module(module):\n    Child.__table__.drop(engine, checkfirst=True)\n    Parent.__table__.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_create_many_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] }'\n    data_ = json.loads(data)['insert']\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float8_value\": 0.7}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data['insert']):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == value[k]\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_1():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        float8_value_change = 0.1\n        int8_value_change = 100\n        json_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n        change['int8_value'] = int8_value_change\n        change['numeric_value'] = numeric_value_change\n        change['varchar_value'] = varchar_value_change\n        change['json_value'] = json_value_change\n        change['float8_value'] = float8_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['array_value'] = array_value_change\n        change['bool_value'] = bool_value_change\n        change['array_str__value'] = array_str__value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_2():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        int2_value_change = 100\n        interval_value_change = float(5400)\n        jsonb_value_change = {\"hello\": \"world\"}\n        text_value_change = 'hello world'\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        change = {}\n        change['int2_value'] = int2_value_change\n        change['text_value'] = text_value_change\n        change['uuid_value'] = uuid_value_change\n        change['char_value'] = char_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['interval_value'] = interval_value_change\n        change['date_value'] = date_value_change\n        change['timetz_value'] = timetz_value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields_1()\n    update_partial_fields_2()\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_create_one_api.py",
    "content": "import json\nimport random\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit, UnknownColumn, UpdateColumnEmptyException\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      prefix=\"/test_creation_one\",\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       tags=[\"test\"]\n                                       )\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0, 'uuid_value': '3fa85f64-5717-4562-b3fc-2c963f66afa6'}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in response_result.items():\n        if k in data:\n            if isinstance(v, str):\n                v = v.strip()\n            assert json.dumps(data[k]).strip() == json.dumps(v).strip()\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields()\n\n\ndef test_try_input_with_conflict_but_missing_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': []}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UpdateColumnEmptyException as e:\n        assert True\n        return\n    assert False\n\n\ndef test_try_input_with_conflict_but_unknown_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': ['testsetsetset']}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UnknownColumn as e:\n        assert True\n        return\n    assert False\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    response_data = response.json()\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n\n\ndef test_create_one_and_delete_one_but_not_found_test_case_sensitive():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\n              \"varchar_value____str\": 'String',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n\n    params = {\n              \"varchar_value____str\": 'String',\n              \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 200\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownColumn, UnknownOrderType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud.misc.utils import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_find_many = crud_router_builder(db_session=get_transaction_session,\n                                     db_model=UntitledTable256,\n                                     crud_models=UntitledTable256Model,\n                                     prefix=\"/test_get_many\",\n                                     tags=[\"test\"]\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"interval_value\": kwargs.get('interval_value', 5),\n                          \"json_value\": kwargs.get('json_value', {}),\n                          \"jsonb_value\": kwargs.get('jsonb_value', {}),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"uuid_value\": kwargs.get('uuid_value', \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string'),\n                          \"array_value\": kwargs.get('array_value', [1, 2, 3, 4]),\n                          \"array_str__value\": kwargs.get('array_str__value', [\"string\", \"string1\"])}\n    data = {'insert': [insert_sample_item for i in range(num)]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n        for i in _:\n            assert i not in seem\n            seem.append(i)\n            assert i in sample_data\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    assert response.status_code == 204\n\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            _ = response.json()\n            assert i in _\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two+0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two+0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 1\n    for i in a:\n        assert i['primary_key'] == init\n        init += 1\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key']  == init\n        init -= 1\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\ntest_create_a_more_than_one_data_and_get_many_1()"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_get_one_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846Z\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 200\n# try find the data by primary key but false by uuid\ndef test_get_by_primary_key_with_false_uuid_query_param():\n    # In operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6', headers=headers)\n    assert response.status_code == 404\n    # not In operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n    assert response.status_code == 200\n\n\n    # Equal operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    assert response.status_code == 404\n    # not Equal operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    assert response.status_code == 200\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 200\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846Z&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856Z&timestamp_value____to=2021-07-26T02:17:46.986Z&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_other_default_value.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(UUID(as_uuid=True), primary_key=True, info={'alias_name': 'primary_key'},\n                         server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nUUIDTable.__table__.create(engine, checkfirst=True)\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": False,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns': ['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_other_set_description.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(UUID(as_uuid=True), primary_key=True, comment='this is a primary_key',\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nUUIDTable.__table__.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\ntest_post_redirect_get_data()"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_other_single_unique.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass UUIDTable(Base):\n    __tablename__ = 'test_single_unique_table_model'\n    id = Column(UUID(as_uuid=True), primary_key=True,\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False,unique=True)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=True)\n    int4_value = Column(Integer, nullable=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ndef setup_module(module):\n    UUIDTable.__table__.create(engine)\n\n\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0.12, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 1.2, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 9.3, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\n\n\ndef teardown_module(module):\n\n    UUIDTable.__table__.drop(engine, checkfirst=True)\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_other_uuid_primary.py",
    "content": "import json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_uuid_primary_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(UUID(as_uuid=True), primary_key=True, info={'alias_name': 'primary_key'},\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nUUIDTable.__table__.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_patch_data = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_patch_many\",\n                                      tags=[\"test\"]\n                                      )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_patch_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\ntest_create_one_and_patch_one()"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_post_redirect_get_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test_post_direct_get\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_session=get_transaction_session,\n                                                             db_model=UntitledTable256,\n                                                             crud_models=UntitledTable256Model,\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             tags=[\"test\"]\n                                                             )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_get_data, test_post_and_redirect_get_without_get]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert  response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test/test_put_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/__init__.py",
    "content": "import asyncio\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n# client = AsyncIOMotorClient()??\n# client.get_io_loop = asyncio.get_event_loop\n# engine = AIOEngine(motor_client=client)\n\nengine = create_async_engine(TEST_DATABASE_URL, echo=True, future=True)\n\nasync_session = sessionmaker(\n    engine, class_=AsyncSession, expire_on_commit=False\n)\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    # xml_value = Column(NullType)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n    # box_valaue = Column(NullType)\n\n\nasync def create_table():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(create_table())\n# loop.close()\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_create_many_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] }'\n    data_ = json.loads(data)['insert']\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float8_value\": 0.7}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data['insert']):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == value[k]\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_1():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        float8_value_change = 0.1\n        int8_value_change = 100\n        json_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n        change['int8_value'] = int8_value_change\n        change['numeric_value'] = numeric_value_change\n        change['varchar_value'] = varchar_value_change\n        change['json_value'] = json_value_change\n        change['float8_value'] = float8_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['array_value'] = array_value_change\n        change['bool_value'] = bool_value_change\n        change['array_str__value'] = array_str__value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_2():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        int2_value_change = 100\n        interval_value_change = float(5400)\n        jsonb_value_change = {\"hello\": \"world\"}\n        text_value_change = 'hello world'\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        change = {}\n        change['int2_value'] = int2_value_change\n        change['text_value'] = text_value_change\n        change['uuid_value'] = uuid_value_change\n        change['char_value'] = char_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['interval_value'] = interval_value_change\n        change['date_value'] = date_value_change\n        change['timetz_value'] = timetz_value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields_1()\n    update_partial_fields_2()\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_create_one_api.py",
    "content": "import json\nimport random\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit, UpdateColumnEmptyException, UnknownColumn\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0, 'uuid_value': '3fa85f64-5717-4562-b3fc-2c963f66afa6'}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in response_result.items():\n        if k in data:\n            if isinstance(v, str):\n                v = v.strip()\n            assert json.dumps(data[k]).strip() == json.dumps(v).strip()\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields()\n\n\ndef test_try_input_with_conflict_but_missing_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': []}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UpdateColumnEmptyException as e:\n        assert True\n        return\n    assert False\n\n\ndef test_try_input_with_conflict_but_unknown_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': ['testsetsetset']}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UnknownColumn as e:\n        assert True\n        return\n    assert False\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\nfor i in [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]:\n    app.include_router(i)\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.DELETE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_delete_one\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownOrderType, UnknownColumn\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud.misc.utils import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_find_many = crud_router_builder(db_session=get_transaction_session,\n                                     db_model=UntitledTable256,\n                                     crud_models=UntitledTable256Model,\n                                     prefix=\"/test_get_many\",\n                                     async_mode=True,\n                                     tags=[\"test\"]\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"interval_value\": kwargs.get('interval_value', 5),\n                          \"json_value\": kwargs.get('json_value', {}),\n                          \"jsonb_value\": kwargs.get('jsonb_value', {}),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"uuid_value\": kwargs.get('uuid_value', \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string'),\n                          \"array_value\": kwargs.get('array_value', [1, 2, 3, 4]),\n                          \"array_str__value\": kwargs.get('array_str__value', [\"string\", \"string1\"])}\n    data = {'insert': [insert_sample_item for i in range(num)]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n        for i in _:\n            assert i not in seem\n            seem.append(i)\n            assert i in sample_data\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response.status_code = 204\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n# test order_by_columns regex validation\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] >= init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] >= init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key'] == init\n        init -= 1\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_get_one_api.py",
    "content": "import json\nimport os\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import app, UntitledTable256\n\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\nengine = create_async_engine(TEST_DATABASE_URL, echo=True, future=True)\n\nasync_session = sessionmaker(\n    engine, class_=AsyncSession, expire_on_commit=False\n)\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n    'accept': '*/*',\n    'Content-Type': 'application/json',\n}\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n\n\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n\n\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# try find the data by primary key but false by uuid\ndef test_get_by_primary_key_with_false_uuid_query_param():\n    # In operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6',\n        headers=headers)\n    assert response.status_code == 404\n    # not In operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in',\n        headers=headers)\n    assert response.status_code == 200\n\n    # Equal operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal',\n        headers=headers)\n    assert response.status_code == 404\n    # not Equal operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000',\n        headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746&timestamp_value____to=2021-07-26T02:17:46.946&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.946&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856&timestamp_value____to=2021-07-26T02:17:46.986&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_other_default_value.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_default_value_sync'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(UUID(as_uuid=True), primary_key=True, info={'alias_name': 'primary_key'},\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, default=False)\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\ndef setup_module(module):\n\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784 ,\"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef teardown_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.drop_all)\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_other_single_unique.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\nclass UUIDTable(Base):\n    __tablename__ = 'test_single_unique_table_async'\n    id = Column(UUID(as_uuid=True), primary_key=True,\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False,unique=True)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=True)\n    int4_value = Column(Integer, nullable=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\ndef setup_module(module):\n\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0.12, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 1.2, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 9.3, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef teardown_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.drop_all)\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_other_uuid_primary.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\nclass UUIDTable(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_uuid_primary_async'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(UUID(as_uuid=True), primary_key=True,\n                server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nasync def create_table():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(create_table())\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              async_mode=True,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_patch_data = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_patch_many\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    async_mode=True,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.PATCH_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_patch_one\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_post_redirect_get_api.py",
    "content": "import json\nimport os\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import app, UntitledTable256\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\nengine = create_async_engine(TEST_DATABASE_URL, echo=True, future=True)\n\nasync_session = sessionmaker(\n    engine, class_=AsyncSession, expire_on_commit=False\n)\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_session=get_transaction_session,\n                                                             db_model=UntitledTable256,\n                                                             crud_models=UntitledTable256Model,\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             async_mode=True,\n                                                             tags=[\"test\"]\n                                                             )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test_post_direct_get\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_get_data, test_post_and_redirect_get_without_get]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\ntest_create_but_not_found_get_api()"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import get_transaction_session, app, UntitledTable256\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_update_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/api_test_async/test_put_one_api.py",
    "content": "import json\nimport os\nfrom collections import OrderedDict\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy.api_test_async import  app, UntitledTable256\n\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\nengine = create_async_engine(TEST_DATABASE_URL, echo=True, future=True)\n\nasync_session = sessionmaker(\n    engine, class_=AsyncSession, expire_on_commit=False\n)\nasync def get_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_one = crud_router_builder(db_session=get_session,\n                                      db_model=UntitledTable256,\n                                      crud_models=UntitledTable256Model,\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPSERT_MANY,\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_create_many = crud_router_builder(db_session=get_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_models=UntitledTable256Model,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_get_data = crud_router_builder(db_session=get_session,\n                                    db_model=UntitledTable256,\n                                    crud_models=UntitledTable256Model,\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\nUntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                               crud_methods=[\n                                                   CrudMethods.UPDATE_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\ntest_update_data = crud_router_builder(db_session=get_session,\n                                       db_model=UntitledTable256,\n                                       crud_models=UntitledTable256Model,\n                                       async_mode=True,\n                                       prefix=\"/test_update_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = UntitledTable256.primary_key_of_table\nunique_fields = UntitledTable256.unique_fields\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        print(i)\n        print(response_data[i])\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_create_null_type.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, Numeric, SmallInteger, String, Text, Time, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True, primary_key=True,\n                         server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(None)\n\n\nfrom sqlalchemy.orm import sessionmaker\nimport os\nfrom sqlalchemy import create_engine\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    assert 'The type of column array_str__value (NULL) not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_create_specific_api_when_no_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\nUniqueConstraint('interval_value', 'numeric_value', 'text_value'),\n)\n\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue','__id'])\nexcept PrimaryMissing as e:\n    assert 'The generation of this API [PATCH_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.FIND_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue','__id'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [FIND_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.DELETE_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue','__id'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [DELETE_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPDATE_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue','__id'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [UPDATE_ONE] requires a primary key' in str(e)\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.POST_REDIRECT_GET,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue','__id'])\nexcept PrimaryMissing as e:\n    print(str(e))\n    assert 'The generation of this API [POST_REDIRECT_GET] requires a primary key' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_create_table_with_more_than_one_unique_but_no_use_composite.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('id', Integer, autoincrement=True, primary_key=True),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON, unique=True),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric, unique=True),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n)\nfrom sqlalchemy.orm import sessionmaker\nimport os\nfrom sqlalchemy import  create_engine\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\n\ntry:\n\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue', '__id'])\nexcept SchemaException as e:\n    assert 'nly support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_blob_type_column.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud import CrudMethods\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True, primary_key=True,\n                         server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nfrom sqlalchemy.orm import sessionmaker\nimport os\nfrom sqlalchemy import create_engine\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\ntry:\n\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept BaseException as e:\n    assert 'The type of column bytea_value (BLOB) not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_composite_primary.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        PrimaryKeyConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_more_than_one_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer,primary_key=True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10),primary_key=True,)\n    date_value = Column(Date, server_default=text(\"now()\"),primary_key=True,)\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_more_than_one_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException\n\nBase = declarative_base()\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_unique_and_composite_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n    primary_key = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True,server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_unsupported_type_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(LargeBinary, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_unsupported_type_pk_2.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(INTERVAL, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_unsupported_type_pk_3.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(JSON, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy/error_test/test_use_unsupported_type_pk_4.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\n\nclass UntitledTable256(Base):\n    primary_key_of_table = \"primary_key\"\n    unique_fields = ['primary_key', 'int4_value', 'float4_value']\n    __tablename__ = 'test_build_myself_async'\n    primary_key = Column(JSONB, primary_key = True, info={'alias_name': 'primary_key'}, autoincrement=True,\n                server_default=\"nextval('test_build_myself_id_seq'::regclass)\")\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False, unique=True)\n    int4_value = Column(Integer, nullable=False, unique=True)\n    int8_value = Column(BigInteger, server_default=text(\"99\"), unique=True)\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/__init__.py",
    "content": "import os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR,Table, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n)\n\nUntitledTable256.create(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      prefix=\"/test_creation_one\",\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 tags=[\"test\"]\n                                                 )\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.DELETE_MANY\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_delete_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.DELETE_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_delete_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    response_data = response.json()\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownColumn, UnknownOrderType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud.misc.utils import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\ntest_find_many = crud_router_builder(db_session=get_transaction_session,\n                                     db_model=UntitledTable256,\n                                     crud_methods=[\n                                         CrudMethods.FIND_MANY,\n                                     ],\n                                     exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                     prefix=\"/test_get_many\",\n                                     tags=[\"test\"]\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"interval_value\": kwargs.get('interval_value', 5),\n                          \"json_value\": kwargs.get('json_value', {}),\n                          \"jsonb_value\": kwargs.get('jsonb_value', {}),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"uuid_value\": kwargs.get('uuid_value', \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string'),\n                          \"array_value\": kwargs.get('array_value', [1, 2, 3, 4]),\n                          \"array_str__value\": kwargs.get('array_str__value', [\"string\", \"string1\"])}\n    data = {'insert': [insert_sample_item for i in range(num)]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n        for i in _:\n            assert i not in seem\n            seem.append(i)\n            assert i in sample_data\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    assert response.status_code == 204\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] > init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] > init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key'] == init\n        init -= 1\n\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_get_one_api.py",
    "content": "import json\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n    'accept': '*/*',\n    'Content-Type': 'application/json',\n}\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846Z\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n\n\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n\n\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# try find the data by primary key but false by uuid\ndef test_get_by_primary_key_with_false_uuid_query_param():\n    # In operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6',\n        headers=headers)\n    assert response.status_code == 404\n    # not In operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in',\n        headers=headers)\n    assert response.status_code == 200\n\n    # Equal operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal',\n        headers=headers)\n    assert response.status_code == 404\n    # not Equal operator\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n\n\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000',\n        headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846Z&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846Z&timestamp_value____to=2021-07-26T02:17:46.946Z&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856Z&timestamp_value____to=2021-07-26T02:17:46.986Z&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00',\n        headers=headers)\n    assert response.status_code == 404\n\n\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00',\n        headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_other_no_alias.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, Table, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUUIDTable = Table(\n    'test_no_alias', metadata,\n    Column('id', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('id', 'int4_value', 'float4_value')\n)\n\nUUIDTable.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns': ['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_other_set_description.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, Table, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUUIDTable = Table(\n    'test_default_value', metadata,\n    Column('primary_key', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"), comment='this is a primary_key'),\n    Column('bool_value', Boolean, nullable=False, default=False),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value')\n)\n\nUUIDTable.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784 ,\"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_other_single_unique.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUUIDTable = Table(\n    'test_single_unique_table', metadata,\n    Column('id', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False, unique=True),\n    Column('float8_value', Float(53), nullable=True, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=True),\n    Column('int4_value', Integer, nullable=True),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n)\n\nUUIDTable.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue']\n                              ,\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0.12, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 1.2, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 9.3, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 500,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 500,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns': ['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef teardown_module(module):\n    UUIDTable.drop(engine, checkfirst=True)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_other_user_default_value.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, Table, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUUIDTable = Table(\n    'test_default_value', metadata,\n    Column('primary_key', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, default=False),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value')\n)\n\nUUIDTable.create(engine, checkfirst=True)\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784 ,\"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_other_uuid_primary.py",
    "content": "import json\nimport os\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nUUIDTable = Table(\n    'test_uuid_primary', metadata,\n    Column('primary_key', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value')\n)\n\n\ndef setup_module(module):\n    UUIDTable.create(engine, checkfirst=True)\n\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n        \"bool_value____list\": True,\n        \"char_value____str\": 'string%',\n        \"char_value____str_____matching_pattern\": 'case_sensitive',\n        \"date_value____from\": \"2021-07-22\",\n        \"date_value____to\": \"2021-07-25\",\n        \"float4_value____from\": -1,\n        \"float4_value____to\": 2,\n        \"float4_value____list\": 0,\n        \"float8_value____from\": -1,\n        \"float8_value____to\": 2,\n        \"float8_value____list\": 0,\n        \"int2_value____from\": -1,\n        \"int2_value____to\": 9,\n        \"int2_value____list\": 0,\n        \"int4_value____from\": -1,\n        \"int4_value____to\": 9,\n        \"int4_value____list\": 0,\n        \"int8_value____from\": -1,\n        \"int8_value____to\": 9,\n        \"int8_value____list\": 0,\n        \"interval_value____from\": -1,\n        \"interval_value____to\": 9,\n        \"interval_value____list\": 0,\n        \"numeric_value____from\": -1,\n        \"numeric_value____to\": 9,\n        \"numeric_value____list\": 0,\n        \"text_value____list\": \"string\",\n        \"time_value____from\": '18:18:18',\n        \"time_value____to\": '18:18:18',\n        \"time_value____list\": '18:18:18',\n        \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n        \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n        \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n        \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n        \"time_value____from\": '18:18:18+00:00',\n        \"time_value____to\": '18:18:18+00:00',\n        \"time_value____list\": '18:18:18+00:00',\n        \"varchar_value____str\": 'string',\n        \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n        \"varchar_value____list\": 'string',\n    }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k, v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns': ['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_patch_data = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.PATCH_MANY\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_patch_many\",\n                                      tags=[\"test\"]\n                                      )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.PATCH_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_patch_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_post_redirect_get_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test_post_direct_get\",\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_session=get_transaction_session,\n                                                             db_model=UntitledTable256,\n                                                             crud_methods=[\n                                                                 CrudMethods.POST_REDIRECT_GET\n                                                             ],\n                                                             exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             tags=[\"test\"]\n                                                             )\n[app.include_router(i) for i in [test_post_and_redirect_get,test_post_and_redirect_get_without_get, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue']\n                                      ,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPDATE_MANY\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_update_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285Z\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert  response.status_code == 204\n\n# test_create_many_and_update_many()"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_put_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPDATE_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_update_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_upsert_many_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\n\n# Create Many API Test\n\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963Z\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] }'\n    data_ = json.loads(data)['insert']\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float8_value\": 0.7}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data['insert']):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == value[k]\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_1():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        float8_value_change = 0.1\n        int8_value_change = 100\n        json_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n        change['int8_value'] = int8_value_change\n        change['numeric_value'] = numeric_value_change\n        change['varchar_value'] = varchar_value_change\n        change['json_value'] = json_value_change\n        change['float8_value'] = float8_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['array_value'] = array_value_change\n        change['bool_value'] = bool_value_change\n        change['array_str__value'] = array_str__value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_2():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        int2_value_change = 100\n        interval_value_change = float(5400)\n        jsonb_value_change = {\"hello\": \"world\"}\n        text_value_change = 'hello world'\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        change = {}\n        change['int2_value'] = int2_value_change\n        change['text_value'] = text_value_change\n        change['uuid_value'] = uuid_value_change\n        change['char_value'] = char_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['interval_value'] = interval_value_change\n        change['date_value'] = date_value_change\n        change['timetz_value'] = timetz_value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields_1()\n    update_partial_fields_2()\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test/test_upsert_one_api.py",
    "content": "import json\nimport random\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit, UnknownColumn, UpdateColumnEmptyException\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test import get_transaction_session, app, UntitledTable256\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"],\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue']\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"],\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue']\n                                       )\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue']\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0, 'uuid_value': '3fa85f64-5717-4562-b3fc-2c963f66afa6'}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in response_result.items():\n        if k in data:\n            if isinstance(v, str):\n                v = v.strip()\n            assert json.dumps(data[k]).strip() == json.dumps(v).strip()\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields()\n\n\ndef test_try_input_with_conflict_but_missing_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': []}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UpdateColumnEmptyException as e:\n        assert True\n        return\n    assert False\n\n\ndef test_try_input_with_conflict_but_unknown_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': ['testsetsetset']}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UnknownColumn as e:\n        assert True\n        return\n    assert False\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/__init__.py",
    "content": "import asyncio\nimport os\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR,Table, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nfrom sqlalchemy.ext.asyncio import AsyncSession, create_async_engine\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n)\n\n\nasync def create_table():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(create_table())"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_create_many_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, UntitledTable256\n\n\n\n# Create Many API Test\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_create_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963\", \"timestamptz_value\": \"2021-07-23T02:38:24.963Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'\n\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"insert\": [ { \"float4_value\": 1, \"int2_value\": 1, \"int4_value\": 1 },{ \"float4_value\": 2, \"int2_value\": 2, \"int4_value\": 2 },{ \"float4_value\": 3, \"int2_value\": 3, \"int4_value\": 3 } ] }'\n    data_ = json.loads(data)['insert']\n    response = client.post('/test_creation_many', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float8_value\": 0.7}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data['insert']):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == value[k]\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    insert_data = []\n    for i in sample_data:\n        _ = {}\n        for k, v in i.items():\n            _[k] = v\n        for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n            _[k] = v\n        insert_data.append(_)\n    data['insert'] = insert_data\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_1():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        bool_value_change = not response_data[0]['bool_value']\n        float8_value_change = 0.1\n        int8_value_change = 100\n        json_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n        change['int8_value'] = int8_value_change\n        change['numeric_value'] = numeric_value_change\n        change['varchar_value'] = varchar_value_change\n        change['json_value'] = json_value_change\n        change['float8_value'] = float8_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['array_value'] = array_value_change\n        change['bool_value'] = bool_value_change\n        change['array_str__value'] = array_str__value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields_2():\n        headers = {\n            'accept': 'application/json',\n        }\n        response_data = create_example_data()\n\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        tmp = {}\n        tmp['on_conflict'] = update_column_on_conflict\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        int2_value_change = 100\n        interval_value_change = float(5400)\n        jsonb_value_change = {\"hello\": \"world\"}\n        text_value_change = 'hello world'\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        change = {}\n        change['int2_value'] = int2_value_change\n        change['text_value'] = text_value_change\n        change['uuid_value'] = uuid_value_change\n        change['char_value'] = char_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['interval_value'] = interval_value_change\n        change['date_value'] = date_value_change\n        change['timetz_value'] = timetz_value_change\n\n        for i in response_data:\n            for k, v in change.items():\n                i[k] = v\n        tmp['insert'] = response_data\n        response = client.post('/test_creation_many', headers=headers, data=json.dumps(tmp))\n        assert response.status_code == 201\n        response_result = response.json()\n        for i in response_result:\n            for k, v in i.items():\n                if k in change:\n                    if isinstance(v, str):\n                        v = v.strip()\n\n                    assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields_1()\n    update_partial_fields_2()\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_create_one_api.py",
    "content": "import json\nimport random\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.exceptions import ConflictColumnsCannotHit, UnknownColumn, UpdateColumnEmptyException\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 async_mode=True,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# Create One API Test\n\ndef create_example_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n\n    response = client.post('/test_creation_one', headers=headers, data=data)\n    assert response.status_code == 201\n    return response.json()\n\n\ndef test_try_only_input_required_fields():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"float4_value\": 0.0, \"int2_value\": 0, \"int4_value\": 0, 'uuid_value': '3fa85f64-5717-4562-b3fc-2c963f66afa6'}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in data.items():\n        assert response_result[k] == v\n\n\ndef test_try_input_with_conflict_but_conflict_columns_not_hit():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 99, \"int2_value\": 99, \"int4_value\": 99}.items():\n        data[k] = v\n    # for k, v in {\"float4_value\": 99.9, \"int2_value\": 99, \"int4_value\": 99}.items():\n    #     data[k] = v\n    try:\n        _ = json.dumps(data)\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except ConflictColumnsCannotHit as e:\n        pass\n    assert response.status_code == 409\n\n\ndef test_try_input_with_conflict():\n    sample_data = create_example_data()\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {\"on_conflict\": {\"update_columns\": [\"bool_value\", \"float8_value\", \"varchar_value\", \"interval_value\",\n                                               \"time_value\", \"int8_value\", \"jsonb_value\", \"timetz_value\",\n                                               \"array_str__value\", \"text_value\", \"char_value\", \"uuid_value\",\n                                               \"array_value\", \"numeric_value\", \"timestamp_value\", \"int2_value\",\n                                               \"date_value\", \"json_value\", \"timestamptz_value\"]}}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for k, v in response_result.items():\n        if k in data:\n            if isinstance(v, str):\n                v = v.strip()\n            assert json.dumps(data[k]).strip() == json.dumps(v).strip()\n\n\ndef test_try_input_without_conflict():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    # data['on_conflict'] = {'update_columns': []}\n\n    response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    assert response.status_code == 409\n\n\ndef test_update_specific_columns_when_conflict():\n    def update_all_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"int8_value\",\n                \"numeric_value\",\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"int2_value\",\n                \"text_value\",\n                \"uuid_value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        int2_value_change = 100\n        int8_value_change = 100\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        numeric_value_change = 19\n        text_value_change = 'hello world'\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        uuid_value_change = str(uuid.uuid4())\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['int2_value'] = int2_value_change\n        change['int8_value'] = int8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['numeric_value'] = numeric_value_change\n        change['text_value'] = text_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['uuid_value'] = uuid_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    def update_partial_fields():\n        headers = {\n            'accept': 'application/json',\n        }\n\n        sample_data = create_example_data()\n        response = client.get(f'/test/{sample_data[primary_key_name]}', headers=headers)\n        assert response.status_code == 200\n        response_data = response.json()\n        # create the data\n        update_column_on_conflict = {\n            \"update_columns\": [\n                \"varchar_value\",\n                \"json_value\",\n                \"float8_value\",\n                \"time_value\",\n                \"timestamp_value\",\n                \"timestamptz_value\",\n                \"array_value\",\n                \"bool_value\",\n                \"array_str__value\",\n                \"char_value\",\n                \"jsonb_value\",\n                \"interval_value\",\n                \"date_value\",\n                \"timetz_value\"\n            ]\n        }\n        response_data['on_conflict'] = update_column_on_conflict\n        ran_num = random.randint(5, 100)\n\n        bool_value_change = not response_data['bool_value']\n        char_value_change = \"test\"\n        date_value_change = str(date.today() - timedelta(days=1))\n        float8_value_change = 0.1\n        interval_value_change = float(5400)\n        json_value_change = {\"hello\": \"world\"}\n        jsonb_value_change = {\"hello\": \"world\"}\n        time_value_change = '18:18:18'\n        timestamp_value_change = str(datetime.utcnow().isoformat())\n        timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n        timetz_value_change = '18:18:18+00:00'\n        varchar_value_change = 'hello world'\n        array_value_change = [1, 2, 3, 4]\n        array_str__value_change = ['1', '2', '3', '4']\n        change = {}\n\n        change['bool_value'] = bool_value_change\n        change['char_value'] = char_value_change\n        change['date_value'] = date_value_change\n        change['float8_value'] = float8_value_change\n        change['interval_value'] = interval_value_change\n        change['json_value'] = json_value_change\n        change['jsonb_value'] = jsonb_value_change\n        change['time_value'] = time_value_change\n        change['timestamp_value'] = timestamp_value_change\n        change['timestamptz_value'] = timestamptz_value_change\n        change['timetz_value'] = timetz_value_change\n        change['varchar_value'] = varchar_value_change\n        change['array_value'] = array_value_change\n        change['array_str__value'] = array_str__value_change\n        for k, v in change.items():\n            response_data[k] = v\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(response_data))\n        assert response.status_code == 201\n        response_result = response.json()\n        for k, v in response_result.items():\n            if k in change:\n                if isinstance(v, str):\n                    v = v.strip()\n\n                assert json.dumps(change[k]).strip() == json.dumps(v).strip()\n\n    update_all_fields()\n    update_partial_fields()\n\n\n\ndef test_try_input_with_conflict_but_missing_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': []}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UpdateColumnEmptyException as e:\n        assert True\n        return\n    assert False\n\n\ndef test_try_input_with_conflict_but_unknown_update_columns():\n    sample_data = create_example_data()\n\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = {}\n    for k, v in sample_data.items():\n        data[k] = v\n    for k, v in {\"float4_value\": 0.0, \"int2_value\": 99, \"int4_value\": 0}.items():\n        data[k] = v\n    data['on_conflict'] = {'update_columns': ['testsetsetset']}\n    try:\n        response = client.post('/test_creation_one', headers=headers, data=json.dumps(data))\n    except UnknownColumn as e:\n        assert True\n        return\n    assert False"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_delete_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       async_mode=True,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                       async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.DELETE_MANY\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_delete_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\ndef test_create_many_and_delete_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\n\ndef test_create_many_and_delete_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '12:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.delete(f'/test_delete_many?{query_string}')\n    assert response.status_code == 204\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_delete_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       async_mode=True,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 async_mode=True,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    async_mode=True,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\ntest_delete_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.DELETE_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       async_mode=True,\n                                       prefix=\"/test_delete_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_delete_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_delete_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    response_data = response.json()\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\n\n\ndef test_create_one_and_delete_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.delete(f'/test_delete_one/{primary_key}?{query_string}')\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_get_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\nfrom urllib.parse import urlencode\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud.misc.exceptions import UnknownOrderType, UnknownColumn\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud.misc.utils import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n# #\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n\ntest_find_many = crud_router_builder(db_session=get_transaction_session,\n                                     db_model=UntitledTable256,\n                                     crud_methods=[\n                                         CrudMethods.FIND_MANY,\n                                     ],\n                                     exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                     async_mode=True,\n                                     prefix=\"/test_get_many\",\n                                     tags=[\"test\"]\n                                     )\n\n[app.include_router(i) for i in [test_create_many, test_find_many]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# test create many\n\ndef create_example_data(num=1, **kwargs):\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    insert_sample_item = {\"bool_value\": kwargs.get('bool_value', True),\n                          \"char_value\": kwargs.get('char_value', 'string'),\n                          \"date_value\": kwargs.get('date_value', \"2021-07-23\"),\n                          \"float4_value\": kwargs.get('float4_value', 0.6),\n                          \"float8_value\": kwargs.get('float8_value', 0.8),\n                          \"int2_value\": kwargs.get('int2_value', 11),\n                          \"int4_value\": kwargs.get('int4_value', 1),\n                          \"int8_value\": kwargs.get('int8_value', 3),\n                          \"interval_value\": kwargs.get('interval_value', 5),\n                          \"json_value\": kwargs.get('json_value', {}),\n                          \"jsonb_value\": kwargs.get('jsonb_value', {}),\n                          \"numeric_value\": kwargs.get('numeric_value', 110),\n                          \"text_value\": kwargs.get('text_value', 'string'),\n                          \"timestamp_value\": kwargs.get('timestamp_value', \"2021-07-23T02:38:24.963\"),\n                          \"timestamptz_value\": kwargs.get('timestamptz_value', \"2021-07-23T02:38:24.963Z\"),\n                          \"uuid_value\": kwargs.get('uuid_value', \"3fa85f64-5717-4562-b3fc-2c963f66afa6\"),\n                          \"varchar_value\": kwargs.get('varchar_value', 'string'),\n                          \"array_value\": kwargs.get('array_value', [1, 2, 3, 4]),\n                          \"array_str__value\": kwargs.get('array_str__value', [\"string\", \"string1\"])}\n    data = {'insert': [insert_sample_item for i in range(num)]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    response_result = response.json()\n    for i in response_result:\n        assert primary_key_name in i\n        assert i[primary_key_name]\n    return response_result\n\n\n# test pagination by offset and limit and ordering\ndef test_pagination_and_ording():\n    sample_data = create_example_data(5 * 10)\n    assert len(sample_data) == 5 * 10\n    limit = 5\n    seem = []\n    for num in range(0, 5 * 10, 5):\n        response = client.get(\n            f'/test_get_many?limit={limit}&offset={num}&order_by_columns=primary_key%20%3A%20DESC%20')\n        response.headers['x-total-count'] == limit\n        assert response.status_code == 200\n        _ = response.json()\n        for i in _:\n            assert i not in seem\n            seem.append(i)\n            assert i in sample_data\n\n\n# test create a new data and get by primary key\ndef test_create_new_data_and_get_by_primary_key():\n    sample_data = create_example_data(10)\n    primary_key_list = [i[primary_key_name] for i in sample_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key, \"primary_key____to\": max_key}\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"primary_key____from_____comparison_operator\": 'Greater_than',\n              \"primary_key____to_____comparison_operator\": 'Less_than'}\n\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 8\n    for i in response_data:\n        assert i['primary_key'] in primary_key_list\n\n\n# test create a more than one data which value is TRUE of boolean type, and get many\ndef test_create_a_more_than_one_data_which_value_is_TRUE_of_boolean_type_and_get_many():\n    bool_false_sample_data = create_example_data(5, bool_value=False)\n    bool_true_sample_data = create_example_data(5, bool_value=True)\n    primary_key_list = [i[primary_key_name] for i in bool_false_sample_data] + \\\n                       [i[primary_key_name] for i in bool_true_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"In\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n\n    #\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    assert response.status_code == 204\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_in\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params)) + f\"&bool_value____list=False\"\n\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 10\n\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": True}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i in response.json()\n    for i in bool_true_sample_data:\n        assert i not in response.json()\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list_____comparison_operator\": \"Not_equal\",\n              \"bool_value____list\": False}\n    query_string = urlencode(OrderedDict(**params))\n    response = client.get(f'/test_get_many?{query_string}')\n    response_data = response.json()\n    assert len(response_data) == 5\n    for i in bool_false_sample_data:\n        assert i not in response.json()\n    for i in bool_true_sample_data:\n        assert i in response.json()\n\n\n# test create a more than one data of char/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_1():\n    char_str_sample_data = create_example_data(5, char_value='string')\n    char_test_sample_data = create_example_data(5, char_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"char_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'string    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'test      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'STRING    '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"char_value____str\": 'TEST      '}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=STRING    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'not_similar_to',\n                  \"char_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"char_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&char_value____str=str%&char_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Varchar\n    char_str_sample_data = create_example_data(5, varchar_value='string')\n    char_test_sample_data = create_example_data(5, varchar_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"varchar_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"varchar_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'not_similar_to',\n                  \"varchar_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"varchar_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&varchar_value____str=str%&varchar_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n    # Text\n    char_str_sample_data = create_example_data(5, text_value='string')\n    char_test_sample_data = create_example_data(5, text_value='test')\n    primary_key_list = [i[primary_key_name] for i in char_str_sample_data] + \\\n                       [i[primary_key_name] for i in char_test_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    # match_regex_with_case_sensitive/ dose not match_regex_with_case_sensitive\n    def match_regex_with_case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_match_regex_with_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'str.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'tes.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def match_regex_with_case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # does_not_match_regex_with_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'STR.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_sensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'does_not_match_regex_with_case_insensitive',\n                  \"text_value____str\": 'TES.*'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STR.*\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_sensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_sensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'string'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'test'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=string    \"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def case_insensitive():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'STRING'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_insensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_case_sensitive',\n                  \"text_value____str\": 'TEST'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=STRING\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    def similar_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        # not_case_insensitive\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'string%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i not in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'not_similar_to',\n                  \"text_value____str\": 'test%'}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i not in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"text_value____str_____matching_pattern\": 'similar_to'}\n        query_string = urlencode(OrderedDict(**params)) + \"&text_value____str=str%&text_value____str=_es%\"\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in char_str_sample_data:\n            assert i in response.json()\n        for i in char_test_sample_data:\n            assert i in response.json()\n\n    match_regex_with_case_sensitive()\n    match_regex_with_case_insensitive()\n    case_sensitive()\n    case_insensitive()\n    similar_to()\n\n\n# test create a more than one data of float4/text/varchar type, and get many\ndef test_create_a_more_than_one_data_and_get_many_2():\n    float_one = 5.5\n    float_two = 10.7\n\n    # float 4 <= will round down to the odd floating even\n    # data  = 0.4\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n\n    num_one_sample_data = create_example_data(5, float4_value=float_one)\n    num_two_sample_data = create_example_data(5, float4_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float4_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    # data = 10.7\n    # < 10.7\n    # still got 10.7 but if data is 10.6\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float4_value____from_____comparison_operator\": 'Greater_than',\n                  \"float4_value____to_____comparison_operator\": 'Less_than',\n                  \"float4_value____from\": float_one,\n                  \"float4_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n    # float 4 < will round down to the odd floating odd\n    # data  = 0.3\n    # <= 0.4\n    # result = []\n\n    # data  = 0.4\n    # <= 0.5\n    # result = [0.4]\n    float_one = 5.5\n    float_two = 10.6\n    num_one_sample_data = create_example_data(5, float8_value=float_one)\n    num_two_sample_data = create_example_data(5, float8_value=float_two)\n    primary_key_list = [i[primary_key_name] for i in num_one_sample_data] + \\\n                       [i[primary_key_name] for i in num_two_sample_data]\n\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n\n    def greater_than_or_equal_to_Less_than_or_equal_to():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than_or_equal_to',\n                  \"float8_value____to_____comparison_operator\": 'Less_than_or_equal_to',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 10\n        for i in num_one_sample_data:\n            assert i in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    def less_than_or_equal_to_less_than():\n        params = {\"primary_key____from\": min_key,\n                  \"primary_key____to\": max_key,\n                  \"float8_value____from_____comparison_operator\": 'Greater_than',\n                  \"float8_value____to_____comparison_operator\": 'Less_than',\n                  \"float8_value____from\": float_one,\n                  \"float8_value____to\": float_two + 0.1}\n        query_string = urlencode(OrderedDict(**params))\n        response = client.get(f'/test_get_many?{query_string}')\n        response_data = response.json()\n        assert len(response_data) == 5\n        for i in num_one_sample_data:\n            assert i not in response.json()\n        for i in num_two_sample_data:\n            assert i in response.json()\n\n    greater_than_or_equal_to_Less_than_or_equal_to()\n    less_than_or_equal_to_less_than()\n\n\ndef test_get_many_with_ordering_unknown_column():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=testestset')\n    except UnknownColumn as e:\n        assert str(e) == \"column testestset is not exited\"\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_default_order():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] > init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_ASC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:ASC&limit=10&offset=0')\n    a = response.json()\n    init = 0\n    for i in a:\n        assert i['primary_key'] > init\n        init = i['primary_key']\n\n\ndef test_get_many_with_ordering_with_DESC():\n    response = client.get(f'/test_get_many?order_by_columns=primary_key:DESC&limit=10&offset=10')\n    a = response.json()\n    init = a[0]['primary_key']\n    for i in a:\n        assert i['primary_key'] == init\n        init -= 1\n\n\ndef test_get_many_with_unknown_order_tyoe():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=primary_key:DESCSS&limit=10&offset=0')\n    except UnknownOrderType as e:\n        assert str(e) == 'Unknown order type DESCSS, only accept DESC or ASC'\n        return\n    assert False\n\n\ndef test_get_many_with_ordering_with_empty_input_list():\n    try:\n        response = client.get(f'/test_get_many?order_by_columns=')\n    except Exception as e:\n        assert False\n    assert True\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_get_one_api.py",
    "content": "import json\nimport os\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import sessionmaker\nfrom starlette.testclient import TestClient\n\n\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import app, UntitledTable256\n\n\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\nengine = create_async_engine(TEST_DATABASE_URL, echo=True, future=True)\n\nasync_session = sessionmaker(\n    engine, class_=AsyncSession, expire_on_commit=False\n)\nasync def get_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\ntest_create_one = crud_router_builder(db_session=get_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test\",\n                                      tags=[\"test\"]\n                                      )\n\n\ntest_get_data = crud_router_builder(db_session=get_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n[app.include_router(i) for i in [test_get_data, test_create_one]]\n\nclient = TestClient(app)\n# create a sample data\n\nheaders = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\ndata = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-26\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\", \"timestamp_value\": \"2021-07-26T02:17:46.846\", \"timestamptz_value\": \"2021-07-26T02:17:46.846Z\", \"timetz_value\": \"18:18:18+00\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\nresponse = client.post('/test', headers=headers, data=data)\nassert response.status_code == 201\nresponse_data = response.json()\ndict_data = json.loads(data)\nsample_primary_key = response_data['primary_key']\n'''\n{\n  \"primary_key\": 1013,\n  \"interval_value\": 0, <- querying not supported\n  \"json_value\": {},<- querying not supported\n  \"jsonb_value\": {},<- querying not supported\n  \n  \"array_value\": [\n    0\n  ],\n  \"array_str__value\": [\n    \"string\"\n  ]\n}\n'''\n# try find the data by primary key\ndef test_get_by_primary_key_without_any_query_param():\n    response = client.get(f'/test/{sample_primary_key}', headers=headers)\n    assert response.status_code == 200\n    assert response.json()['primary_key'] == sample_primary_key\n\n\n#   \"bool_value\": true\n# try find the data by primary key but false by bool\ndef test_get_by_primary_key_with_false_bool_query_param():\n\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=false', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?bool_value____list=true', headers=headers)\n    assert response.status_code == 200\n#   \"char_value\": \"string    \",\n# try find the data by primary key but false by char\ndef test_get_by_primary_key_with_false_char_query_param():\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string1&char_value____list=string2',\n                          headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?char_value____list=string&char_value____list=string1&',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tRi%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string1&char_value____str=%tsri%&char_value____str_____matching_pattern=case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string2&char_value____str=%strg%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%strin%&char_value____str_____matching_pattern=not_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=String2&char_value____str=%Strg%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=STRING%&char_value____str=%TRI%&char_value____str_____matching_pattern=not_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=strI.*&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stG.*&char_value____str=STG&char_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stri.*&varchar_value____stg=str&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=stg.*&char_value____str=stg&char_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive',\n        headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string&char_value____str=%(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 200\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=string%&char_value____str=%(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 404\n    response = client.get(\n        f'/test/{sample_primary_key}?char_value____str=str&char_value____str=(r|z)%&char_value____str_____matching_pattern=not_similar_to',\n        headers=headers)\n    assert response.status_code == 200\n#   \"float4_value\": 0,\n# try find the data by primary key but false by float4\ndef test_get_by_primary_key_with_false_float4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float4_value____from=-2&float4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=0&float4_value____to=0&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=-1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than&float4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float4_value____from=1&float4_value____to=2&float4_value____from_____comparison_operator=Greater_than_or_equal_to&float4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n#   \"float8_value\": 0,\n# try find the data by primary key but false by float8\ndef test_get_by_primary_key_with_false_float8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??float8_value____from=-2&float8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=0&float8_value____to=0&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=-1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than&float8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?float8_value____from=1&float8_value____to=2&float8_value____from_____comparison_operator=Greater_than_or_equal_to&float8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int2\n# int2 0\ndef test_get_by_primary_key_with_false_int2_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int2_value____from=-2&int2_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=0&int2_value____to=0&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=-1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than&int2_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int2_value____from=1&int2_value____to=2&int2_value____from_____comparison_operator=Greater_than_or_equal_to&int2_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int4\n# int 4 0\ndef test_get_by_primary_key_with_false_int4_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int4_value____from=-2&int4_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=0&int4_value____to=0&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=-1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than&int4_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int4_value____from=1&int4_value____to=2&int4_value____from_____comparison_operator=Greater_than_or_equal_to&int4_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by int8\n# int 8 0\ndef test_get_by_primary_key_with_false_int8_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??int8_value____from=-2&int8_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=0&int8_value____to=0&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=-1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than&int8_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?int8_value____from=1&int8_value____to=2&int8_value____from_____comparison_operator=Greater_than_or_equal_to&int8_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by numeric\n\n# numeric 0\ndef test_get_by_primary_key_with_false_numeric_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=1', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=-1', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n    response = client.get(f'/test/{sample_primary_key}??numeric_value____from=-2&numeric_value____to=-1',\n                          headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____to=0', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0',\n                          headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=0&numeric_value____to=0&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=-1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than&numeric_value____to_____comparison_operator=Less_than',\n        headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(\n        f'/test/{sample_primary_key}?numeric_value____from=1&numeric_value____to=2&numeric_value____from_____comparison_operator=Greater_than_or_equal_to&numeric_value____to_____comparison_operator=Less_than_or_equal_to',\n        headers=headers)\n    assert response.status_code == 404\n# try find the data by primary key but false by text\n#  \"text_value\": \"string\",\ndef test_get_by_primary_key_with_false_text_query_param():\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string1&text_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____list=string&text_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tRi%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string1&text_value____str=%tsri%&text_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string2&text_value____str=%strg%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%strin%&text_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=String2&text_value____str=%Strg%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=STRING&text_value____str=%TRI%&text_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=strI.*&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stG.*&text_value____str=STG&text_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stri.*&varchar_value____stg=str&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=stg.*&text_value____str=stg&text_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=string&text_value____str=%(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?text_value____str=str&text_value____str=(r|z)%&text_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 200\n# try find the data by primary key but false by uuid\ndef test_get_by_primary_key_with_false_uuid_query_param():\n    # In operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6', headers=headers)\n    assert response.status_code == 404\n    # not In operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_in', headers=headers)\n    assert response.status_code == 200\n\n\n    # Equal operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Equal', headers=headers)\n    assert response.status_code == 404\n    # not Equal operator\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afa9&uuid_value____list=3fa85f64-5717-4562-b3fc-2c963f66afb6&uuid_value____list_____comparison_operator=Not_equal', headers=headers)\n    assert response.status_code == 200\n# try find the data by primary key but false by varchar\ndef test_get_by_primary_key_with_false_varchar_query_param():\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string1&varchar_value____list=string2', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____list=string&varchar_value____list=string1&', headers=headers)\n    assert response.status_code == 200\n\n    # Like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_sensitive', headers=headers)\n    assert response.status_code == 404\n\n    # Ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tRi%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string1&varchar_value____str=%tsri%&varchar_value____str_____matching_pattern=case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # not like operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string2&varchar_value____str=%strg%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%strin%&varchar_value____str_____matching_pattern=not_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # not ilike operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=String2&varchar_value____str=%Strg%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=STRING&varchar_value____str=%TRI%&varchar_value____str_____matching_pattern=not_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    # match regex with case insensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    # does_not_match_regex_with_case_insensitive\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=strI.*&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stG.*&varchar_value____str=STG&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_insensitive', headers=headers)\n    assert response.status_code == 200\n    # dose not match regex with case sensitive operator\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stri.*&varchar_value____stg=str&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=stg.*&varchar_value____str=stg&varchar_value____str_____matching_pattern=does_not_match_regex_with_case_sensitive', headers=headers)\n    assert response.status_code == 200\n    # similar_to\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 200\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=similar_to', headers=headers)\n    assert response.status_code == 404\n    # not_similar_to\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=string&varchar_value____str=%(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 404\n    response = client.get(f'/test/{sample_primary_key}?varchar_value____str=str&varchar_value____str=(r|z)%&varchar_value____str_____matching_pattern=not_similar_to', headers=headers)\n    assert response.status_code == 200\n# query by range of date field\ndef test_get_by_primary_key_with_false_date_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}??date_value____from=2021-07-21&date_value____to=2021-07-24', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-24&date_value____to=2021-07-27', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-25&date_value____to=2021-07-27&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-26&date_value____to=2021-07-26&date_value____from_____comparison_operator=Greater_than&date_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?date_value____from=2021-07-27&date_value____to=2021-07-29&date_value____from_____comparison_operator=Greater_than_or_equal_to&date_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_time_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=17:18:18', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=10:18:18&time_value____to=19:18:18', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:17&time_value____to=18:18:19&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=18:18:18&time_value____to=18:18:18&time_value____from_____comparison_operator=Greater_than&time_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?time_value____from=19:18:18&time_value____to=19:19:18&time_value____from_____comparison_operator=Greater_than_or_equal_to&time_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamp_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-27T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-20T02:17:46.846000&timestamp_value____to=2021-07-25T02:17:46.846000', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-24T02:17:46.846000&timestamp_value____to=2021-07-28T02:17:46.846000', headers=headers)\n    assert response.status_code == 200\n\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.846&timestampt_value____from_____comparison_operator=Greater_than_or_equal_to&timestampt_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.746&timestamp_value____to=2021-07-26T02:17:46.946&timestampt_value____from_____comparison_operator=Greater_than&timestampt_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.846&timestamp_value____to=2021-07-26T02:17:46.946&timestamp_value____from_____comparison_operator=Greater_than&timestamp_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamp_value____from=2021-07-26T02:17:46.856&timestamp_value____to=2021-07-26T02:17:46.986&timestamp_value____from_____comparison_operator=Greater_than_or_equal_to&timestamp_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timetz_range_query_param():\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=17%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from=16%3A18%3A18%2B00%3A00&timetz_value____to=19%3A18%3A18%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=17%3A18%3A18%2B00&timetz_value____to=19%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=18%3A18%3A18%2B00&timetz_value____to=18%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than&timetz_value____to_____comparison_operator=Less_than&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=18%3A18%3A18%2B00', headers=headers)\n    assert response.status_code == 404\n    # failure from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timetz_value____from_____comparison_operator=Greater_than_or_equal_to&timetz_value____to_____comparison_operator=Less_than_or_equal_to&timetz_value____from=16%3A18%3A18%2B00&timetz_value____to=17%3A19%3A18%2B00', headers=headers)\n    assert response.status_code == 404\ndef test_get_by_primary_key_with_false_timestamptz_range_query_param():\n    #   \"timestamp_value\": \"2021-07-26T02:17:46.846000\",\n\n    # from\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-25T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # from - to\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-27T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-28T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 404\n\n    # success from\n\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n    # success to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____to=2021-07-29T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n    # success from - to\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-20T02%3A17%3A46.846000%2B00%3A00&timestamptz_value____to=2021-07-27T02%3A17%3A46.846000%2B00%3A00', headers=headers)\n    assert response.status_code == 200\n\n\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 200\n    # success from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.800Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 200\n\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.846Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.900Z&timestamptz_value____from_____comparison_operator=Greater_than&timestamptz_value____to_____comparison_operator=Less_than', headers=headers)\n    assert response.status_code == 404\n    # failed from - to with special operator\n    response = client.get(f'/test/{sample_primary_key}?timestamptz_value____from=2021-07-26T02%3A17%3A46.847Z&timestamptz_value____to=2021-07-26T02%3A17%3A46.946Z&timestamptz_value____from_____comparison_operator=Greater_than_or_equal_to&timestamptz_value____to_____comparison_operator=Less_than_or_equal_to', headers=headers)\n    assert response.status_code == 404\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_other_default_value.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, Table\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\n\nUUIDTable = Table(\n    'test_default_value', metadata,\n    Column('primary_key', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, default=False),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value')\n)\n\ndef setup_module(module):\n\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, {  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{  \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = { \"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\":False,\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data[\"bool_value\"] = False\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = False\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": True, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    update_data['bool_value'] = True\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{ \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       { \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": False,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    response_data['bool_value'] = False\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784 ,\"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef teardown_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.drop_all)\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_other_no_alias.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, Table,String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.ext.asyncio import AsyncSession, create_async_engine\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\nUUIDTable = Table(\n    'test_no_alias', metadata,\n    Column('id', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('id', 'int4_value', 'float4_value')\n)\n\ndef setup_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              async_mode=True,\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_other_single_unique.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger,Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.ext.asyncio import AsyncSession, create_async_engine\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\nUUIDTable = Table(\n    'test_single_unique_table', metadata,\n    Column('id', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False,unique=True),\n    Column('float8_value', Float(53), nullable=True, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=True),\n    Column('int4_value', Integer, nullable=True),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n)\n\ndef setup_module(module):\n\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              async_mode=True,\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.443}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['id']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('id')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0.12, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 1.2, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 9.3, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0.98}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['id']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 12.7,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.5,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.6,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 3.7,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 200,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=3.5&float4_value____list=3.6&float4_value____list=3.7'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.58,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    # FIXME: update the unique column will conflict, it may not a issue, because it should input all columns, you can use the patch\n    assert response.status_code == 409\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 5.78,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 5.78,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 1.70,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.91,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.92,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.93,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.91&float4_value____list=0.92&float4_value____list=0.93'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 2.54,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['id'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float4_value____list\": 2.54,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.875,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.876,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0.877,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['id'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 500,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&id____list={primary_key_list[0]}&id____list={primary_key_list[1]}&id____list={primary_key_list[2]}&float4_value____list=0.875&float4_value____list=0.876&&float4_value____list=0.877'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 55.7\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'id' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 12.784}'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n\n\ndef teardown_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.drop_all)\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_other_uuid_primary.py",
    "content": "import asyncio\nimport json\nimport os\nimport uuid\nfrom copy import deepcopy\nfrom datetime import datetime, timezone, date, timedelta\nfrom http import HTTPStatus\nfrom urllib.parse import urlencode\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Table,Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\nfrom src.fastapi_quickcrud.misc.type import CrudMethods\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nfrom sqlalchemy.ext.asyncio import AsyncSession, create_async_engine\nengine = create_async_engine(TEST_DATABASE_URL,\n                             future=True,\n                             echo=True,\n                             pool_use_lifo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False,\n                             autoflush=False,\n                             bind=engine,\n                             class_=AsyncSession)\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        yield session\n\n\n\nUUIDTable = Table(\n    'test_uuid_primary', metadata,\n    Column('primary_key', UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\")),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float(53), nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value')\n)\n\ndef setup_module(module):\n    async def create_table():\n        async with engine.begin() as conn:\n            await conn.run_sync(Base.metadata.create_all)\n\n\n    loop = asyncio.get_event_loop()\n    loop.run_until_complete(create_table())\n\nroute_1 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.FIND_MANY,\n                                  CrudMethods.UPSERT_MANY,\n                                  CrudMethods.UPDATE_ONE,\n                                  CrudMethods.UPDATE_MANY,\n                                  CrudMethods.PATCH_MANY,\n                                  CrudMethods.PATCH_ONE,\n                                  CrudMethods.DELETE_MANY,\n                                  CrudMethods.DELETE_ONE,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test\",\n                              tags=[\"test\"]\n                              )\n\n\nroute_2 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.UPSERT_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              prefix=\"/test_2\",\n                              async_mode=True,\n                              tags=[\"test\"]\n                              )\n\n\nroute_3 = crud_router_builder(db_session=get_transaction_session,\n                              db_model=UUIDTable,\n                              crud_methods=[\n                                  CrudMethods.FIND_ONE,\n                                  CrudMethods.POST_REDIRECT_GET,\n                              ],\n                              exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                              async_mode=True,\n                              prefix=\"/test_3\",\n                              tags=[\"test\"]\n                              )\n\n\n[app.include_router(i) for i in [route_1, route_2, route_3]]\n\nclient = TestClient(app)\n\n\ndef test_get_one_data_and_create_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    find_target = create_response['primary_key']\n    response = client.get(f'/test/{find_target}', headers=headers, data=data)\n    assert response.status_code == 200\n    assert response.json() == create_response\n    create_response.pop('primary_key')\n    query_param = urlencode(create_response)\n    response = client.get(f'/test/{find_target}?{query_param}', headers=headers, data=data)\n    assert response.status_code == 200\n\n\ndef test_get_many_data_and_create_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = '''{ \"insert\": [ { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\",\"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }, { \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] },{ \"bool_value\": true, \"char_value\": \"string    \", \"date_value\": \"2021-07-23\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-23T02:38:24.963000\", \"timestamptz_value\": \"2021-07-23T02:38:24.963000+00:00\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] } ] }'''\n    data_dict = json.loads(data)['insert']\n    response = client.post('/test', headers=headers, data=data)\n    assert response.status_code == 201\n    response_result = response.json()\n    for index, value in enumerate(data_dict):\n        res_result_by_index = response_result[index]\n        for k, v in value.items():\n            assert res_result_by_index[k] == v\n\n\ndef test_update_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 0 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    created_primary_key = create_response['primary_key']\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    query_param = urlencode(update_data)\n    response = client.put(f'/test/{created_primary_key}?{query_param}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_update_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)+f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            assert k[i] == update_data[i]\n\n\ndef test_patch_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(params)\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(params)\n    update_data = {\"date_value\": \"2022-07-24\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(params)\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n\n\ndef test_patch_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_delete_one_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285\",\n         \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i['primary_key'] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(params)\n    response = client.delete(f'/test/{primary_key}?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '1'\n\n\ndef test_delete_many_data():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                         \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i['primary_key'] for i in insert_response_data]\n    params = {\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(\n        params) + f'&primary_key____list={primary_key_list[0]}&primary_key____list={primary_key_list[1]}&primary_key____list={primary_key_list[2]}'\n\n    response = client.delete(f'/test?{query_string}')\n    assert response.status_code == 200\n    assert response.headers['x-total-count'] == '3'\n\n\ndef test_post_redirect_get_data():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_3', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert 'primary_key' in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\n\ndef test_upsert_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n    data = '{\"float4_value\": 0, \"int2_value\": 0, \"int4_value\": 10 }'\n    response = client.post('/test_2', headers=headers, data=data)\n    assert response.status_code == 201\n    create_response = response.json()\n    updated_data = {}\n    for k,v in create_response.items():\n        if k not in data:\n            updated_data[k] = v\n    updated_data['numeric_value'] = 100\n    # conflict\n    upsert_data = deepcopy(updated_data)\n    upsert_data['on_conflict'] = {'update_columns':['numeric_value']}\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(upsert_data, **json.loads(data))))\n    assert response.status_code == 201\n\n    # create\n    response = client.post('/test_2', headers=headers, data=json.dumps(dict(updated_data, **json.loads(data))))\n    assert response.status_code == 409\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_patch_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      async_mode=True,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"],\n                                    async_mode=True,\n                                    )\n\ntest_patch_data = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.PATCH_MANY\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test_patch_many\",\n                                      tags=[\"test\"]\n                                      )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_patch_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_many_and_patch_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\",\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_many?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_patch_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_many_model = api_model[CrudMethods.UPSERT_MANY].__dict__\n# assert create_many_model['requestModel'] or create_many_model['responseModel']\n# create_many_request_model = deepcopy(create_many_model['requestModel'].__dict__['__fields__'])\n# create_many_response_model = deepcopy(create_many_model['responseModel'].__dict__['__fields__'])\n#\n# # Request Model Test\n# assert create_many_request_model.pop('on_conflict', None)\n# insert_many_model = create_many_request_model['insert'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in insert_many_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n#\n# # Response Model Test\n# for k, v in create_many_response_model.items():\n#     create_many_response_model_item = v.type_.__dict__['__fields__']\n#     for k, v in create_many_response_model_item.items():\n#         sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#         if sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#             assert not v.required\n#         elif sql_schema.nullable:\n#             assert not v.required\n#         elif not sql_schema.nullable:\n#             assert v.required\n#         elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#             assert v.required\n#         else:\n#             print(f\"{v.name=}\")\n#             print(f\"{v.required=}\")\n#             print(f\"{v.default=}\")\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       async_mode=True,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n# Response Mode Test\n# response_many = create_many_response_model['__root__'].sub_fields[0].outer_type_.__dict__['__fields__']\n# for k, v in response_many.items():\n#     assert not v.required\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# post_redirect_get_model = api_model[CrudMethods.POST_REDIRECT_GET].__dict__\n# assert post_redirect_get_model['requestModel'] or post_redirect_get_model['responseModel']\n# post_redirect_get_request_model = deepcopy(post_redirect_get_model['requestModel'].__dict__['__fields__'])\n# post_redirect_get_response_model = deepcopy(post_redirect_get_model['responseModel'].__dict__['__fields__'])\n\n# Request Model Test\n\n# for k, v in post_redirect_get_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Model Test\n# for k, v in post_redirect_get_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# for k, v in post_redirect_get_response_model.items():\n#     assert v.required\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 async_mode=True,\n                                                 prefix=\"/test_post_direct_get\",\n                                                 tags=[\"test\"]\n                                                 )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    async_mode=True,\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.PATCH_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       async_mode=True,\n                                       prefix=\"/test_patch_one\",\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_patch_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['bool_value____list'] = False\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"char_value\": \"string_u  \"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['char_value____str'] = \"string_u  \"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"date_value\": \"2022-07-24\"}\n    # update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n    #                \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n    #                \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n    #                \"text_value\": \"string_update\",\n    #                \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n    #                \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n    #                \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n    #                \"array_value\": [1, 2, 3, 4, 5],\n    #                \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n    params['date_value____from'] = \"2022-07-23\"\n    params['date_value____to'] = \"2022-07-25\"\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.patch(f'/test_patch_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_post_redirect_get_api.py",
    "content": "import json\nimport uuid\nfrom datetime import date, timedelta, datetime, timezone\nfrom http import HTTPStatus\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\n# # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test_post_direct_get\",\n                                    async_mode=True,\n                                    tags=[\"test\"]\n                                    )\n\n\ntest_post_and_redirect_get_without_get = crud_router_builder(db_session=get_transaction_session,\n                                                             db_model=UntitledTable256,\n                                                             crud_methods=[\n                                                                 CrudMethods.POST_REDIRECT_GET\n                                                             ],\n                                                             exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                             prefix=\"/test_post_direct_get_without_get\",\n                                                             async_mode=True,\n                                                             tags=[\"test\"]\n                                                             )\n[app.include_router(i) for i in [test_post_and_redirect_get, test_get_data,test_post_and_redirect_get_without_get]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\n# Post Redirect Get API Test\n\ndef test_create_one_but_no_follow_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    data = '{ \"bool_value\": true, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0, \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0, \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\", \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ], \"array_str__value\": [ \"string\" ] }'\n\n    response = client.post('/test_post_direct_get', headers=headers, data=data, allow_redirects=False)\n    assert response.status_code == HTTPStatus.SEE_OTHER\n\n\ndef test_create_one_with_redirect():\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data_ = json.dumps(change)\n    response = client.post('/test_post_direct_get', headers=headers, data=data_, allow_redirects=True)\n    assert response.status_code == HTTPStatus.OK\n    response_data = response.json()\n    assert primary_key_name in response_data\n    for k, v in response_data.items():\n        if k in change:\n            if isinstance(v, str):\n                v = v.strip()\n            response_ = json.dumps(v).strip()\n            request_ = json.dumps(change[k]).strip()\n            assert request_ == response_\n    return response_data\n\n\ndef test_create_but_conflict():\n    data = test_create_one_with_redirect()\n\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get', headers=headers, data=json.dumps(data), allow_redirects=True)\n    assert response.status_code == HTTPStatus.CONFLICT\n\n\ndef test_create_but_not_found_get_api():\n    change = {}\n\n    bool_value_change = False\n    char_value_change = \"test\"\n    date_value_change = str(date.today() - timedelta(days=1))\n    float8_value_change = 0.1\n    int2_value_change = 100\n    int8_value_change = 100\n    interval_value_change = float(5400)\n    json_value_change = {\"hello\": \"world\"}\n    jsonb_value_change = {\"hello\": \"world\"}\n    numeric_value_change = 19\n    text_value_change = 'hello world'\n    time_value_change = '18:18:18'\n    timestamp_value_change = str(datetime.utcnow().isoformat())\n    timestamptz_value_change = str(datetime.utcnow().replace(tzinfo=timezone.utc).isoformat())\n    timetz_value_change = '18:18:18+00:00'\n    uuid_value_change = str(uuid.uuid4())\n    varchar_value_change = 'hello world'\n    array_value_change = [1, 2, 3, 4]\n    array_str__value_change = ['1', '2', '3', '4']\n\n    change['bool_value'] = bool_value_change\n    change['char_value'] = char_value_change\n    change['date_value'] = date_value_change\n    change['float8_value'] = float8_value_change\n    change['int2_value'] = int2_value_change\n    change['int8_value'] = int8_value_change\n    change['float4_value'] = 0.4\n    change['int4_value'] = 4\n    change['interval_value'] = interval_value_change\n    change['json_value'] = json_value_change\n    change['jsonb_value'] = jsonb_value_change\n    change['numeric_value'] = numeric_value_change\n    change['text_value'] = text_value_change\n    change['time_value'] = time_value_change\n    change['timestamp_value'] = timestamp_value_change\n    change['timestamptz_value'] = timestamptz_value_change\n    change['timetz_value'] = timetz_value_change\n    change['uuid_value'] = uuid_value_change\n    change['varchar_value'] = varchar_value_change\n    change['array_value'] = array_value_change\n    change['array_str__value'] = array_str__value_change\n    data = json.dumps(change)\n    headers = {\n        'accept': '*/*',\n        'Content-Type': 'application/json',\n    }\n\n    response = client.post('/test_post_direct_get_without_get', headers=headers, data=data, allow_redirects=True)\n    assert response.status_code == HTTPStatus.NOT_FOUND\n\n\n\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_put_many_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n# Model Test\n# api_model = UntitledTable256Model.__dict__['POST']\n# assert api_model\n# create_one_model = api_model[CrudMethods.UPSERT_ONE].__dict__\n# assert create_one_model['requestModel'] or create_one_model['responseModel']\n# create_one_request_model = deepcopy(create_one_model['requestModel'].__dict__['__fields__'])\n# create_one_response_model = deepcopy(create_one_model['responseModel'].__dict__['__fields__'])\n# Request Test\n# assert create_one_request_model.pop('on_conflict', False)\n# for k, v in create_one_request_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\n# Response Test\n# for k, v in create_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      async_mode=True,\n                                      prefix=\"/test_creation_one\",\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       async_mode=True,\n                                       prefix=\"/test_creation_many\",\n                                       tags=[\"test\"]\n                                       )\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    async_mode=True,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPDATE_MANY\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_update_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_many_and_update_many():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [{\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0],\n                        \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"time_value\": \"18:18:18\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert len(response_data) == 3\n    for k in response_data:\n        for i in update_data:\n            print(i)\n            print(k[i])\n            assert k[i] == update_data[i]\n\n\ndef test_create_many_and_update_many_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = { \"insert\": [ { \"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                           \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                           \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                           \"timestamp_value\": \"2021-07-24T02:54:53.285\", \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\", \"array_value\": [ 0 ],\n                           \"array_str__value\": [ \"string\" ], \"time_value\": \"18:18:18\" , \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\", \"time_value\": \"18:18:18\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"timetz_value\": \"18:18:18+00:00\"},\n\n                         {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                          \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                          \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                          \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                          \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                          \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                          \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\", \"timetz_value\": \"18:18:18+00:00\"},\n                         ] }\n\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key_list = [i[primary_key_name] for i in insert_response_data]\n    min_key = min(primary_key_list)\n    max_key = max(primary_key_list)\n    params = {\"primary_key____from\": min_key,\n              \"primary_key____to\": max_key,\n              \"bool_value____list\":True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"timez_value____from\": '18:18:18+00:00',\n              \"timez_value____to\": '18:18:18+00:00',\n              \"timez_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = { \"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                           \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                           \"json_value\": {'test':'hello'}, \"jsonb_value\": {'test':'hello'}, \"numeric_value\": 10, \"text_value\": \"string_update\",\n                           \"timestamp_value\": \"2022-07-24T02:54:53.285000\", \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                           \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\", \"array_value\": [ 1,2,3,4,5 ],\n                           \"array_str__value\": [ \"test\" ], \"time_value\": \"18:19:18\" , \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_many?{query_string}', data= json.dumps(update_data))\n    # response_data = response.json()\n    # assert len(response_data) == 3\n    # for k in response_data:\n    #     for i in update_data:\n    #         print(i)\n    #         print(k[i])\n    #         assert k[i] == update_data[i]\n    assert  response.status_code == 204"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/api_test_async/test_put_one_api.py",
    "content": "import json\nfrom collections import OrderedDict\n\nfrom starlette.testclient import TestClient\n\nfrom src.fastapi_quickcrud import CrudMethods\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom tests.test_implementations.test_sqlalchemy_table.api_test_async import get_transaction_session, app, \\\n    UntitledTable256\n\n\ntest_create_one = crud_router_builder(db_session=get_transaction_session,\n                                      db_model=UntitledTable256,\n                                      crud_methods=[\n                                          CrudMethods.UPSERT_ONE\n                                      ],\n                                      exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                      prefix=\"/test_creation_one\",\n                                      async_mode=True,\n                                      tags=[\"test\"]\n                                      )\n\ntest_create_many = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPSERT_MANY,\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_creation_many\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n\n\n\ntest_post_and_redirect_get = crud_router_builder(db_session=get_transaction_session,\n                                                 db_model=UntitledTable256,\n                                                 crud_methods=[\n                                                     CrudMethods.POST_REDIRECT_GET\n                                                 ],\n                                                 exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                                 prefix=\"/test_post_direct_get\",\n                                                 async_mode=True,\n                                                 tags=[\"test\"]\n                                                 )\n\n# # # Model Test\n# api_model = UntitledTable256Model.__dict__['GET']\n# assert api_model\n# get_one_model = api_model[CrudMethods.FIND_ONE].__dict__\n# assert get_one_model['requestModel'] or get_one_model['responseModel']\n# get_one_request_model = deepcopy(get_one_model['requestModel'].__dict__['__fields__'])\n# get_one_response_model = deepcopy(get_one_model['responseModel'].__dict__['__fields__'])\n# primary_key_of_get_sql_schema = get_one_request_model[UntitledTable256.__dict__['primary_key_of_table']]\n# assert not primary_key_of_get_sql_schema.required\n# get_one_request_model.pop(UntitledTable256.__dict__['primary_key_of_table'], None)\n# for k, v in get_one_request_model.items():\n#     assert not v.required\n# # FIXME some thing may not require\n# for k, v in get_one_response_model.items():\n#     sql_schema = UntitledTable256.__dict__[v.name].comparator\n#\n#     if sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif not sql_schema.nullable and sql_schema.server_default or sql_schema.default:\n#         assert not v.required\n#     elif sql_schema.nullable:\n#         assert not v.required\n#     elif not sql_schema.nullable:\n#         assert v.required\n#     elif not sql_schema.nullable and not sql_schema.server_default or not sql_schema.default:\n#         assert v.required\n#     else:\n#         print(f\"{v.name=}\")\n#         print(f\"{v.required=}\")\n#         print(f\"{v.default=}\")\ntest_get_data = crud_router_builder(db_session=get_transaction_session,\n                                    db_model=UntitledTable256,\n                                    async_mode=True,\n                                    crud_methods=[\n                                        CrudMethods.FIND_ONE\n                                    ],\n                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                    prefix=\"/test\",\n                                    tags=[\"test\"]\n                                    )\n\ntest_update_data = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=UntitledTable256,\n                                       crud_methods=[\n                                           CrudMethods.UPDATE_ONE\n                                       ],\n                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n                                       prefix=\"/test_update_one\",\n                                       async_mode=True,\n                                       tags=[\"test\"]\n                                       )\n[app.include_router(i) for i in\n [test_post_and_redirect_get, test_update_data, test_create_one, test_create_many, test_get_data]]\n\nclient = TestClient(app)\n\nprimary_key_name = 'primary_key'\nunique_fields = ['primary_key', 'int4_value', 'float4_value']\n\n\ndef test_create_one_and_update_one():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n        {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n         \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n         \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n         \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n         \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n         \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n         \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n         \"timetz_value\": \"18:18:18+00:00\"},\n    ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key, = [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '18:18:18',\n              \"time_value____to\": '18:18:18',\n              \"time_value____list\": '18:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_value____from\": '18:18:18+00:00',\n              \"time_value____to\": '18:18:18+00:00',\n              \"time_value____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"\"\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    response_data = response.json()\n    assert response_data\n    for i in update_data:\n        print(i)\n        print(response_data[i])\n        assert response_data[i] == update_data[i]\n\n\ndef test_create_one_and_update_one_but_not_found():\n    headers = {\n        'accept': 'application/json',\n        'Content-Type': 'application/json',\n    }\n\n    data = {\"insert\": [\n                       {\"bool_value\": True, \"char_value\": \"string\", \"date_value\": \"2021-07-24\", \"float4_value\": 0,\n                        \"float8_value\": 0, \"int2_value\": 0, \"int4_value\": 0, \"int8_value\": 0, \"interval_value\": 0,\n                        \"json_value\": {}, \"jsonb_value\": {}, \"numeric_value\": 0, \"text_value\": \"string\",\n                        \"timestamp_value\": \"2021-07-24T02:54:53.285\",\n                        \"timestamptz_value\": \"2021-07-24T02:54:53.285Z\",\n                        \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\", \"varchar_value\": \"string\",\n                        \"array_value\": [0], \"array_str__value\": [\"string\"], \"time_value\": \"18:18:18\",\n                        \"timetz_value\": \"18:18:18+00:00\"},\n                       ]}\n\n    response = client.post('/test_creation_many', headers=headers, data=json.dumps(data))\n    assert response.status_code == 201\n    insert_response_data = response.json()\n\n    primary_key ,= [i[primary_key_name] for i in insert_response_data]\n    params = {\"bool_value____list\": True,\n              \"char_value____str\": 'string%',\n              \"char_value____str_____matching_pattern\": 'case_sensitive',\n              \"date_value____from\": \"2021-07-22\",\n              \"date_value____to\": \"2021-07-25\",\n              \"float4_value____from\": -1,\n              \"float4_value____to\": 2,\n              \"float4_value____list\": 0,\n              \"float8_value____from\": -1,\n              \"float8_value____to\": 2,\n              \"float8_value____list\": 0,\n              \"int2_value____from\": -1,\n              \"int2_value____to\": 9,\n              \"int2_value____list\": 0,\n              \"int4_value____from\": -1,\n              \"int4_value____to\": 9,\n              \"int4_value____list\": 0,\n              \"int8_value____from\": -1,\n              \"int8_value____to\": 9,\n              \"int8_value____list\": 0,\n              \"interval_value____from\": -1,\n              \"interval_value____to\": 9,\n              \"interval_value____list\": 0,\n              \"numeric_value____from\": -1,\n              \"numeric_value____to\": 9,\n              \"numeric_value____list\": 0,\n              \"text_value____list\": \"string\",\n              \"time_value____from\": '10:18:18',\n              \"time_value____to\": '12:18:18',\n              \"time_value____list\": '10:18:18',\n              \"timestamp_value_value____from\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____to\": \"2021-07-24T02:54:53.285\",\n              \"timestamp_value_value____list\": \"2021-07-24T02:54:53.285\",\n              \"timestamptz_value_value____from\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____to\": \"2021-07-24T02:54:53.285Z\",\n              \"timestamptz_value_value____list\": \"2021-07-24T02:54:53.285Z\",\n              \"uuid_value_value____list\": \"3fa85f64-5717-4562-b3fc-2c963f66afa6\",\n              \"time_valuez____from\": '18:18:18+00:00',\n              \"time_valuez____to\": '18:18:18+00:00',\n              \"time_valuez____list\": '18:18:18+00:00',\n              \"varchar_value____str\": 'string',\n              \"varchar_value____str_____matching_pattern\": 'case_sensitive',\n              \"varchar_value____list\": 'string',\n              }\n    from urllib.parse import urlencode\n    query_string = urlencode(OrderedDict(**params))\n    update_data = {\"bool_value\": False, \"char_value\": \"string_u  \", \"date_value\": \"2022-07-24\", \"float4_value\": 10.50,\n                   \"float8_value\": 10.5, \"int2_value\": 10, \"int4_value\": 10, \"int8_value\": 10, \"interval_value\": 3600,\n                   \"json_value\": {'test': 'hello'}, \"jsonb_value\": {'test': 'hello'}, \"numeric_value\": 10,\n                   \"text_value\": \"string_update\",\n                   \"timestamp_value\": \"2022-07-24T02:54:53.285000\",\n                   \"timestamptz_value\": \"2022-07-24T02:54:53.285000+00:00\",\n                   \"uuid_value\": \"3fa85f64-5717-4562-b3fc-2c963f66afb6\", \"varchar_value\": \"string\",\n                   \"array_value\": [1, 2, 3, 4, 5],\n                   \"array_str__value\": [\"test\"], \"time_value\": \"18:19:18\", \"timetz_value\": \"18:19:18+00:00\"}\n    response = client.put(f'/test_update_one/{primary_key}?{query_string}', data=json.dumps(update_data))\n    # response_data = response.json()\n    response.status_code = 404\n    # assert response_data\n    # for i in update_data:\n    #     assert response_data[i] == update_data[i]\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/__init__.py",
    "content": ""
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_create_null_type.py",
    "content": "import os\n\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint, \\\n    create_engine\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym, sessionmaker\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\n\n\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON,),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', None),\n\n)\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\ntry:\n\n    crud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                           db_model=UntitledTable256,\n                                           crud_methods=[\n                                               CrudMethods.PATCH_ONE,\n                                           ],\n                                           exclude_columns=['xml_value', 'box_valaue'],\n                                           prefix=\"/child\",\n                                           tags=[\"child\"]\n                                           )\nexcept BaseException as e:\n    assert 'not supported yet' in str(e)\n# except BaseException as e:\n#     print(str(e))"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_pk_no_default_value.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, text, PrimaryKeyConstraint, Table, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, ColumnTypeNotSupportedException, PrimaryMissing\n\nBase = declarative_base()\n\nmetadata = Base.metadata\n\n\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, nullable=False, primary_key=True, autoincrement=False),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON,),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', None),\n\n)\n\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.PATCH_ONE,\n                                                   ],\n                                                   exclude_columns=['xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    print(str(e))\n    assert 'The type of column array_str__value (NULL) not supported yet' in str(e)\n\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_composite_primary.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON, unique=True),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric, unique=True),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    PrimaryKeyConstraint('primary_key', 'int4_value', 'float4_value'),\n\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_more_than_one_pk.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean,primary_key=True,  nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary,primary_key=True, ),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON, unique=True),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric, unique=True),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    print(e)\n    'multiple primary key / or composite not supported;' in str(e)"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_more_than_one_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger,Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON, unique=True),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric, unique=True),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_unique_and_composite_unique.py",
    "content": "from sqlalchemy import ARRAY, BigInteger,Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL, unique=True),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                   crud_methods=[\n                                                       CrudMethods.UPSERT_MANY,\n                                                   ],\n                                                   exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept SchemaException as e:\n    str(e) == 'Only support one unique constraint/ Use unique constraint and composite unique constraint at same time is not supported / Use  composite unique constraint if there are more than one unique constraint'\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_unsupported_type.py",
    "content": "from sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud.misc.utils import table_to_declarative_base\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException, \\\n    ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', LargeBinary,nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n\n)\nUntitledTable256 = table_to_declarative_base(UntitledTable256)\ntry:\n    UntitledTable256Model = sqlalchemy_to_pydantic(UntitledTable256,\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_unsupported_type_2.py",
    "content": "import os\n\nfrom sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint, \\\n    create_engine\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException, \\\n    ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', INTERVAL,nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n\n)\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\ntry:\n\n    crud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                           db_model=UntitledTable256,\n                                           prefix=\"/child\",\n                                           tags=[\"child\"],\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_unsupported_type_3.py",
    "content": "import os\n\nfrom sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint, \\\n    create_engine\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException, \\\n    ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', JSON,nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n\n)\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\ntry:\n\n    crud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                           db_model=UntitledTable256,\n                                           prefix=\"/child\",\n                                           tags=[\"child\"],\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tests/test_implementations/test_sqlalchemy_table/error_test/test_use_unsupported_type_4.py",
    "content": "import os\n\nfrom sqlalchemy import ARRAY, BigInteger, Table, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text, PrimaryKeyConstraint, \\\n    create_engine\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic, CrudMethods, sqlalchemy_to_pydantic\nfrom src.fastapi_quickcrud.misc.exceptions import SchemaException, MultipleSingleUniqueNotSupportedException, \\\n    ColumnTypeNotSupportedException\n\nBase = declarative_base()\n\nmetadata = Base.metadata\nUntitledTable256 = Table(\n    'test_table', metadata,\n    Column('primary_key', JSONB,nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text, unique=True),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n\n)\n\nTEST_DATABASE_URL = os.environ.get('TEST_DATABASE_ASYNC_URL',\n                                   'postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres')\n\nengine = create_engine(TEST_DATABASE_URL, future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\ntry:\n\n    crud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                           db_model=UntitledTable256,\n                                           prefix=\"/child\",\n                                           tags=[\"child\"],\n                                                       crud_methods=[\n                                                           CrudMethods.UPSERT_MANY,\n                                                       ],\n                                                       exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\nexcept ColumnTypeNotSupportedException as e:\n    'not supported yet' in str(e)\n"
  },
  {
    "path": "tutorial/__init__.py",
    "content": "from collections import defaultdict\n\na = [\n    {\n        \"id\": 1,\n        \"id_foreign\": {\n            \"id\": 1,\n            \"parent_id\": 1\n        }\n    },\n    {\n        \"id\": 1,\n        \"id_foreign\": {\n            \"id\": 2,\n            \"parent_id\": 1\n        }\n    },\n    {\n        \"id\": 1,\n        \"id_foreign\": {\n            \"id\": 3,\n            \"parent_id\": 1\n        }\n    },\n    {\n        \"id\": 2,\n        \"id_foreign\": {\n            \"id\": 4,\n            \"parent_id\": 2\n        }\n    },\n    {\n        \"id\": 2,\n        \"id_foreign\": {\n            \"id\": 5,\n            \"parent_id\": 2\n        }\n    },\n    {\n        \"id\": 2,\n        \"id_foreign\": {\n            \"id\": 6,\n            \"parent_id\": 2\n        }\n    }\n]\n\n\nb = [\n    {\"id\": 1,\n     \"id_foreign\":[{\n             \"id\": 3,\n             \"parent_id\": 1\n         }, {\n             \"id\": 1,\n             \"parent_id\": 1\n         }, {\"id\": 2,\n             \"parent_id\": 1}\n         ],\n     },\n    {\"id\": 2,\n     \"id_foreign\": [{\n         \"id\": 4,\n         \"parent_id\": 2\n     }, {\n         \"id\": 5,\n         \"parent_id\": 2\n     }, {\n         \"id\": 6,\n         \"parent_id\": 2}\n        ]\n     }\n]\ntmp = defaultdict(list)\nprint(tmp)\nfrom itertools import groupby\ndef test(*args, **kwargs):\n    tmp = {}\n    for k, v in args[0].items():\n        if '_foreign' not in k:\n            tmp[k] = v\n    return tmp\n\nresponse_list = []\nfor key, group in groupby(a, test):\n    response = {}\n    for i in group:\n        for k , v in i.items():\n            if '_foreign' in k:\n                if k not in response:\n                    response[k] = [v]\n                else:\n                    response[k].append(v)\n        for response_ in response:\n            i.pop(response_, None)\n        result = i | response\n    response_list.append(result)\nprint()\n# result = []\n# for data_index in range(0, len(a)):\n#     for data_index_ in range(0, len(a)):\n#         foreign_ = {}\n#         non_foreign_ = {}\n#         for k, v in a[data_index].items():\n#             tmp = {}\n#             if '_foreign' in k:\n#                 foreign_[k] = v\n#             else:\n#                 non_foreign_[k] = v\n#\n#         foreign__ = {}\n#         non_foreign__ = {}\n#         for k, v in a[data_index_].items():\n#             tmp = {}\n#             if '_foreign' in k:\n#                 foreign__[k] = v\n#             else:\n#                 non_foreign__[k] = v\n#         if non_foreign_ == non_foreign__:\n#             print(data_index)\n#             print(data_index_)\n#         print('----')\n#     print('===')"
  },
  {
    "path": "tutorial/basic_usage/__init__.py",
    "content": ""
  },
  {
    "path": "tutorial/basic_usage/depencies_example_auth.py",
    "content": "from typing import Optional\n\nimport uvicorn\nfrom fastapi import FastAPI, Depends, Security, Request\nfrom fastapi.security import HTTPBearer, APIKeyHeader, APIKeyQuery\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import CrudMethods as CrudRouter\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import create_engine\n\nengine = create_engine('postgresql://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = async_session()\n        yield db\n    finally:\n        db.close()\n\n\nclass ExampleTable(Base):\n    __tablename__ = 'example_table'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n    id = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},\n                server_default=text(\"nextval('untitled_table_256_id_seq'::regclass)\"))\n    primary_key = synonym('id')\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, info={'alias_name': 'int4_alias'}, nullable=False)\n    int4_alias = synonym('int4_value')\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text, info={'alias_name': 'text_alias'})\n    text_alias = synonym('text_value')\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\ndef AuthenticationService(\n        auth_rest_url: str,\n        apikey_header_accept: str = \"x-api-key\",\n        apikey_query_accept: str = \"apikey\",\n):\n    jwt_bearer = HTTPBearer(auto_error=False)\n    apikey_header = APIKeyHeader(name=apikey_header_accept, auto_error=False)\n    apikey_query = APIKeyQuery(name=apikey_query_accept, auto_error=False)\n\n    async def security_schemes(\n            _jwt_bearer: Optional[str] = Security(jwt_bearer),\n            _apikey_header: Optional[str] = Security(apikey_header),\n            _apikey_query: Optional[str] = Security(apikey_query),\n    ):\n        \"\"\"\n        authentication dependencices for correct generating openapi by fastapi\n        \"\"\"\n\n    class AuthenticationServiceClass:\n        @staticmethod\n        def AuthRequest(request: Request, schemes=Depends(security_schemes)):\n            return request\n\n        @staticmethod\n        def auth_check(request: Request = Depends(security_schemes)):\n            ''' do your business logic'''\n            return True\n\n    return AuthenticationServiceClass\n\n\nauthentication = AuthenticationService(\n    auth_rest_url='0.0.0.0',\n    apikey_header_accept='x-api-key',\n    apikey_query_accept='api-key',\n)\ndependencies = [authentication.auth_check]\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nupsert_many_router = crud_router_builder(db_session=get_transaction_session,\n                                         crud_models=UntitledTable256Model,\n                                         db_model=ExampleTable,\n                                         prefix=\"/create_many\",\n                                         dependencies=dependencies,\n                                         tags=[\"test\"]\n                                         )\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\npost_redirect_get_router = crud_router_builder(db_session=get_transaction_session,\n                                               crud_models=UntitledTable256Model,\n                                               db_model=ExampleTable,\n                                               prefix=\"/post_redirect_get\",\n                                               dependencies=dependencies,\n                                               tags=[\"test\"]\n                                               )\n\nexample_table_full_api = sqlalchemy_to_pydantic(ExampleTable,\n                                                crud_methods=[\n                                                    CrudRouter.FIND_MANY,\n                                                    CrudRouter.FIND_ONE,\n                                                    CrudRouter.UPSERT_ONE,\n                                                    CrudRouter.UPDATE_MANY,\n                                                    CrudRouter.UPDATE_ONE,\n                                                    CrudRouter.DELETE_ONE,\n                                                    CrudRouter.DELETE_MANY,\n                                                    CrudRouter.PATCH_MANY,\n                                                    CrudRouter.PATCH_ONE,\n\n                                                ],\n                                                exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nexample_table_full_router = crud_router_builder(db_session=get_transaction_session,\n                                                crud_models=example_table_full_api,\n                                                db_model=ExampleTable,\n                                                dependencies=dependencies,\n                                                prefix=\"/test_CRUD\",\n                                                tags=[\"test\"]\n                                                )\n\nExampleTable.__table__.create(engine, checkfirst=True)\n[app.include_router(i) for i in [example_table_full_router, post_redirect_get_router, upsert_many_router]]\nuvicorn.run(app, host=\"0.0.0.0\", port=8001, debug=False)\n"
  },
  {
    "path": "tutorial/basic_usage/quick_usage_with_async_SQLALchemy_Base.py",
    "content": "from datetime import datetime, timezone\n\nimport uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import *\nfrom sqlalchemy.dialects.postgresql import *\nfrom sqlalchemy.orm import *\nfrom src.fastapi_quickcrud import CrudMethods as CrudRouter\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\n\n\nclass ExampleTable(Base):\n    __tablename__ = 'example_table'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n    id = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'}, autoincrement=True)\n    primary_key = synonym('id')\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, info={'alias_name': 'int4_alias'}, nullable=False)\n    int4_alias = synonym('int4_value')\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text, info={'alias_name': 'text_alias'})\n    text_alias = synonym('text_value')\n    time_value = Column(Time(False), default=datetime.now(timezone.utc).strftime('%H:%M:%S'))\n    timestamp_value = Column(DateTime(False), default=datetime.now())\n    timestamptz_value = Column(DateTime(True), default=datetime.now(timezone.utc))\n    timetz_value = Column(Time(True), default=datetime.now(timezone.utc).strftime('%H:%M:%S%z'))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nupsert_many_router = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=ExampleTable,\n                                         crud_models=UntitledTable256Model,\n                                         prefix=\"/create_many\",\n                                         async_mode=True,\n                                         tags=[\"test\"]\n                                         )\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.FIND_ONE,\n                                                   CrudRouter.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\npost_redirect_get_router = crud_router_builder(db_session=get_transaction_session,\n                                               db_model=ExampleTable,\n                                               crud_models=UntitledTable256Model,\n                                               prefix=\"/post_redirect_get\",\n                                               async_mode=True,\n                                               tags=[\"test\"]\n                                               )\n\nexample_table_full_api = sqlalchemy_to_pydantic(ExampleTable,\n                                                crud_methods=[\n                                                    CrudRouter.FIND_MANY,\n                                                    CrudRouter.UPSERT_ONE,\n                                                    CrudRouter.UPDATE_MANY,\n                                                    CrudRouter.UPDATE_ONE,\n                                                    CrudRouter.DELETE_ONE,\n                                                    CrudRouter.DELETE_MANY,\n                                                    CrudRouter.PATCH_MANY,\n                                                    CrudRouter.PATCH_ONE,\n\n                                                ],\n                                                exclude_columns=['array_str__value', 'bytea_value', 'xml_value',\n                                                                 'box_valaue'])\n\nexample_table_full_router = crud_router_builder(db_session=get_transaction_session,\n                                                db_model=ExampleTable,\n                                                crud_models=example_table_full_api,\n                                                async_mode=True,\n                                                prefix=\"/test_CRUD\",\n                                                tags=[\"test\"]\n                                                )\n\n\n# Base.metadata.create_all(engine)\n# unknown reason that will throw error when add the code following\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\n#\n[app.include_router(i) for i in [example_table_full_router, post_redirect_get_router, upsert_many_router]]\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/basic_usage/quick_usage_with_async_SQLALchemy_table.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom sqlalchemy.testing.schema import Table\n\nfrom fastapi_quickcrud.misc.utils import sqlalchemy_table_to_pydantic\nfrom src.fastapi_quickcrud import CrudMethods as CrudRouter\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\n\n\nExampleTable = Table(\n    'untitled_table_256', metadata,\n    Column('id', Integer, primary_key=True, nullable=False,autoincrement=True,info={'alias_name': 'primary_key'}),\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint('id', 'int4_value', 'float4_value'),\n)\n\n\nUntitledTable256Model = sqlalchemy_table_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nUntitledTable256Model = sqlalchemy_table_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nupsert_many_router = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=ExampleTable,\n                                         crud_models=UntitledTable256Model,\n                                         prefix=\"/create_many\",\n                                         async_mode=True,\n                                         tags=[\"test\"]\n                                         )\nUntitledTable256Model = sqlalchemy_table_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.POST_REDIRECT_GET,\n                                                   CrudRouter.FIND_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\npost_redirect_get_router = crud_router_builder(db_session=get_transaction_session,\n                                               db_model=ExampleTable,\n                                               crud_models=UntitledTable256Model,\n                                               prefix=\"/post_redirect_get\",\n                                               async_mode=True,\n                                               tags=[\"test\"]\n                                               )\n\nexample_table_full_api = sqlalchemy_table_to_pydantic(ExampleTable,\n                                                crud_methods=[\n                                                    CrudRouter.FIND_MANY,\n                                                    CrudRouter.UPSERT_ONE,\n                                                    CrudRouter.UPDATE_MANY,\n                                                    CrudRouter.UPDATE_ONE,\n                                                    CrudRouter.DELETE_ONE,\n                                                    CrudRouter.DELETE_MANY,\n                                                    CrudRouter.PATCH_MANY,\n                                                    CrudRouter.PATCH_ONE,\n\n                                                ],\n                                                exclude_columns=['array_str__value', 'bytea_value', 'xml_value',\n                                                                 'box_valaue'])\n\nexample_table_full_router = crud_router_builder(db_session=get_transaction_session,\n                                                db_model=ExampleTable,\n                                                crud_models=example_table_full_api,\n                                                async_mode=True,\n                                                prefix=\"/test_CRUD\",\n                                                tags=[\"test\"]\n                                                )\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n#\n# Base.metadata.create_all(engine)\n# unknown reason that will throw error when add the code following\n# async def create_table():\n#     async with engine.begin() as conn:\n#         await conn.run_sync(Base.metadata.create_all)\n#         print('created')\n#     print('done')\n#     return\n#\n# asyncio.run(create_table())\n# loop.stop()\n# loop.close()\n# print(loop.is_closed())\n[app.include_router(i) for i in [example_table_full_router, post_redirect_get_router, upsert_many_router]]\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/basic_usage/quick_usage_with_async_SQLALchemy_table_with_out_primary_key.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\nfrom sqlalchemy.testing.schema import Table\n\nfrom fastapi_quickcrud.misc.utils import sqlalchemy_table_to_pydantic\nfrom src.fastapi_quickcrud import CrudMethods as CrudRouter\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\n\n\nExampleTable = Table(\n    'untitled_table_256', metadata,\n    Column('bool_value', Boolean, nullable=False, server_default=text(\"false\")),\n    Column('bytea_value', LargeBinary),\n    Column('char_value', CHAR(10)),\n    Column('date_value', Date, server_default=text(\"now()\")),\n    Column('float4_value', Float, nullable=False),\n    Column('float8_value', Float(53), nullable=False, server_default=text(\"10.10\")),\n    Column('int2_value', SmallInteger, nullable=False),\n    Column('int4_value', Integer, nullable=False),\n    Column('int8_value', BigInteger, server_default=text(\"99\")),\n    Column('interval_value', INTERVAL),\n    Column('json_value', JSON),\n    Column('jsonb_value', JSONB(astext_type=Text())),\n    Column('numeric_value', Numeric),\n    Column('text_value', Text),\n    Column('time_value', Time),\n    Column('timestamp_value', DateTime),\n    Column('timestamptz_value', DateTime(True)),\n    Column('timetz_value', Time(True)),\n    Column('uuid_value', UUID),\n    Column('varchar_value', String),\n    Column('array_value', ARRAY(Integer())),\n    Column('array_str__value', ARRAY(String())),\n    UniqueConstraint( 'int4_value', 'float4_value'),\n)\n\n\nUntitledTable256Model = sqlalchemy_table_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nUntitledTable256Model = sqlalchemy_table_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nupsert_many_router = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=ExampleTable,\n                                         crud_models=UntitledTable256Model,\n                                         prefix=\"/create_many\",\n                                         async_mode=True,\n                                         tags=[\"test\"]\n                                         )\n\nexample_table_full_api = sqlalchemy_table_to_pydantic(ExampleTable,\n                                                crud_methods=[\n                                                    CrudRouter.FIND_MANY,\n                                                    CrudRouter.UPSERT_ONE,\n                                                    CrudRouter.UPDATE_MANY,\n                                                    CrudRouter.DELETE_MANY,\n                                                    CrudRouter.PATCH_MANY,\n\n                                                ],\n                                                exclude_columns=['array_str__value', 'bytea_value', 'xml_value',\n                                                                 'box_valaue'])\n\nexample_table_full_router = crud_router_builder(db_session=get_transaction_session,\n                                                db_model=ExampleTable,\n                                                crud_models=example_table_full_api,\n                                                async_mode=True,\n                                                prefix=\"/test_CRUD\",\n                                                tags=[\"test\"]\n                                                )\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n[app.include_router(i) for i in [example_table_full_router, upsert_many_router]]\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/basic_usage/quick_usage_with_sync_SQLAlchemy_Base.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Text, Time, UniqueConstraint, text\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, UUID\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import sessionmaker, synonym\n\nfrom src.fastapi_quickcrud import CrudMethods as CrudRouter\nfrom src.fastapi_quickcrud import crud_router_builder\nfrom src.fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nengine = create_engine('postgresql://root@127.0.0.1:5432/postgres', future=True, echo=True,\n                       pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nsync_session = sessionmaker(autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = sync_session()\n        yield db\n        db.commit()\n    except Exception as e:\n        db.rollback()\n        raise e\n    finally:\n        db.close()\n\n\nclass ExampleTable(Base):\n    __tablename__ = 'untitled_table_256'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n    id = Column(Integer, primary_key=True, info={'alias_name': 'primary_key'},autoincrement=True)\n    primary_key = synonym('id')\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), info={'alias_name': 'float8_alias'}, nullable=False, server_default=text(\"10.10\"))\n    float8_alias = synonym('float8_value')\n\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, info={'alias_name': 'int4_alias'}, nullable=False)\n    int4_alias = synonym('int4_value')\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text, info={'alias_name': 'text_alias'})\n    text_alias = synonym('text_value')\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID(as_uuid=True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_ONE\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[\n                                                   CrudRouter.UPSERT_MANY\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\nupsert_many_router = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=ExampleTable,\n                                         crud_models=UntitledTable256Model,\n                                         prefix=\"/create_many\",\n                                         tags=[\"test\"]\n                                         )\nUntitledTable256Model = sqlalchemy_to_pydantic(ExampleTable,\n                                               crud_methods=[  # CrudRouter.FIND_ONE,\n                                                   # CrudRouter.FIND_ONE,\n                                                   CrudRouter.POST_REDIRECT_GET\n                                               ],\n                                               exclude_columns=['bytea_value', 'xml_value', 'box_valaue'])\n\npost_redirect_get_router = crud_router_builder(db_session=get_transaction_session,\n                                               db_model=ExampleTable,\n                                               crud_models=UntitledTable256Model,\n                                               prefix=\"/post_redirect_get\",\n                                               tags=[\"post_redirect_get\"]\n                                               )\n\nexample_table_full_api = sqlalchemy_to_pydantic(ExampleTable,\n                                                crud_methods=[\n                                                    CrudRouter.FIND_MANY,\n                                                    CrudRouter.UPSERT_ONE,\n                                                    CrudRouter.FIND_ONE,\n                                                    CrudRouter.UPDATE_MANY,\n                                                    CrudRouter.UPDATE_ONE,\n                                                    CrudRouter.DELETE_ONE,\n                                                    CrudRouter.DELETE_MANY,\n                                                    CrudRouter.PATCH_MANY,\n                                                    CrudRouter.PATCH_ONE,\n\n                                                ],\n                                                exclude_columns=['array_str__value', 'bytea_value', 'xml_value',\n                                                                 'box_valaue'])\n\nexample_table_full_router = crud_router_builder(db_session=get_transaction_session,\n                                                db_model=ExampleTable,\n                                                crud_models=example_table_full_api,\n                                                async_mode=False,\n                                                prefix=\"/test_CRUD\",\n                                                tags=[\"test\"],\n                                                dependencies=[],\n                                                autocommit=False\n                                                )\n\nExampleTable.__table__.create(engine, checkfirst=True)\n[app.include_router(i) for i in [example_table_full_router, post_redirect_get_router, upsert_many_router]]\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/foreign_tree/__init__.py",
    "content": ""
  },
  {
    "path": "tutorial/foreign_tree/async_m2m.py",
    "content": "import asyncio\n\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    ForeignKey, Table, CHAR\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom src.fastapi_quickcrud.misc.type import SqlType\nfrom src.fastapi_quickcrud.crud_router import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.pool import StaticPool\n\nengine = create_async_engine('sqlite+aiosqlite://',\n                             future=True,\n                             echo=True,\n                             pool_pre_ping=True,\n                             pool_recycle=7200,\n                             connect_args={\"check_same_thread\": False},\n                             poolclass=StaticPool)\n\nsession = sessionmaker(autocommit=False,\n                       autoflush=False,\n                       bind=engine,\n                       class_=AsyncSession)\n\n\nasync def get_transaction_session():\n    async with session() as s:\n        yield s\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    child = Column(CHAR(10))\n    parent = relationship(\"Parent\",\n                          secondary=association_table)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    parent = Column(CHAR(10))\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    child_second = Column(CHAR(10))\n    children_second = relationship(\"Parent\",\n                                   secondary=association_table_second)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"],\n                                       sql_type=SqlType.sqlite,\n                                       foreign_include=[Parent],\n                                       async_mode=True\n\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n                                                          async_mode=True\n\n                                                          )\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n                                                          async_mode=True\n\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"],\n                                              sql_type=SqlType.sqlite,\n                                              async_mode=True\n\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n                                        foreign_include=[Child, ],\n                                        sql_type=SqlType.sqlite,\n                                        async_mode=True\n\n                                        )\ncrud_route_parent2 = crud_router_builder(db_session=get_transaction_session,\n                                         db_model=Parent,\n                                         prefix=\"/parent\",\n                                         tags=[\"parent\"],\n                                         foreign_include=[ChildSecond],\n                                         sql_type=SqlType.sqlite,\n                                         async_mode=True\n\n                                         )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"],\n                                             sql_type=SqlType.sqlite,\n\n                                             async_mode=True\n                                             )\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child, crud_route_parent2,\n  crud_route_association]]\n\nfrom starlette.testclient import TestClient\n\n\nasync def create_table():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n        db = session()\n\n        db.add(Child(id=1, child=\"child1\"))\n        db.add(Child(id=2, child=\"child2\"))\n        db.add(Child(id=3, child=\"child3\"))\n        db.add(Child(id=4, child=\"child4\"))\n        await db.flush()\n\n        db.add(Parent(id=1, parent=\"parent1\"))\n        db.add(Parent(id=2, parent=\"parent2\"))\n        db.add(Parent(id=3, parent=\"parent3\"))\n        db.add(Parent(id=4, parent=\"parent4\"))\n        await db.flush()\n        await db.execute(association_table.insert().values(left_id=1, right_id=1))\n        await db.execute(association_table.insert().values(left_id=2, right_id=2))\n        await db.execute(association_table.insert().values(left_id=3, right_id=3))\n        await db.execute(association_table.insert().values(left_id=4, right_id=4))\n\n        db.add(ChildSecond(id=1, child_second=\"child_second1\"))\n        db.add(ChildSecond(id=2, child_second=\"child_second2\"))\n        db.add(ChildSecond(id=3, child_second=\"child_second3\"))\n        db.add(ChildSecond(id=4, child_second=\"child_second4\"))\n        await db.flush()\n\n        await db.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\n        await db.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\n        await db.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\n        await db.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\n        await db.commit()\n\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(create_table())\n\nimport uvicorn\n\nuvicorn.run(app, host=\"0.0.0.0\", port=8002, debug=False)\n"
  },
  {
    "path": "tutorial/foreign_tree/m2m.py",
    "content": "from fastapi import FastAPI\nfrom fastapi_quickcrud import crud_router_builder\nfrom sqlalchemy import *\nfrom sqlalchemy.orm import *\n\nfrom fastapi_quickcrud.misc.type import SqlType\n\nBase = declarative_base()\n\nfrom sqlalchemy.pool import StaticPool\n\nengine = create_engine('sqlite://', echo=True,\n                       connect_args={\"check_same_thread\": False}, pool_recycle=7200, poolclass=StaticPool)\nsession = sessionmaker(autocommit=False, autoflush=False, bind=engine)\n\n\ndef get_transaction_session():\n    try:\n        db = session()\n        yield db\n    finally:\n        db.close()\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n    child = Column(CHAR(10))\n    parent = relationship(\"Parent\",\n                            secondary=association_table)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    parent = Column(CHAR(10))\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n    child_second = Column(CHAR(10))\n    children_second = relationship(\"Parent\",\n                                   secondary=association_table_second)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"],\n                                       sql_type=SqlType.sqlite,\n                                       foreign_include=[Parent],\n\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n\n                                                          )\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"],\n                                                          sql_type=SqlType.sqlite,\n\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"],\n                                              sql_type=SqlType.sqlite,\n\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n                                        foreign_include=[Child,],\n                                        sql_type=SqlType.sqlite,\n\n                                        )\ncrud_route_parent2 = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"],\n                                        foreign_include=[ChildSecond],\n                                        sql_type=SqlType.sqlite,\n\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"],\n                                             sql_type=SqlType.sqlite,\n\n                                             )\napp = FastAPI()\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child,crud_route_parent2,\n  crud_route_association]]\n\nChild.__table__.create(engine, checkfirst=True)\nChildSecond.__table__.create(engine, checkfirst=True)\nParent.__table__.create(engine, checkfirst=True)\nassociation_table.create(engine, checkfirst=True)\nassociation_table_second.create(engine, checkfirst=True)\ndb = session()\ndb.add(Child(id=1, child=\"child1\"))\ndb.add(Child(id=2, child=\"child2\"))\ndb.add(Child(id=3, child=\"child3\"))\ndb.add(Child(id=4, child=\"child4\"))\ndb.flush()\n\ndb.add(Parent(id=1, parent=\"parent1\"))\ndb.add(Parent(id=2, parent=\"parent2\"))\ndb.add(Parent(id=3, parent=\"parent3\"))\ndb.add(Parent(id=4, parent=\"parent4\"))\ndb.flush()\ndb.execute(association_table.insert().values(left_id=1, right_id=1))\ndb.execute(association_table.insert().values(left_id=2, right_id=2))\ndb.execute(association_table.insert().values(left_id=3, right_id=3))\ndb.execute(association_table.insert().values(left_id=4, right_id=4))\n\ndb.add(ChildSecond(id=1, child_second=\"child_second1\"))\ndb.add(ChildSecond(id=2, child_second=\"child_second2\"))\ndb.add(ChildSecond(id=3, child_second=\"child_second3\"))\ndb.add(ChildSecond(id=4, child_second=\"child_second4\"))\ndb.flush()\n\ndb.execute(association_table_second.insert().values(left_id_second=1, right_id_second=1))\ndb.execute(association_table_second.insert().values(left_id_second=2, right_id_second=2))\ndb.execute(association_table_second.insert().values(left_id_second=3, right_id_second=3))\ndb.execute(association_table_second.insert().values(left_id_second=4, right_id_second=4))\nq = db.execute('''\n                    SELECT \n        name\n    FROM \n        sqlite_master \n                    ''')\n\navailable_tables = q.fetchall()\ndb.commit()\n\nimport uvicorn\n\nuvicorn.run(app, host=\"0.0.0.0\", port=8002, debug=False)\n"
  },
  {
    "path": "tutorial/foreign_tree/sample_tree.py",
    "content": "from fastapi import FastAPI\nimport uvicorn\nfrom fastapi_quickcrud import crud_router_builder\nfrom sqlalchemy import *\nfrom sqlalchemy.orm import *\nfrom fastapi_quickcrud.crud_router import generic_sql_crud_router_builder\n\nBase = declarative_base()\n\n\nclass Account(Base):\n    __tablename__ = \"account\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    blog_post = relationship(\"BlogPost\", back_populates=\"account\")\n\n\nclass BlogPost(Base):\n    __tablename__ = \"blog_post\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    account_id = Column(Integer, ForeignKey(\"account.id\"), nullable=False)\n    account = relationship(\"Account\", back_populates=\"blog_post\")\n    blog_comment = relationship(\"BlogComment\", back_populates=\"blog_post\")\n\n\nclass BlogComment(Base):\n    __tablename__ = \"blog_comment\"\n    id = Column(Integer, primary_key=True, autoincrement=True)\n    blog_id = Column(Integer, ForeignKey(\"blog_post.id\"), nullable=False)\n    blog_post = relationship(\"BlogPost\", back_populates=\"blog_comment\")\n\n\ncrud_route_parent = crud_router_builder(\n    db_model=Account,\n    prefix=\"/account\",\n    tags=[\"account\"],\n    foreign_include=[BlogComment, BlogPost]\n\n)\ncrud_route_child1 = generic_sql_crud_router_builder(\n    db_model=BlogPost,\n    prefix=\"/blog_post\",\n    tags=[\"blog_post\"],\n    foreign_include=[BlogComment]\n\n)\ncrud_route_child2 = generic_sql_crud_router_builder(\n    db_model=BlogComment,\n    prefix=\"/blog_comment\",\n    tags=[\"blog_comment\"]\n\n)\n\napp = FastAPI()\n[app.include_router(i) for i in [crud_route_parent, crud_route_child1, crud_route_child2]]\n\nuvicorn.run(app, host=\"0.0.0.0\", port=8002, debug=False)\n"
  },
  {
    "path": "tutorial/relationship/__init__.py",
    "content": ""
  },
  {
    "path": "tutorial/relationship/many_to_many.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI, Depends\nfrom sqlalchemy.orm import declarative_base, sessionmaker\n\nfrom fastapi_quickcrud import CrudMethods\nfrom fastapi_quickcrud import crud_router_builder\nfrom fastapi_quickcrud import sqlalchemy_to_pydantic\nfrom fastapi_quickcrud.misc.memory_sql import sync_memory_db\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy import CHAR, Column, ForeignKey, Integer, Table\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy.ext.declarative import declarative_base\n\nBase = declarative_base()\nmetadata = Base.metadata\nassociation_table = Table('association', Base.metadata,\n                          Column('left_id', ForeignKey('left.id')),\n                          Column('right_id', ForeignKey('right.id'))\n                          )\n\n\nclass Parent(Base):\n    __tablename__ = 'left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                            secondary=association_table)\n\n\nclass Child(Base):\n    __tablename__ = 'right'\n    id = Column(Integer, primary_key=True)\n    name = Column(CHAR, nullable=True)\n\n\nuser_model_m2m = sqlalchemy_to_pydantic(db_model=association_table,\n                                        crud_methods=[\n                                            CrudMethods.FIND_MANY,\n                                            CrudMethods.UPSERT_ONE,\n                                            CrudMethods.UPDATE_MANY,\n                                            CrudMethods.DELETE_MANY,\n                                            CrudMethods.PATCH_MANY,\n\n                                        ],\n                                        exclude_columns=[])\n\nuser_model_set = sqlalchemy_to_pydantic(db_model=Parent,\n                                        crud_methods=[\n                                            CrudMethods.FIND_MANY,\n                                            CrudMethods.FIND_ONE,\n                                            CrudMethods.CREATE_ONE,\n                                            CrudMethods.UPDATE_MANY,\n                                            CrudMethods.UPDATE_ONE,\n                                            CrudMethods.DELETE_ONE,\n                                            CrudMethods.DELETE_MANY,\n                                            CrudMethods.PATCH_MANY,\n\n                                        ],\n                                        exclude_columns=[])\n\nfriend_model_set = sqlalchemy_to_pydantic(db_model=Child,\n                                          crud_methods=[\n                                              CrudMethods.FIND_MANY,\n                                              CrudMethods.UPSERT_MANY,\n                                              CrudMethods.UPDATE_MANY,\n                                              CrudMethods.DELETE_MANY,\n                                              CrudMethods.CREATE_ONE,\n                                              CrudMethods.PATCH_MANY,\n\n                                          ],\n                                          exclude_columns=[])\n\ncrud_route_1 = crud_router_builder(crud_models=user_model_set,\n                                   db_model=Parent,\n                                   prefix=\"/Parent\",\n                                   dependencies=[],\n                                   async_mode=True,\n                                   tags=[\"Parent\"]\n                                   )\ncrud_route_3 = crud_router_builder(crud_models=user_model_m2m,\n                                   db_model=association_table,\n                                   prefix=\"/Parent2child\",\n                                   dependencies=[],\n                                   async_mode=True,\n                                   tags=[\"m2m\"]\n                                   )\ncrud_route_2 = crud_router_builder(crud_models=friend_model_set,\n                                   db_model=Child,\n                                   async_mode=True,\n                                   prefix=\"/Child\",\n                                   dependencies=[],\n                                   tags=[\"Child\"]\n                                   )\npost_model = friend_model_set.POST[CrudMethods.CREATE_ONE]\n\nsync_memory_db.create_memory_table(Child)\n@app.post(\"/hello\",\n           status_code=201,\n          tags=[\"Child\"],\n           response_model=post_model.responseModel,\n           dependencies=[])\nasync def my_api(\n        body: post_model.requestBodyModel = Depends(post_model.requestBodyModel),\n        session=Depends(sync_memory_db.get_memory_db_session)\n):\n    db_item = Child(**body.__dict__)\n    session.add(db_item)\n    session.commit()\n    session.refresh(db_item)\n    return db_item.__dict__\n\n\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\napp.include_router(crud_route_3)\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/relationship/many_to_one.py",
    "content": "import asyncio\nfrom datetime import datetime, timezone\n\nimport uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    String, Table, ForeignKey, DateTime, Text, text, select, Index, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import UUID, ARRAY\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom fastapi_quickcrud import CrudMethods\nfrom fastapi_quickcrud import crud_router_builder\nfrom fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, ForeignKey, Index, Integer, JSON, LargeBinary, Numeric, SmallInteger, String, Table, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, TIMESTAMP, UUID\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy.sql.sqltypes import NullType\nfrom sqlalchemy.ext.declarative import declarative_base\n\nBase = declarative_base()\nmetadata = Base.metadata\nclass Child(Base):\n    __tablename__ = 'child_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\nclass Parent(Base):\n    __tablename__ = 'parent_m2o_back_populates'\n    id = Column(Integer, primary_key=True)\n    child_id = Column(Integer, ForeignKey('child_m2o_back_populates.id'))\n    child = relationship(\"Child\", backref=\"parents\")\n\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\n\nuser_model_set = sqlalchemy_to_pydantic(db_model=Parent,\n                                        crud_methods=[\n                                            CrudMethods.FIND_MANY,\n                                            CrudMethods.FIND_ONE,\n                                            CrudMethods.UPSERT_ONE,\n                                            CrudMethods.UPDATE_MANY,\n                                            CrudMethods.UPDATE_ONE,\n                                            CrudMethods.DELETE_ONE,\n                                            CrudMethods.DELETE_MANY,\n                                            CrudMethods.PATCH_MANY,\n\n                                        ],\n                                        exclude_columns=[])\n\nfriend_model_set = sqlalchemy_to_pydantic(db_model=Child,\n                                                crud_methods=[\n                                                    CrudMethods.FIND_MANY,\n                                                    CrudMethods.UPSERT_MANY,\n                                                    CrudMethods.UPDATE_MANY,\n                                                    CrudMethods.DELETE_MANY,\n                                                    CrudMethods.PATCH_MANY,\n\n                                                ],\n                                                exclude_columns=[])\n\n\ncrud_route_1 = crud_router_builder(db_session=get_transaction_session,\n                                   crud_models=user_model_set,\n                                   db_model=Parent,\n                                   prefix=\"/Parent\",\n                                   dependencies=[],\n                                   async_mode=True,\n                                   tags=[\"Parent\"]\n                                   )\n\ncrud_route_2 = crud_router_builder(db_session=get_transaction_session,\n                                   crud_models=friend_model_set,\n                                   db_model=Child,\n                                   async_mode=True,\n                                   prefix=\"/Child\",\n                                   dependencies=[],\n                                   tags=[\"Child\"]\n                                   )\n\n\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/relationship/one_to_many.py",
    "content": "import asyncio\nfrom datetime import datetime, timezone\n\nimport uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    String, Table, ForeignKey, DateTime, Text, text, select, Index, UniqueConstraint\nfrom sqlalchemy.dialects.postgresql import UUID, ARRAY\nfrom sqlalchemy.orm import declarative_base, sessionmaker, relationship\n\nfrom fastapi_quickcrud import CrudMethods\nfrom fastapi_quickcrud import crud_router_builder\nfrom fastapi_quickcrud import sqlalchemy_to_pydantic\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, ForeignKey, Index, Integer, JSON, LargeBinary, Numeric, SmallInteger, String, Table, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, TIMESTAMP, UUID\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy.sql.sqltypes import NullType\nfrom sqlalchemy.ext.declarative import declarative_base\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\", backref=\"parent_one_to_many_back_ref\")\n\nclass Child(Base):\n    __tablename__ = 'child_one_to_many_back_ref'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_one_to_many_back_ref.id'))\n\n\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\n\nuser_model_set = sqlalchemy_to_pydantic(db_model=Parent,\n                                        crud_methods=[\n                                            CrudMethods.FIND_MANY,\n                                            CrudMethods.FIND_ONE,\n                                            CrudMethods.UPSERT_ONE,\n                                            CrudMethods.UPDATE_MANY,\n                                            CrudMethods.UPDATE_ONE,\n                                            CrudMethods.DELETE_ONE,\n                                            CrudMethods.DELETE_MANY,\n                                            CrudMethods.PATCH_MANY,\n\n                                        ],\n                                        exclude_columns=[])\n\nfriend_model_set = sqlalchemy_to_pydantic(db_model=Child,\n                                                crud_methods=[\n                                                    CrudMethods.FIND_MANY,\n                                                    CrudMethods.UPSERT_MANY,\n                                                    CrudMethods.UPDATE_MANY,\n                                                    CrudMethods.DELETE_MANY,\n                                                    CrudMethods.PATCH_MANY,\n\n                                                ],\n                                                exclude_columns=[])\n\n\ncrud_route_1 = crud_router_builder(db_session=get_transaction_session,\n                                   crud_models=user_model_set,\n                                   db_model=Parent,\n                                   prefix=\"/Parent\",\n                                   dependencies=[],\n                                   async_mode=True,\n                                   tags=[\"Parent\"]\n                                   )\ncrud_route_2 = crud_router_builder(db_session=get_transaction_session,\n                                   crud_models=friend_model_set,\n                                   db_model=Child,\n                                   async_mode=True,\n                                   prefix=\"/Child\",\n                                   dependencies=[],\n                                   tags=[\"Child\"]\n                                   )\n\n\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/relationship/one_to_one.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, ForeignKey, Integer\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\nfrom sqlalchemy.ext.declarative import declarative_base\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy.orm import sessionmaker\n\nfrom fastapi_quickcrud import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\n\n\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True)\n\n    # one-to-many collection\n    children = relationship(\"Child\", back_populates=\"parent\")\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True)\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'))\n\n    # many-to-one scalar\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n@app.on_event(\"startup\")\nasync def startup_event():\n    async with engine.begin() as conn:\n        await conn.run_sync(Base.metadata.create_all)\n\n\ncrud_route_1 = crud_router_builder(db_session=get_transaction_session,\n                                   db_model=Parent,\n                                   prefix=\"/Parent\",\n                                   tags=['parent']\n                                   )\ncrud_route_2 = crud_router_builder(db_session=get_transaction_session,\n                                   db_model=Child,\n                                   prefix=\"/Child\",\n                                   tags=['child']\n                                   )\n\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\nuvicorn.run(app, host=\"0.0.0.0\", port=8000, debug=False)\n"
  },
  {
    "path": "tutorial/sample.py",
    "content": "from fastapi import FastAPI\nfrom sqlalchemy import *\nfrom sqlalchemy.orm import *\nfrom fastapi_quickcrud.crud_router import generic_sql_crud_router_builder\n\nBase = declarative_base()\nclass Parent(Base):\n    __tablename__ = 'parent_o2o'\n    id = Column(Integer, primary_key=True, comment='test-test-test')\n    name = Column(String, default='ok', unique = True)\n    children = relationship(\"Child\", back_populates=\"parent\")\n\n\n\nclass Child(Base):\n    __tablename__ = 'child_o2o'\n    id = Column(Integer, primary_key=True, comment='child_pk_test')\n    parent_id = Column(Integer, ForeignKey('parent_o2o.id'), info=({'description': 'child_parent_id_test'}))\n    parent = relationship(\"Parent\", back_populates=\"children\")\n\n\ncrud_route_parent = generic_sql_crud_router_builder(\n    db_model=Parent,\n    prefix=\"/parent\",\n    tags=[\"parent\"],\n)\n\ncrud_route_child = generic_sql_crud_router_builder(\n    db_model=Child,\n    prefix=\"/child\",\n    tags=[\"child\"]\n)\n\napp = FastAPI()\n[app.include_router(i) for i in [crud_route_parent, crud_route_child]]\n\n@app.get(\"/\", tags=[\"child\"])\nasync def root():\n    return {\"message\": \"Hello World\"}\n\nimport uvicorn\nuvicorn.run(app, host=\"0.0.0.0\", port=8002, debug=False)\n"
  },
  {
    "path": "tutorial/sample_case.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy import Column, Integer, \\\n    String, Table, ForeignKey, orm\nfrom fastapi_quickcrud import crud_router_builder\n\nBase = orm.declarative_base()\n\n\nclass User(Base):\n    __tablename__ = 'test_users'\n    id = Column(Integer, primary_key=True, autoincrement=True, unique=True)\n    name = Column(String, nullable=False)\n    email = Column(String, nullable=False)\n\n\nfriend = Table(\n    'test_friend', Base.metadata,\n    Column('id', ForeignKey('test_users.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('friend_name', String, nullable=False)\n)\n\ncrud_route_1 = crud_router_builder(db_model=User,\n                                   prefix=\"/user\",\n                                   tags=[\"User\"],\n                                   async_mode=True\n                                   )\ncrud_route_2 = crud_router_builder(db_model=friend,\n                                   prefix=\"/friend\",\n                                   tags=[\"friend\"],\n                                   async_mode=True\n                                   )\n\napp = FastAPI()\napp.include_router(crud_route_1)\napp.include_router(crud_route_2)\nuvicorn.run(app, host=\"0.0.0.0\", port=8002)\n"
  },
  {
    "path": "tutorial/sample_two_table.py",
    "content": "import uvicorn\nfrom fastapi import FastAPI\nfrom sqlalchemy.orm import declarative_base, sessionmaker, synonym\n\nfrom fastapi_quickcrud import crud_router_builder\n\napp = FastAPI()\n\nBase = declarative_base()\nmetadata = Base.metadata\n\nfrom sqlalchemy.ext.asyncio import create_async_engine, AsyncSession\n\nengine = create_async_engine('postgresql+asyncpg://postgres:1234@127.0.0.1:5432/postgres', future=True, echo=True,\n                             pool_use_lifo=True, pool_pre_ping=True, pool_recycle=7200)\nasync_session = sessionmaker(bind=engine, class_=AsyncSession)\n\n\nasync def get_transaction_session() -> AsyncSession:\n    async with async_session() as session:\n        async with session.begin():\n            yield session\n\n\nfrom sqlalchemy import ARRAY, BigInteger, Boolean, CHAR, Column, Date, DateTime, Float, ForeignKey, Index, Integer, \\\n    JSON, LargeBinary, Numeric, SmallInteger, String, Table, Text, Time, UniqueConstraint, text\nfrom sqlalchemy.dialects.postgresql import INTERVAL, JSONB, TIMESTAMP, UUID\nfrom sqlalchemy.orm import relationship\nfrom sqlalchemy.sql.sqltypes import NullType\nfrom sqlalchemy.ext.declarative import declarative_base\n\nBase = declarative_base()\nmetadata = Base.metadata\n\n\nclass Category(Base):\n    __tablename__ = 'category'\n\n    category_id = Column(Integer, primary_key=True,\n                         server_default=text(\"nextval('category_category_id_seq'::regclass)\"))\n    name = Column(String(50))\n\n    movies = relationship('Movie', secondary='movie_category_junction')\n\n\nt_critical_fault_chart = Table(\n    'critical_fault_chart', metadata,\n    Column('log_datetime', TIMESTAMP(True, 0)),\n    Column('site_code', String),\n    Column('site_name', String),\n    Column('equipment_type', String(64)),\n    Column('crit_fault_cnt', BigInteger)\n)\n\n\nclass DataRestCachingCompOption(Base):\n    __tablename__ = 'data_rest_caching_comp_option'\n\n    comp_id = Column(Integer, primary_key=True,\n                     server_default=text(\"nextval('data_rest_caching_comp_option_comp_id_seq'::regclass)\"))\n    comp_hash = Column(CHAR(64), nullable=False, unique=True)\n    comp_content = Column(JSONB(astext_type=Text()), nullable=False)\n    created_at = Column(DateTime(True), server_default=text(\"now()\"))\n\n\nclass DataRestCachingFilterOption(Base):\n    __tablename__ = 'data_rest_caching_filter_option'\n\n    filter_id = Column(Integer, primary_key=True,\n                       server_default=text(\"nextval('data_rest_caching_filter_option_filter_id_seq'::regclass)\"))\n    filter_hash = Column(CHAR(64), nullable=False, unique=True)\n    filter_content = Column(JSONB(astext_type=Text()), nullable=False)\n    created_at = Column(DateTime(True), server_default=text(\"now()\"))\n\n\nclass DataRestCachingQueryOption(Base):\n    __tablename__ = 'data_rest_caching_query_option'\n\n    query_id = Column(Integer, primary_key=True,\n                      server_default=text(\"nextval('data_rest_caching_query_option_query_id_seq'::regclass)\"))\n    query_hash = Column(CHAR(64), nullable=False, unique=True)\n    query_content = Column(JSONB(astext_type=Text()), nullable=False)\n    created_at = Column(DateTime(True), server_default=text(\"now()\"))\n\n\nt_data_rest_pre_aggregated_data_view = Table(\n    'data_rest_pre_aggregated_data_view', metadata,\n    Column('site_code', String(24)),\n    Column('timestamp', DateTime(True)),\n    Column('query_hash', CHAR(64)),\n    Column('filter_hash', CHAR(64)),\n    Column('comp_hash', CHAR(64)),\n    Column('payload', LargeBinary),\n    Column('updated_at', DateTime(True))\n)\n\nt_display_fault = Table(\n    'display_fault', metadata,\n    Column('log_datetime', TIMESTAMP(True, 0)),\n    Column('site_name_en', String),\n    Column('site_code', String),\n    Column('device_name', String),\n    Column('equip_type_name', String(64)),\n    Column('detailed_result', JSONB(astext_type=Text())),\n    Column('plot_metadata', JSONB(astext_type=Text())),\n    Column('impact', JSONB(astext_type=Text()))\n)\n\nt_equipment_fault_overview = Table(\n    'equipment_fault_overview', metadata,\n    Column('log_datetime', TIMESTAMP(True, 0)),\n    Column('site_code', String),\n    Column('site_name', String),\n    Column('equip_type_name', String(64)),\n    Column('crit_fault_cnt', BigInteger),\n    Column('minor_fault_cnt', BigInteger)\n)\n\n\nclass EquipmentTypeNew(Base):\n    __tablename__ = 'equipment_type_new'\n    __table_args__ = (\n        UniqueConstraint('equip_type_id', 'equip_type_name'),\n    )\n\n    equip_type_id = Column(Integer, primary_key=True, unique=True,\n                           server_default=text(\"nextval('equipment_type_equip_type_id_seq'::regclass)\"))\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    equip_type_name = Column(String(64), nullable=False, unique=True)\n\n\nclass EquipmentType(Base):\n    __tablename__ = 'equipment_types'\n\n    equip_type_id = Column(Integer, primary_key=True,\n                           server_default=text(\"nextval('equipment_types_equip_type_id_seq'::regclass)\"))\n    equip_type_name = Column(String(64), nullable=False, unique=True)\n    creation_time = Column(DateTime(True), server_default=text(\"now()\"))\n\n\nclass Example(Base):\n    __tablename__ = 'example'\n    __table_args__ = (\n        UniqueConstraint('p_id', 'test'),\n    )\n\n    p_id = Column(Integer, primary_key=True)\n    test = Column(Integer)\n    test_1 = Column(Text)\n\n\nclass ExampleTable(Base):\n    __tablename__ = 'example_table'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(Integer, primary_key=True, server_default=text(\"nextval('untitled_table_256_id_seq'::regclass)\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID)\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nt_fault_diagnosis_view = Table(\n    'fault_diagnosis_view', metadata,\n    Column('log_datetime', TIMESTAMP(True, 0)),\n    Column('site_code', String),\n    Column('device_name', String),\n    Column('detailed_result', JSONB(astext_type=Text())),\n    Column('plot_metadata', JSONB(astext_type=Text())),\n    Column('severity', String(16)),\n    Column('equip_type_id', Integer),\n    Column('equip_type_name', String(64)),\n    Column('impact', JSONB(astext_type=Text()))\n)\n\nt_fault_features_view = Table(\n    'fault_features_view', metadata,\n    Column('log_date', Date),\n    Column('site_code', String(24)),\n    Column('device_name', String(64)),\n    Column('feature_name', String(64)),\n    Column('sub_type', String(64)),\n    Column('value_json', JSONB(astext_type=Text()))\n)\n\nt_fault_list = Table(\n    'fault_list', metadata,\n    Column('log_datetime', DateTime(True)),\n    Column('site_code', String),\n    Column('site_name', String),\n    Column('device_name', String),\n    Column('equip_type_name', String(64)),\n    Column('severity', String(16)),\n    Column('impact', JSONB(astext_type=Text())),\n    Column('fault_cnt', BigInteger),\n    Column('detailed_result', JSONB(astext_type=Text())),\n    Column('fault_category', JSONB(astext_type=Text()))\n)\n\n\nclass FunctionGroup(Base):\n    __tablename__ = 'function_group'\n\n    func_group_id = Column(String(5), primary_key=True)\n    func_group_name = Column(String, nullable=False)\n    created_at = Column(DateTime(True))\n    updated_at = Column(DateTime(True))\n    deleted_at = Column(DateTime(True))\n    function_catagory = Column(String(20), nullable=False, server_default=text(\"'site'::character varying\"))\n\n\nt_list_of_critical_fault = Table(\n    'list_of_critical_fault', metadata,\n    Column('log_datetime', TIMESTAMP(True, 0)),\n    Column('site_code', String),\n    Column('site_name', String),\n    Column('device_name', String),\n    Column('severity', String(16)),\n    Column('equipment_type', String(64)),\n    # Column('impact', JSONB(astext_type=Text())),\n    # Column('fault_issue', JSONB(astext_type=Text()))\n)\n\n\nclass Movie(Base):\n    __tablename__ = 'movie'\n\n    movie_id = Column(Integer, primary_key=True, server_default=text(\"nextval('movie_movie_id_seq'::regclass)\"))\n    name = Column(String(50))\n\n\nclass ProcessedFilter(Base):\n    __tablename__ = 'processed_filter'\n\n    filter_id = Column(Integer, primary_key=True,\n                       server_default=text(\"nextval('processed_filter_filter_id_seq'::regclass)\"))\n    name = Column(String, nullable=False, unique=True)\n\n\nclass ProcessedResolution(Base):\n    __tablename__ = 'processed_resolution'\n\n    resolution_id = Column(Integer, primary_key=True,\n                           server_default=text(\"nextval('processed_resolution_resolution_id_seq'::regclass)\"))\n    name = Column(String, nullable=False, unique=True)\n\n\nclass ProcessedValue(Base):\n    __tablename__ = 'processed_value'\n\n    pid = Column(UUID, primary_key=True, nullable=False)\n    timestamp = Column(DateTime(True), primary_key=True, nullable=False)\n    count = Column(Integer, nullable=False)\n    value = Column(Float(53))\n    sum = Column(Float(53))\n    mean = Column(Float(53))\n    std = Column(Float(53))\n    min = Column(Float(53))\n    max = Column(Float(53))\n    median = Column(Float(53))\n\n\nclass RefCode(Base):\n    __tablename__ = 'ref_code'\n\n    code_key = Column(String, primary_key=True, nullable=False)\n    code_type = Column(String, primary_key=True, nullable=False)\n    code_sub_type = Column(String, primary_key=True, nullable=False)\n    descn = Column(String)\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n\n\nclass RefFilter(Base):\n    __tablename__ = 'ref_filter'\n\n    code_key = Column(String(20), primary_key=True, nullable=False)\n    code_type = Column(String(20), primary_key=True, nullable=False)\n    processed_filter_id = Column(SmallInteger, nullable=False)\n    descn = Column(String(100))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n    code_sub_type = Column(String(20))\n\n\nclass RefResolution(Base):\n    __tablename__ = 'ref_resolution'\n\n    code_key = Column(String(20), primary_key=True, nullable=False)\n    code_type = Column(String(20), primary_key=True, nullable=False)\n    processed_resolution_id = Column(SmallInteger, nullable=False)\n    descn = Column(String(100))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n\n\nclass RefSymptomGroup(Base):\n    __tablename__ = 'ref_symptom_group'\n\n    id = Column(String(40), primary_key=True)\n    description = Column(String(100))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n\n\nclass RelationshipTestA(Base):\n    __tablename__ = 'relationship_test_a'\n\n    id = Column(Integer, primary_key=True, server_default=text(\"nextval('untitled_table_271_id_seq'::regclass)\"))\n    name = Column(String, nullable=False)\n    email = Column(String, nullable=False)\n\n\nclass Sometable(Base):\n    __tablename__ = 'sometable'\n    __table_args__ = (\n        UniqueConstraint('col1', 'col2'),\n    )\n\n    id = Column(Integer, primary_key=True, server_default=text(\"nextval('sometable_id_seq'::regclass)\"))\n    col1 = Column(Integer, nullable=False)\n    col2 = Column(Integer, nullable=False)\n\n\nclass TempSite(Base):\n    __tablename__ = 'temp_sites'\n\n    site_name_chn = Column(String)\n    site_name_en = Column(String)\n    tenant_id = Column(UUID, nullable=False)\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n    site_code = Column(String, primary_key=True)\n    photo = Column(String)\n    location = Column(String)\n    weather_station = Column(String)\n    is_activate = Column(Boolean)\n\n\nclass Tenant(Base):\n    __tablename__ = 'tenants'\n\n    id = Column(UUID, primary_key=True)\n    tenant_code = Column(String(10), nullable=False, unique=True)\n    tenant_name_en = Column(String(750), server_default=text(\"NULL::character varying\"))\n    tenant_name_chn = Column(String(150), server_default=text(\"NULL::character varying\"))\n    logo = Column(String(1000), server_default=text(\"NULL::character varying\"))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True), index=True)\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n\n\nclass TestAliasUniqueColumn(Base):\n    __tablename__ = 'test_alias_unique_column'\n    __table_args__ = (\n        UniqueConstraint('id', 'test_case_column', 'float4_value'),\n    )\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    test_case_column = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestAliasUniqueColumnAsync(Base):\n    __tablename__ = 'test_alias_unique_column_async'\n    __table_args__ = (\n        UniqueConstraint('id', 'test_case_column', 'float4_value'),\n    )\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    test_case_column = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestBuildMyself(Base):\n    __tablename__ = 'test_build_myself'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(Integer, primary_key=True, server_default=text(\"nextval('test_build_myself_id_seq'::regclass)\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID)\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestBuildMyselfAsync(Base):\n    __tablename__ = 'test_build_myself_async'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(Integer, primary_key=True, server_default=text(\"nextval('test_build_myself_async_id_seq'::regclass)\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID)\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestNoAlia(Base):\n    __tablename__ = 'test_no_alias'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestNoAliasAsync(Base):\n    __tablename__ = 'test_no_alias_async'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestTable(Base):\n    __tablename__ = 'test_table'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n\n    primary_key = Column(Integer, primary_key=True,\n                         server_default=text(\"nextval('test_table_primary_key_seq'::regclass)\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID)\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestUuidPrimary(Base):\n    __tablename__ = 'test_uuid_primary'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n\n    primary_key = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestUuidPrimaryAsync(Base):\n    __tablename__ = 'test_uuid_primary_async'\n    __table_args__ = (\n        UniqueConstraint('primary_key', 'int4_value', 'float4_value'),\n    )\n\n    primary_key = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\nclass TestUuidPrimarySync(Base):\n    __tablename__ = 'test_uuid_primary_sync'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float(53), nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    varchar_value = Column(String)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n\n\n# class UntitledTable256(Base):\n#     __tablename__ = 'untitled_table_256'\n#     __table_args__ = (\n#         UniqueConstraint('id', 'int4_value', 'float4_value'),\n#     )\n#\n#     id = Column(Integer, primary_key=True, nullable=False,\n#                 server_default=text(\"nextval('untitled_table_256_id_seq'::regclass)\"))\n#     bool_value = Column(Boolean, primary_key=True, nullable=False, server_default=text(\"false\"))\n#     bytea_value = Column(LargeBinary)\n#     char_value = Column(CHAR(10))\n#     date_value = Column(Date, server_default=text(\"now()\"))\n#     float4_value = Column(Float, nullable=False)\n#     float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n#     int2_value = Column(SmallInteger, nullable=False)\n#     int4_value = Column(Integer, nullable=False)\n#     int8_value = Column(BigInteger, server_default=text(\"99\"))\n#     interval_value = Column(INTERVAL)\n#     json_value = Column(JSON)\n#     jsonb_value = Column(JSONB(astext_type=Text()))\n#     numeric_value = Column(Numeric)\n#     text_value = Column(Text)\n#     time_value = Column(Time)\n#     timestamp_value = Column(DateTime)\n#     timestamptz_value = Column(DateTime(True))\n#     timetz_value = Column(Time(True))\n#     uuid_value = Column(UUID)\n#     varchar_value = Column(String)\n#     xml_value = Column(NullType)\n#     array_value = Column(ARRAY(Integer()))\n#     array_str__value = Column(ARRAY(String()))\n#     box_valaue = Column(NullType)\n\n\nt_user_group_dashboard = Table(\n    'user_group_dashboard', metadata,\n    Column('ordering', Integer, nullable=False),\n    Column('created_at', DateTime(True), nullable=False),\n    Column('updated_at', DateTime(True), nullable=False),\n    Column('deleted_at', DateTime(True)),\n    Column('dashboard_id', UUID, nullable=False),\n    Column('user_group_id', UUID, nullable=False),\n    Column('tenant_id', UUID, nullable=False),\n    Column('children_list', ARRAY(UUID())),\n    Column('created_by', UUID),\n    Column('item_type', String)\n)\n\nt_user_policy_table = Table(\n    'user_policy_table', metadata,\n    Column('user_group_name', String),\n    Column('group_id', UUID),\n    Column('policy_level', Integer),\n    Column('policy_name', String),\n    Column('policy_id', UUID),\n    Column('site_code', String),\n    Column('user_info', JSON),\n    Column('available_function', JSON)\n)\n\n\nclass ZFaultDiagnosisType(Base):\n    __tablename__ = 'z_fault_diagnosis_type'\n\n    diagnosis_type_id = Column(Integer, primary_key=True,\n                               server_default=text(\"nextval('z_fault_diagnosis_type_diagnosis_type_id_seq'::regclass)\"))\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    severity = Column(String(16))\n    impact = Column(JSONB(astext_type=Text()))\n    recommendation = Column(JSONB(astext_type=Text()))\n    issue = Column(JSONB(astext_type=Text()))\n\n\nclass FaultFeatureTypeNew(Base):\n    __tablename__ = 'fault_feature_type_new'\n    __table_args__ = (\n        UniqueConstraint('equip_type_id', 'feature_name', 'sub_type', 'frequency', 'attribute_name'),\n    )\n\n    feature_type_id = Column(Integer, primary_key=True,\n                             server_default=text(\"nextval('fault_feature_type_feature_type_id_seq'::regclass)\"))\n    equip_type_id = Column(ForeignKey('equipment_type_new.equip_type_id'), nullable=False)\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    feature_name = Column(String(64), nullable=False)\n    sub_type = Column(String(64), nullable=False)\n    frequency = Column(String(16), nullable=False)\n    attribute_name = Column(JSONB(astext_type=Text()), nullable=False)\n\n    equip_type = relationship('EquipmentTypeNew')\n\n\nclass FaultFeatureType(Base):\n    __tablename__ = 'fault_feature_types'\n    __table_args__ = (\n        UniqueConstraint('feature_name', 'sub_type', 'equip_type_id'),\n    )\n\n    feature_type_id = Column(Integer, primary_key=True,\n                             server_default=text(\"nextval('fault_feature_types_feature_type_id_seq'::regclass)\"))\n    feature_name = Column(String(64), nullable=False)\n    sub_type = Column(String(64), nullable=False)\n    equip_type_id = Column(ForeignKey('equipment_types.equip_type_id'), nullable=False)\n    creation_time = Column(DateTime(True), server_default=text(\"now()\"))\n\n    equip_type = relationship('EquipmentType')\n\n\nclass FaultSymptomType(Base):\n    __tablename__ = 'fault_symptom_type'\n    __table_args__ = (\n        UniqueConstraint('equip_type_id', 'symptom_name', 'frequency', 'attribute_names'),\n    )\n\n    symptom_type_id = Column(Integer, primary_key=True,\n                             server_default=text(\"nextval('fault_symptom_type_symptom_type_id_seq'::regclass)\"))\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    symptom_name = Column(String(64), nullable=False)\n    frequency = Column(String(16), nullable=False)\n    attribute_names = Column(String(64), nullable=False)\n    equip_type_id = Column(ForeignKey('equipment_type_new.equip_type_id'), nullable=False)\n\n    equip_type = relationship('EquipmentTypeNew')\n\n\nclass Function(Base):\n    __tablename__ = 'functions'\n\n    func_id = Column(String(10), primary_key=True)\n    func_name = Column(String(100))\n    created_at = Column(DateTime(True))\n    updated_at = Column(DateTime(True))\n    deleted_at = Column(DateTime(True))\n    func_group_id = Column(ForeignKey('function_group.func_group_id'))\n\n    func_group = relationship('FunctionGroup')\n\n\nt_movie_category_junction = Table(\n    'movie_category_junction', metadata,\n    Column('movie_id', ForeignKey('movie.movie_id'), primary_key=True, nullable=False),\n    Column('category_id', ForeignKey('category.category_id'), primary_key=True, nullable=False)\n)\n\nt_relationship_test_b = Table(\n    'relationship_test_b', metadata,\n    Column('id', ForeignKey('relationship_test_a.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('friend', String, nullable=False)\n)\n\n\nclass Site(Base):\n    __tablename__ = 'sites'\n\n    id = Column(String(24), primary_key=True)\n    site_name_chn = Column(String)\n    site_name_en = Column(String)\n    tenant_id = Column(ForeignKey('tenants.id', ondelete='SET NULL', onupdate='CASCADE'), nullable=False)\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n    site_code = Column(String, unique=True)\n    photo = Column(String)\n    location = Column(String)\n    weather_station = Column(String)\n    is_activate = Column(Boolean)\n\n    tenant = relationship('Tenant')\n\n\nclass TenantPolicy(Base):\n    __tablename__ = 'tenant_policy'\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    tenant_id = Column(ForeignKey('tenants.id'), nullable=False)\n    policy_name = Column(String, nullable=False)\n    created_at = Column(DateTime(True))\n    updated_at = Column(DateTime(True))\n    deleted_at = Column(DateTime(True))\n    policy_level = Column(Integer, nullable=False)\n\n    tenant = relationship('Tenant')\n\n\nclass UserGroup(Base):\n    __tablename__ = 'user_group'\n\n    id = Column(UUID, primary_key=True, server_default=text(\"uuid_generate_v4()\"))\n    tenant_id = Column(ForeignKey('tenants.id', onupdate='CASCADE'), nullable=False)\n    group_name = Column(String, nullable=False)\n    created_at = Column(DateTime(True))\n    updated_at = Column(DateTime(True))\n    deleted_at = Column(DateTime(True))\n    description = Column(Text)\n    policy_id = Column(UUID)\n    icon_url = Column(Text)\n\n    tenant = relationship('Tenant')\n\n\nclass User(Base):\n    __tablename__ = 'users'\n\n    id = Column(UUID, primary_key=True)\n    first_name = Column(String(30))\n    last_name = Column(String(70))\n    email = Column(String(100), nullable=False, unique=True)\n    avatar = Column(String(1000), server_default=text(\"NULL::character varying\"))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True), index=True)\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n    tenant_id = Column(ForeignKey('tenants.id', ondelete='SET NULL', onupdate='CASCADE'), nullable=False, index=True)\n    active = Column(Boolean, nullable=False, server_default=text(\"false\"))\n\n    tenant = relationship('Tenant')\n\n\nclass WidgetInfo(Base):\n    __tablename__ = 'widget_info'\n\n    id = Column(UUID, primary_key=True)\n    method_template_id = Column(String)\n    title = Column(String)\n    widget_type = Column(String, nullable=False)\n    tenant_id = Column(ForeignKey('tenants.id'), nullable=False)\n    polling_interval = Column(Integer)\n    internal_dataset = Column(JSONB(astext_type=Text()))\n    created_at = Column(DateTime(True))\n    updated_at = Column(DateTime(True))\n    deleted_at = Column(DateTime(True))\n    local_start_date = Column(DateTime(True))\n    local_end_date = Column(DateTime(True))\n    created_by = Column(UUID)\n    local_filter_option = Column(JSONB(astext_type=Text()))\n    local_groupby = Column(String(255))\n    point_configs = Column(JSONB(astext_type=Text()))\n    groupby_point_configs = Column(JSONB(astext_type=Text()))\n    chart_data = Column(ARRAY(JSONB(astext_type=Text())))\n    axis_config = Column(JSONB(astext_type=Text()))\n    axis = Column(JSONB(astext_type=Text()))\n    extra_axis = Column(JSONB(astext_type=Text()))\n    legend_orientation = Column(String)\n    legend_location = Column(String)\n    legend = Column(JSONB(astext_type=Text()))\n    color_palette = Column(ARRAY(String()))\n    marker_symbol = Column(String)\n    extra_axis_data = Column(ARRAY(JSONB(astext_type=Text())))\n    alignment = Column(String)\n    required_other_data_source = Column(Boolean)\n    extra_columns = Column(ARRAY(String()))\n    testing_colors = Column(JSONB(astext_type=Text()))\n    subtitle = Column(String)\n    desc = Column(String)\n    ref_widget_data_id = Column(UUID)\n    extra_rows = Column(JSONB(astext_type=Text()))\n    horizontal_rows = Column(ARRAY(String()))\n    model_unit = Column(String)\n    chart_data_2 = Column(JSONB(astext_type=Text()))\n\n    tenant = relationship('Tenant')\n\n\nt_apikeys = Table(\n    'apikeys', metadata,\n    Column('user_id', ForeignKey('users.id', ondelete='CASCADE', onupdate='CASCADE'), nullable=False),\n    Column('apikey', String, nullable=False, unique=True),\n    Column('description', String),\n    Column('created_at', DateTime(True), server_default=text(\"CURRENT_TIMESTAMP\"))\n)\n\n\nclass Dashboard(Base):\n    __tablename__ = 'dashboards'\n\n    id = Column(UUID, primary_key=True, info={'alias_name': 'primary_key'})\n    icon = Column(String(1000), server_default=text(\"NULL::character varying\"))\n    name_en = Column(String(750), nullable=False)\n    name_chn = Column(String(150), nullable=False)\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n    tenant_id = Column(ForeignKey('tenants.id', ondelete='SET NULL', onupdate='CASCADE'), nullable=False, index=True)\n    descn_en = Column(String)\n    descn_chn = Column(String)\n    site_id = Column(ForeignKey('sites.id', onupdate='CASCADE'), index=True)\n    compact_type = Column(String(10), server_default=text(\"'vertical'::character varying\"))\n    item_type = Column(String, nullable=False)\n\n    site = relationship('Site')\n    tenant = relationship('Tenant')\n\n\nclass DataRestCachingPayload(Base):\n    __tablename__ = 'data_rest_caching_payload'\n\n    site_code = Column(ForeignKey('sites.site_code', ondelete='CASCADE'), primary_key=True, nullable=False)\n    timestamp = Column(DateTime(True), primary_key=True, nullable=False)\n    query_id = Column(ForeignKey('data_rest_caching_query_option.query_id', ondelete='CASCADE'), primary_key=True,\n                      nullable=False)\n    filter_id = Column(ForeignKey('data_rest_caching_filter_option.filter_id', ondelete='CASCADE'), primary_key=True,\n                       nullable=False)\n    comp_id = Column(ForeignKey('data_rest_caching_comp_option.comp_id', ondelete='CASCADE'), primary_key=True,\n                     nullable=False)\n    payload = Column(LargeBinary)\n    updated_at = Column(DateTime(True), server_default=text(\"now()\"))\n\n    comp = relationship('DataRestCachingCompOption')\n    filter = relationship('DataRestCachingFilterOption')\n    query = relationship('DataRestCachingQueryOption')\n    site = relationship('Site')\n\n\nclass Device(Base):\n    __tablename__ = 'devices'\n    __table_args__ = (\n        UniqueConstraint('site_code', 'device_name'),\n    )\n\n    device_id = Column(Integer, primary_key=True, server_default=text(\"nextval('devices_device_id_seq'::regclass)\"))\n    site_code = Column(ForeignKey('sites.site_code'), nullable=False)\n    device_name = Column(String(64), nullable=False)\n    equip_type_id = Column(ForeignKey('equipment_types.equip_type_id'))\n    creation_time = Column(DateTime(True), server_default=text(\"now()\"))\n\n    equip_type = relationship('EquipmentType')\n    site = relationship('Site')\n\n\nclass FaultDiagnosi(Base):\n    __tablename__ = 'fault_diagnosis'\n    __table_args__ = (\n        UniqueConstraint('log_datetime', 'site_code', 'equip_type_id', 'device_name'),\n    )\n\n    fault_id = Column(Integer, primary_key=True, server_default=text(\"nextval('vav_faults_fault_id_seq'::regclass)\"))\n    log_datetime = Column(TIMESTAMP(True, 0), nullable=False)\n    detailed_result = Column(JSONB(astext_type=Text()))\n    plot_metadata = Column(JSONB(astext_type=Text()))\n    severity = Column(String(16))\n    equip_type_id = Column(ForeignKey('equipment_types.equip_type_id'))\n    fault_category = Column(JSONB(astext_type=Text()))\n    device_name = Column(String)\n    site_code = Column(ForeignKey('sites.site_code'))\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    impact = Column(JSONB(astext_type=Text()), server_default=text(\"'[]'::jsonb\"))\n\n    equip_type = relationship('EquipmentType')\n    site = relationship('Site')\n\n\nclass FaultFeatureNew(Base):\n    __tablename__ = 'fault_feature_new'\n\n    log_datetime = Column(DateTime(True), primary_key=True, nullable=False)\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    feature_type_id = Column(ForeignKey('fault_feature_type_new.feature_type_id'), primary_key=True, nullable=False)\n    value_json = Column(JSONB(astext_type=Text()))\n    site_code = Column(ForeignKey('sites.site_code'), primary_key=True, nullable=False)\n    device_name = Column(String(64), primary_key=True, nullable=False)\n\n    feature_type = relationship('FaultFeatureTypeNew')\n    site = relationship('Site')\n\n\nclass FaultSymptom(Base):\n    __tablename__ = 'fault_symptom'\n\n    log_datetime = Column(DateTime(True), primary_key=True, nullable=False)\n    created_at = Column(DateTime(True), nullable=False, server_default=text(\"now()\"))\n    updated_at = Column(DateTime(True))\n    symptom_type_id = Column(ForeignKey('fault_symptom_type.symptom_type_id'), primary_key=True, nullable=False)\n    detected = Column(Boolean, comment='conflict update')\n    value_json = Column(JSONB(astext_type=Text()), comment='conflict update')\n    device_name = Column(String, primary_key=True, nullable=False)\n    site_code = Column(ForeignKey('sites.site_code'), primary_key=True, nullable=False)\n\n    site = relationship('Site')\n    symptom_type = relationship('FaultSymptomType')\n\n\nt_link_site_func_group = Table(\n    'link_site_func_group', metadata,\n    Column('site_code', ForeignKey('sites.site_code'), nullable=False),\n    Column('func_group_id', ForeignKey('function_group.func_group_id')),\n    Column('created_at', DateTime(True)),\n    Column('updated_at', DateTime(True)),\n    Column('deleted_at', DateTime(True))\n)\n\nt_link_user_group = Table(\n    'link_user_group', metadata,\n    Column('user_id', ForeignKey('users.id', onupdate='CASCADE'), nullable=False),\n    Column('group_id', ForeignKey('user_group.id'), nullable=False),\n    Column('created_at', DateTime(True)),\n    Column('updated_at', DateTime(True)),\n    Column('deleted_at', DateTime(True))\n)\n\nt_link_user_group_site_func = Table(\n    'link_user_group_site_func', metadata,\n    Column('user_group_id', ForeignKey('user_group.id', onupdate='CASCADE'), nullable=False),\n    Column('func_id', ForeignKey('functions.func_id'), nullable=False),\n    Column('created_at', DateTime(True)),\n    Column('updated_at', DateTime(True)),\n    Column('deleted_at', DateTime(True)),\n    Column('site_code', ForeignKey('sites.site_code'), nullable=False),\n    Column('func_group_id', ForeignKey('function_group.func_group_id'))\n)\n\n\nclass FaultFeature(Base):\n    __tablename__ = 'fault_features'\n\n    device_id = Column(ForeignKey('devices.device_id'), primary_key=True, nullable=False)\n    feature_type_id = Column(ForeignKey('fault_feature_types.feature_type_id'), primary_key=True, nullable=False)\n    log_date = Column(Date, primary_key=True, nullable=False)\n    value_json = Column(JSONB(astext_type=Text()))\n\n    device = relationship('Device')\n    feature_type = relationship('FaultFeatureType')\n\n\nclass UserDashboard(Base):\n    __tablename__ = 'user_dashboard'\n\n    start_from = Column(DateTime(True))\n    start_to = Column(DateTime(True))\n    ordering = Column(Integer, nullable=False)\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True), index=True)\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n    dashboard_id = Column(ForeignKey('dashboards.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True,\n                          nullable=False, index=True)\n    user_id = Column(ForeignKey('users.id', onupdate='CASCADE'), primary_key=True, nullable=False, index=True)\n    tenant_id = Column(ForeignKey('tenants.id', ondelete='SET NULL', onupdate='CASCADE'), nullable=False, index=True)\n    children_list = Column(ARRAY(UUID()))\n\n    dashboard = relationship('Dashboard')\n    tenant = relationship('Tenant')\n    user = relationship('User')\n\n\nclass WidgetLayout(Base):\n    __tablename__ = 'widget_layout'\n    __table_args__ = (\n        Index('widget_layout_widget_data_id_idx', 'deleted_at', 'widget_data_id'),\n        Index('widget_layout_dashboard_id_idx', 'deleted_at', 'dashboard_id')\n    )\n\n    dashboard_id = Column(ForeignKey('dashboards.id', ondelete='CASCADE', onupdate='CASCADE'),\n                          info={'alias_name': 'primary_key'}, primary_key=True, nullable=False)\n    primary_key = synonym('dashboard_id')\n    tenant_id = Column(ForeignKey('tenants.id', ondelete='SET NULL', onupdate='CASCADE'), nullable=False)\n    widget_data_id = Column(ForeignKey('widget_info.id'), nullable=False)\n    user_id = Column(ForeignKey('users.id', onupdate='CASCADE'), nullable=False)\n    x = Column(Integer, nullable=False, server_default=text(\"0\"))\n    y = Column(Integer, nullable=False, server_default=text(\"0\"))\n    h = Column(Integer, nullable=False, server_default=text(\"0\"))\n    w = Column(Integer, nullable=False, server_default=text(\"0\"))\n    start_from = Column(DateTime(True))\n    start_to = Column(DateTime(True))\n    created_at = Column(DateTime(True), nullable=False)\n    updated_at = Column(DateTime(True), nullable=False)\n    deleted_at = Column(DateTime(True))\n    version = Column(Integer, nullable=False, server_default=text(\"0\"))\n\n    dashboard = relationship('Dashboard')\n    tenant = relationship('Tenant')\n    user = relationship('User')\n    widget_data = relationship('WidgetInfo')\n\n\nclass UntitledTable256(Base):\n    __tablename__ = 'untitled_table_256'\n    __table_args__ = (\n        UniqueConstraint('id', 'int4_value', 'float4_value'),\n    )\n\n    id = Column(Integer, primary_key=True, nullable=False,\n                server_default=text(\"nextval('untitled_table_256_id_seq'::regclass)\"))\n    bool_value = Column(Boolean, nullable=False, server_default=text(\"false\"))\n    bytea_value = Column(LargeBinary)\n    char_value = Column(CHAR(10))\n    date_value = Column(Date, server_default=text(\"now()\"))\n    float4_value = Column(Float, nullable=False)\n    float8_value = Column(Float(53), nullable=False, server_default=text(\"10.10\"))\n    int2_value = Column(SmallInteger, nullable=False)\n    int4_value = Column(Integer, nullable=False)\n    int8_value = Column(BigInteger, server_default=text(\"99\"))\n    interval_value = Column(INTERVAL)\n    json_value = Column(JSON)\n    jsonb_value = Column(JSONB(astext_type=Text()))\n    numeric_value = Column(Numeric)\n    text_value = Column(Text)\n    time_value = Column(Time)\n    timestamp_value = Column(DateTime)\n    timestamptz_value = Column(DateTime(True))\n    timetz_value = Column(Time(True))\n    uuid_value = Column(UUID)\n    varchar_value = Column(String)\n    xml_value = Column(NullType)\n    array_value = Column(ARRAY(Integer()))\n    array_str__value = Column(ARRAY(String()))\n    box_valaue = Column(NullType)\n\n    def test(self):\n        print('ok')\n\n\nassociation_table = Table('test_association', Base.metadata,\n                          Column('left_id', ForeignKey('test_left.id')),\n                          Column('right_id', ForeignKey('test_right.id'))\n                          )\n\nassociation_table_second = Table('test_association_second', Base.metadata,\n                                 Column('left_id_second', ForeignKey('test_left.id')),\n                                 Column('right_id_second', ForeignKey('test_right_second.id'))\n                                 )\n\n\nclass Child(Base):\n    __tablename__ = 'test_right'\n    id = Column(Integer, primary_key=True)\n\n\nclass Parent(Base):\n    __tablename__ = 'test_left'\n    id = Column(Integer, primary_key=True)\n    children = relationship(\"Child\",\n                            secondary=association_table)\n    children_second = relationship(\"ChildSecond\",\n                                   secondary=association_table_second)\n\n\nclass ChildSecond(Base):\n    __tablename__ = 'test_right_second'\n    id = Column(Integer, primary_key=True)\n\n\ncrud_route_child = crud_router_builder(db_session=get_transaction_session,\n                                       db_model=Child,\n                                       prefix=\"/child\",\n                                       tags=[\"child\"]\n                                       )\n\ncrud_route_association_table_second = crud_router_builder(db_session=get_transaction_session,\n                                                          db_model=association_table_second,\n                                                          prefix=\"/association_table_second\",\n                                                          tags=[\"association_table_second\"]\n                                                          )\n\ncrud_route_child_second = crud_router_builder(db_session=get_transaction_session,\n                                              db_model=Child,\n                                              prefix=\"/child_second\",\n                                              tags=[\"child_second\"]\n                                              )\n\ncrud_route_parent = crud_router_builder(db_session=get_transaction_session,\n                                        db_model=Parent,\n                                        prefix=\"/parent\",\n                                        tags=[\"parent\"]\n                                        )\ncrud_route_association = crud_router_builder(db_session=get_transaction_session,\n                                             db_model=association_table,\n                                             prefix=\"/association\",\n                                             tags=[\"association\"]\n                                             )\n\n[app.include_router(i) for i in\n [crud_route_association_table_second, crud_route_child_second, crud_route_parent, crud_route_child,\n  crud_route_association]]\n\n# crud_route_2 = crud_router_builder(db_session=get_transaction_session,\n#                                    db_model=UntitledTable256,\n#                                    crud_methods=[\n#                                        CrudMethods.UPSERT_MANY,\n#                                    ],\n#                                    exclude_columns=['bytea_value', 'xml_value', 'box_valaue'],\n#                                    prefix=\"/friend\",\n#                                    )\n# app.include_router(crud_route_2)\nuvicorn.run(app, host=\"0.0.0.0\", port=8002, debug=False)\n"
  }
]