diff --git a/fastapi_startkit/pyproject.toml b/fastapi_startkit/pyproject.toml
index 4e2a062e..89d7cfdb 100644
--- a/fastapi_startkit/pyproject.toml
+++ b/fastapi_startkit/pyproject.toml
@@ -1,6 +1,6 @@
[project]
name = "fastapi-startkit"
-version = "0.13.7"
+version = "0.13.6"
description = "Fastapi Starter kit components"
authors = [
{name = "Bedram Tamang", email = "tmgbedu@gmail.com"}
@@ -46,7 +46,6 @@ dev = [
"dumpdie>=1.5.0",
"pytest>=9.0.3",
"pytest-asyncio>=1.3.0",
- "ruff>=0.15.12",
"twine>=6.2.0",
]
@@ -60,14 +59,3 @@ build-backend = "uv_build"
[tool.uv]
workspace = { members = ["application", "example/*"] }
-
-[tool.ruff]
-line-length = 120
-
-[tool.ruff.lint]
-select = ["E", "F", "I"]
-ignore = ["E501"]
-fixable = ["ALL"]
-
-[tool.ruff.lint.per-file-ignores]
-"__init__.py" = ["F401"]
diff --git a/fastapi_startkit/src/fastapi_startkit/application.py b/fastapi_startkit/src/fastapi_startkit/application.py
index 85e62afb..a2cfa5d1 100644
--- a/fastapi_startkit/src/fastapi_startkit/application.py
+++ b/fastapi_startkit/src/fastapi_startkit/application.py
@@ -1,16 +1,16 @@
import os
from pathlib import Path
-from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, Type, TypeVar
+from typing import TYPE_CHECKING, Optional
+from typing import Type, Callable, Any, List, TypeVar, Generic
from fastapi_startkit.providers.app_provider import AppProvider
-
from .config import AppConfig
from .configuration.providers import ConfigurationProvider
from .container import Container
from .environment.environment import LoadEnvironment
if TYPE_CHECKING:
- from fastapi import APIRouter, FastAPI
+ from fastapi import FastAPI, APIRouter
from starlette.middleware.base import BaseHTTPMiddleware
from fastapi_startkit.exceptions import ExceptionHandler
@@ -64,7 +64,9 @@ def __init__(
self.load_providers()
def configure_exception_handler(self):
- self.exception_manager: ExceptionHandler = self._exception_handler_class(application=self)
+ self.exception_manager: ExceptionHandler = self._exception_handler_class(
+ application=self
+ )
self.exception_manager.register()
self.exception_manager.install()
self.bind("exception_manager", self.exception_manager)
@@ -75,8 +77,6 @@ def register_providers(self):
config = {}
if isinstance(provider_data, tuple):
provider_class, config = provider_data
- if callable(config):
- config = config()
else:
provider_class = provider_data
@@ -129,8 +129,9 @@ def include_router(self, router: "APIRouter", **kwargs):
return self
# Add middleware
- def add_middleware(self, middleware_class: type[Any], *args: Any, **kwargs: Any) -> None:
- self._fastapi.add_middleware(middleware_class, *args, **kwargs)
+ def add_middleware(self, middleware_class: Type["BaseHTTPMiddleware"], **options):
+ self._fastapi.add_middleware(middleware_class, **options)
+ return self
# Add event handlers (startup/shutdown)
def add_event_handler(self, event_type: str, func: Callable[..., Any]):
@@ -143,7 +144,9 @@ def mount(self, path: str, app_instance: "FastAPI", **kwargs):
return self
# Add custom exception handlers
- def add_exception_handler(self, exc_class_or_status_code: Any, handler: Callable[..., Any]):
+ def add_exception_handler(
+ self, exc_class_or_status_code: Any, handler: Callable[..., Any]
+ ):
self._fastapi.add_exception_handler(exc_class_or_status_code, handler)
return self
@@ -153,7 +156,9 @@ def fastapi(self) -> "FastAPI":
try:
from fastapi import FastAPI
except ImportError:
- raise RuntimeError("FastAPI is not installed. Install it with: pip install fastapi")
+ raise RuntimeError(
+ "FastAPI is not installed. Install it with: pip install fastapi"
+ )
self._fastapi = FastAPI()
# Making the type hint work
assert self._fastapi is not None
diff --git a/fastapi_startkit/src/fastapi_startkit/collection/collection.py b/fastapi_startkit/src/fastapi_startkit/collection/collection.py
index 84960a6a..39385c88 100644
--- a/fastapi_startkit/src/fastapi_startkit/collection/collection.py
+++ b/fastapi_startkit/src/fastapi_startkit/collection/collection.py
@@ -276,7 +276,9 @@ def pluck(self, value, key=None, keep_nulls=True):
if k == value:
if key:
- attributes[self._data_get(item, key)] = self._data_get(item, value)
+ attributes[self._data_get(item, key)] = self._data_get(
+ item, value
+ )
else:
attributes.append(v)
diff --git a/fastapi_startkit/src/fastapi_startkit/commands/publish_command.py b/fastapi_startkit/src/fastapi_startkit/commands/publish_command.py
index 89de062b..f6eeec54 100644
--- a/fastapi_startkit/src/fastapi_startkit/commands/publish_command.py
+++ b/fastapi_startkit/src/fastapi_startkit/commands/publish_command.py
@@ -4,7 +4,6 @@
from cleo.commands.command import Command
from cleo.helpers import option
-
from fastapi_startkit.helpers.string import Str
if TYPE_CHECKING:
@@ -16,7 +15,12 @@ class PublishCommand(Command):
description = "Publish provider config files into the project."
options = [
- option("provider", "p", description="Provider name to publish (e.g. LogProvider, log_provider).", flag=False),
+ option(
+ "provider",
+ "p",
+ description="Provider name to publish (e.g. LogProvider, log_provider).",
+ flag=False,
+ ),
]
def handle(self):
@@ -33,10 +37,14 @@ def handle(self):
if provider_arg:
target = Str.slugify(provider_arg)
resources = {
- name: files for name, files in application.published_resources.items() if Str.slugify(name) == target
+ name: files
+ for name, files in application.published_resources.items()
+ if Str.slugify(name) == target
}
if not resources:
- self.line(f"No provider found matching '{provider_arg}'.")
+ self.line(
+ f"No provider found matching '{provider_arg}'."
+ )
return
else:
resources = application.published_resources
@@ -47,10 +55,13 @@ def handle(self):
if os.path.exists(dest_path):
overwrite = self.confirm(
- f" {destination} already exists. Overwrite?", default=False
+ f" {destination} already exists. Overwrite?",
+ default=False,
)
if not overwrite:
- self.line(f" [{provider_key}] Skipped {destination}")
+ self.line(
+ f" [{provider_key}] Skipped {destination}"
+ )
continue
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
diff --git a/fastapi_startkit/src/fastapi_startkit/config/app.py b/fastapi_startkit/src/fastapi_startkit/config/app.py
index e21b5ec0..2bea07f8 100644
--- a/fastapi_startkit/src/fastapi_startkit/config/app.py
+++ b/fastapi_startkit/src/fastapi_startkit/config/app.py
@@ -1,12 +1,13 @@
import os
-from dataclasses import dataclass, field
-
+from dataclasses import field, dataclass
from fastapi_startkit.environment.environment import env
@dataclass
class AppConfig:
- name: str = field(default_factory=lambda: os.getenv("APP_NAME", "FastAPI starter kit"))
+ name: str = field(
+ default_factory=lambda: os.getenv("APP_NAME", "FastAPI starter kit")
+ )
env: str = field(default_factory=lambda: os.getenv("APP_ENV", "development"))
debug: bool = field(default_factory=lambda: env("APP_DEBUG", "true"))
timezone: str = field(default_factory=lambda: os.getenv("APP_TIMEZONE", "UTC"))
diff --git a/fastapi_startkit/src/fastapi_startkit/config/facades/config.py b/fastapi_startkit/src/fastapi_startkit/config/facades/config.py
index 6583e416..e19f5234 100644
--- a/fastapi_startkit/src/fastapi_startkit/config/facades/config.py
+++ b/fastapi_startkit/src/fastapi_startkit/config/facades/config.py
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Type, TypeVar
+from typing import TypeVar, Type, TYPE_CHECKING
if TYPE_CHECKING:
from fastapi_startkit.config import AppConfig
diff --git a/fastapi_startkit/src/fastapi_startkit/configuration/Configuration.py b/fastapi_startkit/src/fastapi_startkit/configuration/Configuration.py
index a4527798..39ac684f 100644
--- a/fastapi_startkit/src/fastapi_startkit/configuration/Configuration.py
+++ b/fastapi_startkit/src/fastapi_startkit/configuration/Configuration.py
@@ -1,7 +1,6 @@
from fastapi_startkit.loader import Loader
-
-from ..exceptions import InvalidConfigurationSetup
from ..utils.structures import data
+from ..exceptions import InvalidConfigurationLocation, InvalidConfigurationSetup
class Configuration:
@@ -27,7 +26,9 @@ def __init__(self, application):
def load(self):
"""At boot load configuration from all files and store them in here."""
config_root = self.application.make("config.location")
- for module_name, module in Loader().get_modules(config_root, raise_exception=True).items():
+ for module_name, module in (
+ Loader().get_modules(config_root, raise_exception=True).items()
+ ):
params = Loader().get_parameters(module)
for name, value in params.items():
self._config[f"{module_name}.{name.lower()}"] = value
@@ -41,7 +42,9 @@ def merge_with(self, path, external_config):
(such as 'application').
"""
if path in self.reserved_keys:
- raise InvalidConfigurationSetup(f"{path} is a reserved configuration key name. Please use an other key.")
+ raise InvalidConfigurationSetup(
+ f"{path} is a reserved configuration key name. Please use an other key."
+ )
if isinstance(external_config, str):
# config is a path and should be loaded
params = Loader().get_parameters(external_config)
diff --git a/fastapi_startkit/src/fastapi_startkit/configuration/__init__.py b/fastapi_startkit/src/fastapi_startkit/configuration/__init__.py
index e04bda97..2847ba4f 100644
--- a/fastapi_startkit/src/fastapi_startkit/configuration/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/configuration/__init__.py
@@ -1,2 +1,2 @@
-from .Configuration import Configuration
from .helpers import config
+from .Configuration import Configuration
diff --git a/fastapi_startkit/src/fastapi_startkit/configuration/providers/ConfigurationProvider.py b/fastapi_startkit/src/fastapi_startkit/configuration/providers/ConfigurationProvider.py
index 2f16c931..772a9e11 100644
--- a/fastapi_startkit/src/fastapi_startkit/configuration/providers/ConfigurationProvider.py
+++ b/fastapi_startkit/src/fastapi_startkit/configuration/providers/ConfigurationProvider.py
@@ -1,4 +1,5 @@
from ...providers import Provider
+
from ..Configuration import Configuration
diff --git a/fastapi_startkit/src/fastapi_startkit/console.py b/fastapi_startkit/src/fastapi_startkit/console.py
index a4c8846a..1b4f6ff6 100644
--- a/fastapi_startkit/src/fastapi_startkit/console.py
+++ b/fastapi_startkit/src/fastapi_startkit/console.py
@@ -1,6 +1,5 @@
from cleo.application import Application as BaseApplication
from cleo.io.io import IO
-
from fastapi_startkit.application import Application
diff --git a/fastapi_startkit/src/fastapi_startkit/container/container.py b/fastapi_startkit/src/fastapi_startkit/container/container.py
index d86e3249..8268b8be 100644
--- a/fastapi_startkit/src/fastapi_startkit/container/container.py
+++ b/fastapi_startkit/src/fastapi_startkit/container/container.py
@@ -54,10 +54,14 @@ def bind(self, name, class_obj):
"""
if inspect.ismodule(class_obj):
raise StrictContainerException(
- "Cannot bind module '{}' with key '{}' into the container".format(class_obj, name)
+ "Cannot bind module '{}' with key '{}' into the container".format(
+ class_obj, name
+ )
)
if self.strict and name in self.objects:
- raise StrictContainerException("You cannot override a key inside a strict container")
+ raise StrictContainerException(
+ "You cannot override a key inside a strict container"
+ )
if self.override or name not in self.objects:
self.fire_hook("bind", name, class_obj)
@@ -141,7 +145,9 @@ def make(self, name, *arguments):
obj = self.resolve(name, *arguments)
return obj
- raise MissingContainerBindingNotFound("{0} key was not found in the container".format(name))
+ raise MissingContainerBindingNotFound(
+ "{0} key was not found in the container".format(name)
+ )
def has(self, name):
"""Check if a key exists in the container.
@@ -194,9 +200,14 @@ def resolve(self, obj, *resolving_arguments):
self.remember
and not passing_arguments
and inspect.ismethod(obj)
- and "{}.{}.{}".format(obj.__module__, obj.__self__.__class__.__name__, obj.__name__) in self._remembered
+ and "{}.{}.{}".format(
+ obj.__module__, obj.__self__.__class__.__name__, obj.__name__
+ )
+ in self._remembered
):
- location = "{}.{}.{}".format(obj.__module__, obj.__self__.__class__.__name__, obj.__name__)
+ location = "{}.{}.{}".format(
+ obj.__module__, obj.__self__.__class__.__name__, obj.__name__
+ )
objects = self._remembered[location]
try:
return obj(*objects)
@@ -204,13 +215,13 @@ def resolve(self, obj, *resolving_arguments):
raise ContainerError(str(e))
else:
for _, value in self.get_parameters(obj):
- if type(value.annotation) in (str, int, dict, list, tuple) or value.annotation in (
+ if type(value.annotation) in (
str,
int,
dict,
list,
tuple,
- ):
+ ) or value.annotation in (str, int, dict, list, tuple):
# Ignore any times a user is simply type hinting a parameter like (parameter:str or parameter:"str").
# In this case we don't want to resolve anything but we do want
# to insert any passing arguments we passed in
@@ -260,7 +271,9 @@ def resolve(self, obj, *resolving_arguments):
if not inspect.ismethod(obj):
self._remembered[obj] = objects
else:
- signature = "{}.{}.{}".format(obj.__module__, obj.__self__.__class__.__name__, obj.__name__)
+ signature = "{}.{}.{}".format(
+ obj.__module__, obj.__self__.__class__.__name__, obj.__name__
+ )
self._remembered[signature] = objects
return obj(*objects)
@@ -292,15 +305,20 @@ def collect(self, search):
providers.update({key: value})
elif "*" in search:
split_search = search.split("*")
- if key.startswith(split_search[0]) and key.endswith(split_search[1]):
+ if key.startswith(split_search[0]) and key.endswith(
+ split_search[1]
+ ):
providers.update({key: value})
else:
- raise AttributeError("There is no '*' in your collection search")
+ raise AttributeError(
+ "There is no '*' in your collection search"
+ )
else:
for provider_key, provider_class in self.objects.items():
- if (inspect.isclass(provider_class) and issubclass(provider_class, search)) or isinstance(
- provider_class, search
- ):
+ if (
+ inspect.isclass(provider_class)
+ and issubclass(provider_class, search)
+ ) or isinstance(provider_class, search):
providers.update({provider_key: provider_class})
return providers
@@ -326,7 +344,10 @@ def _find_annotated_parameter(self, parameter):
return obj
for _, provider_class in self.objects.items():
- if parameter.annotation == provider_class or parameter.annotation == provider_class.__class__:
+ if (
+ parameter.annotation == provider_class
+ or parameter.annotation == provider_class.__class__
+ ):
obj = provider_class
self.fire_hook("resolve", parameter, obj)
@@ -341,7 +362,9 @@ def _find_annotated_parameter(self, parameter):
return obj
raise ContainerError(
- "The dependency with the {0} annotation could not be resolved by the container".format(parameter)
+ "The dependency with the {0} annotation could not be resolved by the container".format(
+ parameter
+ )
)
def get_parameters(self, obj):
@@ -369,7 +392,9 @@ def _find_parameter(self, keyword):
return keyword.default
raise ContainerError(
- "The parameter dependency with the key of {0} could not be found in the container".format(parameter)
+ "The parameter dependency with the key of {0} could not be found in the container".format(
+ parameter
+ )
)
def on_bind(self, key, obj):
@@ -478,7 +503,9 @@ def _find_obj(self, obj):
return return_obj
raise MissingContainerBindingNotFound(
- "The dependency with the {0} annotation could not be resolved by the container".format(obj)
+ "The dependency with the {0} annotation could not be resolved by the container".format(
+ obj
+ )
)
def __contains__(self, obj):
diff --git a/fastapi_startkit/src/fastapi_startkit/environment/environment.py b/fastapi_startkit/src/fastapi_startkit/environment/environment.py
index 615f20a2..86bfaf69 100644
--- a/fastapi_startkit/src/fastapi_startkit/environment/environment.py
+++ b/fastapi_startkit/src/fastapi_startkit/environment/environment.py
@@ -2,9 +2,8 @@
import os
import sys
-from pathlib import Path
-
from dotenv import load_dotenv
+from pathlib import Path
class LoadEnvironment:
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/DD.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/DD.py
index 0512e7f3..972c8cc9 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/DD.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/DD.py
@@ -3,6 +3,7 @@
from .exceptions import DumpException
+
warnings.warn(
"DD class will be removed in Masonite 5. Please use Dump facade instead.",
DeprecationWarning,
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/ExceptionHandler.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/ExceptionHandler.py
index 43aefb4a..d0036aa6 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/ExceptionHandler.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/ExceptionHandler.py
@@ -31,7 +31,9 @@ def handle(self, exception):
response = self.application.make("response")
request = self.application.make("request")
- self.application.make("event").fire(f"masonite.exception.{exception.__class__.__name__}", exception)
+ self.application.make("event").fire(
+ f"masonite.exception.{exception.__class__.__name__}", exception
+ )
# add headers to response if any
if hasattr(exception, "get_headers"):
@@ -45,13 +47,17 @@ def handle(self, exception):
response.with_headers(headers)
if self.application.has(f"{exception.__class__.__name__}Handler"):
- return self.application.make(f"{exception.__class__.__name__}Handler").handle(exception)
+ return self.application.make(
+ f"{exception.__class__.__name__}Handler"
+ ).handle(exception)
# handle exception in production
if not self.application.is_debug():
# for HTTP error codes (500, 404, 403...) a specific page should be displayed
# if a renderable exception is raised let it be displayed
- if hasattr(exception, "is_http_exception") or hasattr(exception, "get_response"):
+ if hasattr(exception, "is_http_exception") or hasattr(
+ exception, "get_response"
+ ):
return self.application.make("HttpExceptionHandler").handle(exception)
# else fallback to an unknown exception that should be displayed as a 500 error
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/__init__.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/__init__.py
index b3c05ef6..590a19b7 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/__init__.py
@@ -1,38 +1,38 @@
-from .DD import DD
from .ExceptionHandler import ExceptionHandler
+from .handlers.DumpExceptionHandler import DumpExceptionHandler
+from .handlers.HttpExceptionHandler import HttpExceptionHandler
+from .handlers.ModelNotFoundHandler import ModelNotFoundHandler
+from .DD import DD
from .exceptions import (
- AmbiguousError,
AuthorizationException,
+ InvalidRouteCompileException,
+ RouteMiddlewareNotFound,
ContainerError,
- DumpException,
- InvalidConfigurationLocation,
- InvalidConfigurationSetup,
- InvalidCSRFToken,
+ MissingContainerBindingNotFound,
+ StrictContainerException,
+ ResponseError,
InvalidHTTPStatusCode,
- InvalidPackageName,
- InvalidRouteCompileException,
+ RequiredContainerBindingNotFound,
+ ViewException,
+ RouteNotFoundException,
+ DumpException,
InvalidSecretKey,
- InvalidToken,
- LoaderNotFound,
- MethodNotAllowedException,
- MissingContainerBindingNotFound,
- MixFileNotFound,
- MixManifestNotFound,
- ModelNotFoundException,
+ InvalidCSRFToken,
NotificationException,
+ InvalidToken,
ProjectLimitReached,
- ProjectProviderHttpError,
ProjectProviderTimeout,
+ ProjectProviderHttpError,
ProjectTargetNotEmpty,
+ MixFileNotFound,
+ MixManifestNotFound,
+ InvalidConfigurationLocation,
+ InvalidConfigurationSetup,
+ InvalidPackageName,
+ LoaderNotFound,
QueueException,
- RequiredContainerBindingNotFound,
- ResponseError,
- RouteMiddlewareNotFound,
- RouteNotFoundException,
- StrictContainerException,
+ AmbiguousError,
+ MethodNotAllowedException,
+ ModelNotFoundException,
ThrottleRequestsException,
- ViewException,
)
-from .handlers.DumpExceptionHandler import DumpExceptionHandler
-from .handlers.HttpExceptionHandler import HttpExceptionHandler
-from .handlers.ModelNotFoundHandler import ModelNotFoundHandler
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/exceptionite/controllers.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/exceptionite/controllers.py
index c7d2cca4..35fd676c 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/exceptionite/controllers.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/exceptionite/controllers.py
@@ -1,5 +1,5 @@
-from ...controllers import Controller
from ...request import Request
+from ...controllers import Controller
from ...response import Response
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/DumpExceptionHandler.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/DumpExceptionHandler.py
index 3a75182b..1c686cbb 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/DumpExceptionHandler.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/DumpExceptionHandler.py
@@ -37,7 +37,9 @@ class DumpExceptionHandler:
def __init__(self, application):
self.application = application
- self.assets_path = os.path.join(get_module_dir(__file__), "../../templates/assets")
+ self.assets_path = os.path.join(
+ get_module_dir(__file__), "../../templates/assets"
+ )
self.styles = []
self.scripts = []
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/HttpExceptionHandler.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/HttpExceptionHandler.py
index a6f57385..e88bd22c 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/HttpExceptionHandler.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/HttpExceptionHandler.py
@@ -18,7 +18,9 @@ def handle(self, exception):
# Renders HTTP exception as HTML with predefined error page if exists
if self.application.make("view").exists(view_name):
return response.view(
- self.application.make("view").render(f"errors/{status_code}", {"message": exception.get_response()}),
+ self.application.make("view").render(
+ f"errors/{status_code}", {"message": exception.get_response()}
+ ),
status_code,
)
else:
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/ModelNotFoundHandler.py b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/ModelNotFoundHandler.py
index 68d53106..7d6880eb 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/ModelNotFoundHandler.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions.backup/handlers/ModelNotFoundHandler.py
@@ -6,6 +6,8 @@ def __init__(self, application):
self.application = application
def handle(self, exception):
- masonite_exception = ModelNotFoundException("No record found with the given primary key")
+ masonite_exception = ModelNotFoundException(
+ "No record found with the given primary key"
+ )
self.application.make("response").status(404)
self.application.make("exception_handler").handle(masonite_exception)
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions/__init__.py b/fastapi_startkit/src/fastapi_startkit/exceptions/__init__.py
index 5fd0447a..b39dec8a 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions/__init__.py
@@ -1,34 +1,34 @@
+from .handler import ExceptionHandler
from .exceptions import (
- AmbiguousError,
AuthorizationException,
+ InvalidRouteCompileException,
+ RouteMiddlewareNotFound,
ContainerError,
- DumpException,
- InvalidConfigurationLocation,
- InvalidConfigurationSetup,
- InvalidCSRFToken,
+ MissingContainerBindingNotFound,
+ StrictContainerException,
+ ResponseError,
InvalidHTTPStatusCode,
- InvalidPackageName,
- InvalidRouteCompileException,
+ RequiredContainerBindingNotFound,
+ ViewException,
+ RouteNotFoundException,
+ DumpException,
InvalidSecretKey,
- InvalidToken,
- LoaderNotFound,
- MethodNotAllowedException,
- MissingContainerBindingNotFound,
- MixFileNotFound,
- MixManifestNotFound,
- ModelNotFoundException,
+ InvalidCSRFToken,
NotificationException,
+ InvalidToken,
ProjectLimitReached,
- ProjectProviderHttpError,
ProjectProviderTimeout,
+ ProjectProviderHttpError,
ProjectTargetNotEmpty,
+ MixFileNotFound,
+ MixManifestNotFound,
+ InvalidConfigurationLocation,
+ InvalidConfigurationSetup,
+ InvalidPackageName,
+ LoaderNotFound,
QueueException,
- RequiredContainerBindingNotFound,
- ResponseError,
- RouteMiddlewareNotFound,
- RouteNotFoundException,
- StrictContainerException,
+ AmbiguousError,
+ MethodNotAllowedException,
+ ModelNotFoundException,
ThrottleRequestsException,
- ViewException,
)
-from .handler import ExceptionHandler
diff --git a/fastapi_startkit/src/fastapi_startkit/exceptions/handler.py b/fastapi_startkit/src/fastapi_startkit/exceptions/handler.py
index 8b0d89c7..c5e8d8af 100644
--- a/fastapi_startkit/src/fastapi_startkit/exceptions/handler.py
+++ b/fastapi_startkit/src/fastapi_startkit/exceptions/handler.py
@@ -1,7 +1,9 @@
-import atexit
import sys
+import atexit
from typing import Any, Callable, Dict, List, Optional, Type
+from dumpdie import dd
+
class ExceptionHandler:
def __init__(self, application=None):
@@ -70,7 +72,11 @@ def _build_context(self, exception: Exception) -> str:
context = f"{type(exception).__name__}: {exception}"
if self.app and self.app.is_debug():
- context += "\n" + "".join(traceback.format_exception(type(exception), exception, exception.__traceback__))
+ context += "\n" + "".join(
+ traceback.format_exception(
+ type(exception), exception, exception.__traceback__
+ )
+ )
return context
async def handle(self, exception: Exception, context: Optional[Dict] = None) -> Any:
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Auth.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Auth.pyi
index fc2e1484..514777ed 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Auth.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Auth.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any, List, Tuple
+from typing import TYPE_CHECKING, Any, Tuple, List
if TYPE_CHECKING:
from ..routes import Route
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Dump.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Dump.pyi
index c011289f..15776405 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Dump.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Dump.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any, List
+from typing import Any, List, TYPE_CHECKING
if TYPE_CHECKING:
from ..dumps import Dump as DumpObject
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Gate.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Gate.pyi
index fc6437bf..af9edf96 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Gate.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Gate.pyi
@@ -1,8 +1,7 @@
-from typing import TYPE_CHECKING, Any, Callable, List, Tuple
+from typing import TYPE_CHECKING, Callable, List, Tuple, Any
if TYPE_CHECKING:
- from ..authorization import AuthorizationResponse, Policy
- from ..authorization import Gate as GateObject
+ from ..authorization import AuthorizationResponse, Policy, Gate as GateObject
class Gate:
"""Gate facade."""
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Hash.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Hash.pyi
index fca84bab..55d74729 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Hash.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Hash.pyi
@@ -20,7 +20,9 @@ class Hash:
) -> bool:
"""Verify that a given string matches its hashed version (based on configured hashing protocol)."""
...
- def needs_rehash(hashed_string: str, options: dict = {}, driver: str = None) -> bool:
+ def needs_rehash(
+ hashed_string: str, options: dict = {}, driver: str = None
+ ) -> bool:
"""Verify that a given hash needs to be hashed again because parameters for generating
the hash have changed."""
...
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Loader.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Loader.pyi
index 7ce200ed..04aa5661 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Loader.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Loader.pyi
@@ -10,8 +10,12 @@ class Loader:
class_name: str,
raise_exception: bool = False,
) -> "None|Any": ...
- def find_all(class_instance: Any, paths: list, raise_exception: bool = False) -> dict: ...
- def get_object(path_or_module: "str|Any", object_name: str, raise_exception: bool = False) -> Any:
+ def find_all(
+ class_instance: Any, paths: list, raise_exception: bool = False
+ ) -> dict: ...
+ def get_object(
+ path_or_module: "str|Any", object_name: str, raise_exception: bool = False
+ ) -> Any:
"""Load the given object from a Python module located at path and returns a default value if
not found. If no object name is provided, returns the loaded module."""
...
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Mail.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Mail.pyi
index 039faaf6..81fc22fa 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Mail.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Mail.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any
+from typing import Any, TYPE_CHECKING
if TYPE_CHECKING:
from ..mail import Mailable
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Notification.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Notification.pyi
index 6add0eb7..6066ffdf 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Notification.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Notification.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any
+from typing import Any, TYPE_CHECKING
if TYPE_CHECKING:
from ..notification import Notification as NotificationObject
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/RateLimiter.pyi b/fastapi_startkit/src/fastapi_startkit/facades/RateLimiter.pyi
index 168a58a4..9b9609ce 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/RateLimiter.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/RateLimiter.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any, Callable
+from typing import Any, Callable, TYPE_CHECKING
if TYPE_CHECKING:
from ..rates.limiters import Limiter
@@ -15,7 +15,9 @@ class RateLimiter:
def get_limiter(self, name: str) -> "Limiter":
"""Get rate limiter registered with the given name."""
...
- def attempt(key: str, callback: Callable, max_attempts: int, delay: int = 60) -> Any:
+ def attempt(
+ key: str, callback: Callable, max_attempts: int, delay: int = 60
+ ) -> Any:
"""Try to execute the given callback if not limited by the 'key' rate limiter."""
...
def too_many_attempts(self, key: str, max_attempts: int) -> bool:
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/Request.pyi b/fastapi_startkit/src/fastapi_startkit/facades/Request.pyi
index f431cc26..284b9cf4 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/Request.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/Request.pyi
@@ -1,4 +1,4 @@
-from typing import TYPE_CHECKING, Any, List
+from typing import TYPE_CHECKING, List, Any
if TYPE_CHECKING:
from ..routes import Route
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/View.pyi b/fastapi_startkit/src/fastapi_startkit/facades/View.pyi
index 5be7e42d..0f7e6640 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/View.pyi
+++ b/fastapi_startkit/src/fastapi_startkit/facades/View.pyi
@@ -1,6 +1,5 @@
-from typing import Any, Callable
-
-from jinja2 import BaseLoader, PackageLoader
+from typing import Callable, Any
+from jinja2 import PackageLoader, BaseLoader
class View:
"""View facade."""
diff --git a/fastapi_startkit/src/fastapi_startkit/facades/__init__.py b/fastapi_startkit/src/fastapi_startkit/facades/__init__.py
index 73693277..de7ed3a8 100644
--- a/fastapi_startkit/src/fastapi_startkit/facades/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/facades/__init__.py
@@ -1,20 +1,20 @@
-from .Auth import Auth
-from .Broadcast import Broadcast
-from .Cache import Cache
-from .Config import Config
-from .Dump import Dump
from .Facade import Facade
-from .Gate import Gate
+from .Request import Request
+from .Response import Response
+from .Mail import Mail
from .Hash import Hash
-from .Inertia import Inertia
+from .Url import Url
+from .Session import Session
+from .View import View
+from .Gate import Gate
+from .Auth import Auth
+from .Config import Config
from .Loader import Loader
-from .Mail import Mail
from .Notification import Notification
+from .Storage import Storage
+from .Dump import Dump
from .Queue import Queue
+from .Cache import Cache
from .RateLimiter import RateLimiter
-from .Request import Request
-from .Response import Response
-from .Session import Session
-from .Storage import Storage
-from .Url import Url
-from .View import View
+from .Broadcast import Broadcast
+from .Inertia import Inertia
diff --git a/fastapi_startkit/src/fastapi_startkit/fastapi/commands/serve_command.py b/fastapi_startkit/src/fastapi_startkit/fastapi/commands/serve_command.py
index 1ee16846..128012a9 100644
--- a/fastapi_startkit/src/fastapi_startkit/fastapi/commands/serve_command.py
+++ b/fastapi_startkit/src/fastapi_startkit/fastapi/commands/serve_command.py
@@ -7,15 +7,38 @@ class ServeCommand(Command):
description = "Start the FastAPI server."
options = [
- option("port", "p", flag=False, default="8000", description="The port to serve the application on"),
- option("host", None, flag=False, default="127.0.0.1", description="The host to bind to"),
- option("reload", "r", flag=False, default=True, description="Enable auto-reload on code changes"),
- option("app", "a", flag=False, default="bootstrap.application:app", description="The application to serve"),
+ option(
+ "port",
+ "p",
+ flag=False,
+ default="8000",
+ description="The port to serve the application on",
+ ),
+ option(
+ "host",
+ None,
+ flag=False,
+ default="127.0.0.1",
+ description="The host to bind to",
+ ),
+ option(
+ "reload",
+ "r",
+ flag=False,
+ default=True,
+ description="Enable auto-reload on code changes",
+ ),
+ option(
+ "app",
+ "a",
+ flag=False,
+ default="bootstrap.application:app",
+ description="The application to serve",
+ ),
]
def handle(self):
import uvicorn
-
from fastapi_startkit.container import Container
port = int(self.option("port"))
@@ -42,7 +65,9 @@ def handle(self):
}
)
- self.line(f"Starting Uvicorn server on {host}:{port} [{app}]...")
+ self.line(
+ f"Starting Uvicorn server on {host}:{port} [{app}]..."
+ )
else:
self.line(f"Starting Uvicorn server on {host}:{port}...")
@@ -66,6 +91,8 @@ def is_app_exist(self) -> "bool":
except (ImportError, ValueError):
pass
- self.line("Unable to detect the application, run the command with --app={app}>")
+ self.line(
+ "Unable to detect the application, run the command with --app={app}>"
+ )
return False
diff --git a/fastapi_startkit/src/fastapi_startkit/fastapi/routers/router.py b/fastapi_startkit/src/fastapi_startkit/fastapi/routers/router.py
index 033e3f77..741da5fb 100644
--- a/fastapi_startkit/src/fastapi_startkit/fastapi/routers/router.py
+++ b/fastapi_startkit/src/fastapi_startkit/fastapi/routers/router.py
@@ -78,25 +78,39 @@ def _add_route(
**kwargs,
)
- def get(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def get(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["GET"], **kwargs)
- def post(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def post(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["POST"], **kwargs)
- def put(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def put(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["PUT"], **kwargs)
- def patch(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def patch(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["PATCH"], **kwargs)
- def delete(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def delete(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["DELETE"], **kwargs)
- def head(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def head(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["HEAD"], **kwargs)
- def options(self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]) -> None:
+ def options(
+ self, path: str, endpoint: Callable[..., Any], **kwargs: Unpack[RouteOptions]
+ ) -> None:
self._add_route(path, endpoint, ["OPTIONS"], **kwargs)
def resource(
@@ -133,22 +147,44 @@ def fn(method: str) -> Callable[..., Any]:
self.get(f"/{name}", fn("index"), name=route_name("index", name))
if include("create") and hasattr(controller, "create"):
- self.get(f"/{name}/create", fn("create"), name=route_name("create", f"{name}.create"))
+ self.get(
+ f"/{name}/create",
+ fn("create"),
+ name=route_name("create", f"{name}.create"),
+ )
if include("store") and hasattr(controller, "store"):
- self.post(f"/{name}", fn("store"), name=route_name("store", f"{name}.store"))
+ self.post(
+ f"/{name}", fn("store"), name=route_name("store", f"{name}.store")
+ )
if include("show") and hasattr(controller, "show"):
- self.get(f"/{name}/{{{param}}}", fn("show"), name=route_name("show", f"{name}.show"))
+ self.get(
+ f"/{name}/{{{param}}}",
+ fn("show"),
+ name=route_name("show", f"{name}.show"),
+ )
if include("edit") and hasattr(controller, "edit"):
- self.get(f"/{name}/{{{param}}}/edit", fn("edit"), name=route_name("edit", f"{name}.edit"))
+ self.get(
+ f"/{name}/{{{param}}}/edit",
+ fn("edit"),
+ name=route_name("edit", f"{name}.edit"),
+ )
if include("update") and hasattr(controller, "update"):
- self.put(f"/{name}/{{{param}}}", fn("update"), name=route_name("update", f"{name}.update"))
+ self.put(
+ f"/{name}/{{{param}}}",
+ fn("update"),
+ name=route_name("update", f"{name}.update"),
+ )
if include("destroy") and hasattr(controller, "destroy"):
- self.delete(f"/{name}/{{{param}}}", fn("destroy"), name=route_name("destroy", f"{name}.destroy"))
+ self.delete(
+ f"/{name}/{{{param}}}",
+ fn("destroy"),
+ name=route_name("destroy", f"{name}.destroy"),
+ )
def __getattr__(self, name: str) -> Any:
return getattr(self.router, name)
diff --git a/fastapi_startkit/src/fastapi_startkit/helpers/dataclass.py b/fastapi_startkit/src/fastapi_startkit/helpers/dataclass.py
index 48714172..54a71b11 100644
--- a/fastapi_startkit/src/fastapi_startkit/helpers/dataclass.py
+++ b/fastapi_startkit/src/fastapi_startkit/helpers/dataclass.py
@@ -1,6 +1,7 @@
-import dataclasses
from typing import Any
+import dataclasses
+
class Dataclass:
@staticmethod
@@ -8,7 +9,10 @@ def to_dict(obj: Any):
if hasattr(obj, "model_dump") and callable(obj.model_dump):
return obj.model_dump()
if dataclasses.is_dataclass(obj):
- return {f.name: Dataclass.to_dict(getattr(obj, f.name)) for f in dataclasses.fields(obj)}
+ return {
+ f.name: Dataclass.to_dict(getattr(obj, f.name))
+ for f in dataclasses.fields(obj)
+ }
if isinstance(obj, dict):
return {k: Dataclass.to_dict(v) for k, v in obj.items()}
if isinstance(obj, (list, tuple)):
diff --git a/fastapi_startkit/src/fastapi_startkit/inertia/__init__.py b/fastapi_startkit/src/fastapi_startkit/inertia/__init__.py
index 0b4ebc00..84ce5dfd 100644
--- a/fastapi_startkit/src/fastapi_startkit/inertia/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/inertia/__init__.py
@@ -1,4 +1,4 @@
-from .inertia import Inertia, InertiaResponse
+from .inertia import Inertia
from .middleware import InertiaMiddleware
from .provider import InertiaProvider
diff --git a/fastapi_startkit/src/fastapi_startkit/inertia/context.py b/fastapi_startkit/src/fastapi_startkit/inertia/context.py
index f9c5218e..7f52ffa3 100644
--- a/fastapi_startkit/src/fastapi_startkit/inertia/context.py
+++ b/fastapi_startkit/src/fastapi_startkit/inertia/context.py
@@ -5,4 +5,6 @@
# Set by InertiaMiddleware before calling the next handler so InertiaResponse
# can access the current request without it being passed explicitly.
-current_request: ContextVar[Optional[Request]] = ContextVar("inertia_request", default=None)
+current_request: ContextVar[Optional[Request]] = ContextVar(
+ "inertia_request", default=None
+)
diff --git a/fastapi_startkit/src/fastapi_startkit/inertia/inertia.py b/fastapi_startkit/src/fastapi_startkit/inertia/inertia.py
index 0c97ef1e..c0b7c57a 100644
--- a/fastapi_startkit/src/fastapi_startkit/inertia/inertia.py
+++ b/fastapi_startkit/src/fastapi_startkit/inertia/inertia.py
@@ -63,7 +63,9 @@ def __init__(
self.root_view = root_view
self.version = version
- def with_(self, key: Union[str, Dict[str, Any]], value: Any = None) -> "InertiaResponse":
+ def with_(
+ self, key: Union[str, Dict[str, Any]], value: Any = None
+ ) -> "InertiaResponse":
if isinstance(key, dict):
self.props = {**self.props, **key}
else:
@@ -123,7 +125,9 @@ async def to_response(self, request: Request):
from fastapi_startkit.application import app as container
if not container().has("templates"):
- raise RuntimeError("Inertia requires 'templates' to be bound in the container for initial rendering.")
+ raise RuntimeError(
+ "Inertia requires 'templates' to be bound in the container for initial rendering."
+ )
return (
container()
@@ -183,5 +187,7 @@ def optional(callback) -> OptionalProp:
return OptionalProp(callback)
@staticmethod
- def render(component: str, props: Optional[Dict[str, Any]] = None) -> InertiaResponse:
+ def render(
+ component: str, props: Optional[Dict[str, Any]] = None
+ ) -> InertiaResponse:
return Inertia.instance().render(component, props or {})
diff --git a/fastapi_startkit/src/fastapi_startkit/inertia/middleware.py b/fastapi_startkit/src/fastapi_startkit/inertia/middleware.py
index 39a22294..b33aa057 100644
--- a/fastapi_startkit/src/fastapi_startkit/inertia/middleware.py
+++ b/fastapi_startkit/src/fastapi_startkit/inertia/middleware.py
@@ -33,7 +33,9 @@ def root_view(cls, request: Request) -> str:
"""Return the root template name for the first page visit."""
return cls._root_view
- async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -> Response:
+ async def dispatch(
+ self, request: Request, call_next: RequestResponseEndpoint
+ ) -> Response:
Inertia.version(lambda: self.version(request))
Inertia.share(self.share(request))
Inertia.set_root_view(self.root_view(request))
@@ -54,7 +56,9 @@ async def dispatch(self, request: Request, call_next: RequestResponseEndpoint) -
return response
# Version conflict — ask client to do a full page reload
- if request.method == "GET" and request.headers.get(Header.INERTIA_VERSION, "") != (Inertia.get_version() or ""):
+ if request.method == "GET" and request.headers.get(
+ Header.INERTIA_VERSION, ""
+ ) != (Inertia.get_version() or ""):
return self.on_version_change(request, response)
# 302 → 303 for PUT/PATCH/DELETE so browser issues a GET
diff --git a/fastapi_startkit/src/fastapi_startkit/inertia/provider.py b/fastapi_startkit/src/fastapi_startkit/inertia/provider.py
index cff6f871..4884b80a 100644
--- a/fastapi_startkit/src/fastapi_startkit/inertia/provider.py
+++ b/fastapi_startkit/src/fastapi_startkit/inertia/provider.py
@@ -1,7 +1,5 @@
import json
-
from fastapi_startkit.providers import Provider
-
from .inertia import Inertia
from .middleware import InertiaMiddleware
@@ -11,7 +9,7 @@ class InertiaProvider(Provider):
def register(self) -> None:
"""Bind the Inertia class to the container."""
- self.app.bind("inertia", Inertia())
+ self.app.bind("inertia", Inertia(self.app))
def boot(self) -> None:
"""Configure template globals and middleware."""
diff --git a/fastapi_startkit/src/fastapi_startkit/loader/Loader.py b/fastapi_startkit/src/fastapi_startkit/loader/Loader.py
index c243b3cd..7125f005 100644
--- a/fastapi_startkit/src/fastapi_startkit/loader/Loader.py
+++ b/fastapi_startkit/src/fastapi_startkit/loader/Loader.py
@@ -2,6 +2,7 @@
import inspect
import pkgutil
+import os
from ..exceptions import LoaderNotFound
from ..utils.str import as_filepath
@@ -33,7 +34,9 @@ def find(self, class_instance, paths, class_name, raise_exception=False):
if name == class_name:
return obj
if raise_exception:
- raise LoaderNotFound(f"No {class_instance} named {class_name} has been found in {paths}")
+ raise LoaderNotFound(
+ f"No {class_instance} named {class_name} has been found in {paths}"
+ )
return None
def find_all(self, class_instance, paths, raise_exception=False):
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/ChannelFactory.py b/fastapi_startkit/src/fastapi_startkit/logging/ChannelFactory.py
index 931b4149..3a7b5e45 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/ChannelFactory.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/ChannelFactory.py
@@ -1,4 +1,11 @@
-from .channels import DailyChannel, SingleChannel, SlackChannel, StackChannel, SyslogChannel, TerminalChannel
+from .channels import (
+ SingleChannel,
+ DailyChannel,
+ SlackChannel,
+ StackChannel,
+ SyslogChannel,
+ TerminalChannel,
+)
class ChannelFactory:
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/BaseChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/BaseChannel.py
index 741c76d0..eb47b21f 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/BaseChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/BaseChannel.py
@@ -1,5 +1,4 @@
import pendulum
-
from fastapi_startkit.facades import Config
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/DailyChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/DailyChannel.py
index 014e67d0..988e3079 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/DailyChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/DailyChannel.py
@@ -1,9 +1,7 @@
-import os
-
+from ..factory import DriverFactory
from fastapi_startkit.facades import Config
from fastapi_startkit.utils.filesystem import make_directory
-
-from ..factory import DriverFactory
+import os
from .BaseChannel import BaseChannel
@@ -13,9 +11,9 @@ def __init__(self, driver=None, path=None):
path = os.path.join(path, self.get_time().to_date_string() + ".log")
self.max_level = Config.get("logging.channels.daily.level")
make_directory(path)
- self.driver = DriverFactory.make(driver or Config.get("logging.channels.daily.driver"))(
- path=path, max_level=self.max_level
- )
+ self.driver = DriverFactory.make(
+ driver or Config.get("logging.channels.daily.driver")
+ )(path=path, max_level=self.max_level)
def debug(self, message, *args, **kwargs):
return self.driver.debug(message, *args, **kwargs)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/MultiBaseChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/MultiBaseChannel.py
index 485d1417..2be7bba4 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/MultiBaseChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/MultiBaseChannel.py
@@ -1,5 +1,4 @@
import pendulum
-
from fastapi_startkit.facades import Config
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/SingleChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/SingleChannel.py
index d1d3785c..09af81a8 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/SingleChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/SingleChannel.py
@@ -1,7 +1,8 @@
+from ..factory import DriverFactory
from fastapi_startkit.facades import Config
from fastapi_startkit.utils.filesystem import make_directory
-
-from ..factory import DriverFactory
+import os
+import pendulum
from .BaseChannel import BaseChannel
@@ -10,6 +11,6 @@ def __init__(self, driver=None, path=None):
path = path or Config.get("logging.channels.single.path")
make_directory(path)
self.max_level = Config.get("logging.channels.single.level")
- self.driver = DriverFactory.make(driver or Config.get("logging.channels.single.driver"))(
- path=path, max_level=self.max_level
- )
+ self.driver = DriverFactory.make(
+ driver or Config.get("logging.channels.single.driver")
+ )(path=path, max_level=self.max_level)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/SlackChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/SlackChannel.py
index c329a663..3adb0151 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/SlackChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/SlackChannel.py
@@ -12,9 +12,9 @@ def __init__(self, driver=None, path=None):
emoji = Config.get("logging.channels.slack.emoji")
username = Config.get("logging.channels.slack.username")
self.max_level = Config.get("logging.channels.slack.level")
- self.driver = DriverFactory.make(driver or Config.get("logging.channels.slack.driver"))(
- emoji=emoji, username=username, token=token, channel=channel
- )
+ self.driver = DriverFactory.make(
+ driver or Config.get("logging.channels.slack.driver")
+ )(emoji=emoji, username=username, token=token, channel=channel)
def debug(self, message, *args, **kwargs):
return self.driver.debug(message, *args, **kwargs)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/SyslogChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/SyslogChannel.py
index a70a8844..caeb8e22 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/SyslogChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/SyslogChannel.py
@@ -1,7 +1,8 @@
+from ..factory import DriverFactory
from fastapi_startkit.facades import Config
from fastapi_startkit.utils.filesystem import make_directory
-
-from ..factory import DriverFactory
+import os
+import pendulum
from .BaseChannel import BaseChannel
@@ -10,6 +11,6 @@ def __init__(self, driver=None, path=None):
path = path or Config.get("logging.channels.syslog.path")
make_directory(path)
self.max_level = Config.get("logging.channels.syslog.level")
- self.driver = DriverFactory.make(driver or Config.get("logging.channels.syslog.driver"))(
- path=path, max_level=self.max_level
- )
+ self.driver = DriverFactory.make(
+ driver or Config.get("logging.channels.syslog.driver")
+ )(path=path, max_level=self.max_level)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/TerminalChannel.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/TerminalChannel.py
index 2a4d19be..380b20fb 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/TerminalChannel.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/TerminalChannel.py
@@ -1,12 +1,15 @@
+import os
+
+import pendulum
from fastapi_startkit.facades import Config
-from ..channels.BaseChannel import BaseChannel
from ..factory import DriverFactory
+from ..channels.BaseChannel import BaseChannel
class TerminalChannel(BaseChannel):
def __init__(self, driver=None, path=None):
self.max_level = Config.get("logging.channels.terminal.level", "debug")
- self.driver = DriverFactory.make(driver or Config.get("logging.channels.terminal.driver"))(
- path=path, max_level=self.max_level
- )
+ self.driver = DriverFactory.make(
+ driver or Config.get("logging.channels.terminal.driver")
+ )(path=path, max_level=self.max_level)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/channels/__init__.py b/fastapi_startkit/src/fastapi_startkit/logging/channels/__init__.py
index 118a7b2d..e3bb8709 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/channels/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/channels/__init__.py
@@ -1,8 +1,8 @@
-from .BaseChannel import BaseChannel
-from .DailyChannel import DailyChannel
-from .MultiBaseChannel import MultiBaseChannel
from .SingleChannel import SingleChannel
+from .TerminalChannel import TerminalChannel
+from .DailyChannel import DailyChannel
from .SlackChannel import SlackChannel
-from .StackChannel import StackChannel
from .SyslogChannel import SyslogChannel
-from .TerminalChannel import TerminalChannel
+from .StackChannel import StackChannel
+from .BaseChannel import BaseChannel
+from .MultiBaseChannel import MultiBaseChannel
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/config/__init__.py b/fastapi_startkit/src/fastapi_startkit/logging/config/__init__.py
index c436c9f8..4cc323cc 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/config/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/config/__init__.py
@@ -1,2 +1,9 @@
-from .channels import DailyChannel, SingleChannel, SlackChannel, StackChannel, SyslogChannel, TerminalChannel
+from .channels import (
+ SingleChannel,
+ StackChannel,
+ DailyChannel,
+ TerminalChannel,
+ SlackChannel,
+ SyslogChannel,
+)
from .logging import LoggingConfig
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/config/channels.py b/fastapi_startkit/src/fastapi_startkit/logging/config/channels.py
index d935f45b..215915e5 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/config/channels.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/config/channels.py
@@ -1,5 +1,4 @@
-from dataclasses import dataclass
-
+from pydantic.dataclasses import dataclass
from pydantic.fields import Field
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/config/logging.py b/fastapi_startkit/src/fastapi_startkit/logging/config/logging.py
index d651cf71..3bfc57e6 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/config/logging.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/config/logging.py
@@ -1,12 +1,14 @@
import dataclasses
from fastapi_startkit.environment import env
-from fastapi_startkit.logging.config import DailyChannel, StackChannel, TerminalChannel
+from fastapi_startkit.logging.config import StackChannel, DailyChannel, TerminalChannel
@dataclasses.dataclass
class LoggingConfig:
- default: str = dataclasses.field(default_factory=lambda: env("LOG_CHANNEL", "stack"))
+ default: str = dataclasses.field(
+ default_factory=lambda: env("LOG_CHANNEL", "stack")
+ )
channels: dict = dataclasses.field(
default_factory=lambda: {
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/BaseDriver.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/BaseDriver.py
index 7435c354..e6ff612e 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/BaseDriver.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/BaseDriver.py
@@ -1,5 +1,4 @@
import pendulum
-
from fastapi_startkit.facades import Config
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSingleDriver.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSingleDriver.py
index 5a356db1..c6648428 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSingleDriver.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSingleDriver.py
@@ -1,5 +1,5 @@
import logging
-
+import os
from .BaseDriver import BaseDriver
@@ -10,7 +10,11 @@ def __init__(self, *args, **kwargs):
self.log = logging.getLogger("root")
handler = logging.FileHandler(self.path, "a")
- formatter = logging.Formatter("{} - %(levelname)s - %(message)s".format(self.get_time().to_datetime_string()))
+ formatter = logging.Formatter(
+ "{} - %(levelname)s - %(message)s".format(
+ self.get_time().to_datetime_string()
+ )
+ )
handler.setFormatter(formatter)
self.log.addHandler(handler)
@@ -28,40 +32,70 @@ def change_format(self, changed_format):
def emergency(self, message, *args, **kwargs):
self.log.setLevel(logging.CRITICAL)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "EMERGENCY"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "EMERGENCY"
+ )
+ )
return self.log.critical(message)
def alert(self, message, *args, **kwargs):
self.log.setLevel(logging.CRITICAL)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "ALERT"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "ALERT"
+ )
+ )
return self.log.critical(message)
def critical(self, message, *args, **kwargs):
self.log.setLevel(logging.CRITICAL)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "CRITICAL"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "CRITICAL"
+ )
+ )
return self.log.critical(message)
def error(self, message, *args, **kwargs):
self.log.setLevel(logging.ERROR)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "ERROR"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "ERROR"
+ )
+ )
return self.log.error(message)
def warning(self, message, *args, **kwargs):
self.log.setLevel(logging.WARNING)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "WARNING"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "WARNING"
+ )
+ )
return self.log.warning(message)
def notice(self, message, *args, **kwargs):
self.log.setLevel(logging.INFO)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "NOTICE"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "NOTICE"
+ )
+ )
return self.log.info(message)
def info(self, message, *args, **kwargs):
self.log.setLevel(logging.INFO)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "INFO"))
+ self.change_format(
+ "{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "INFO")
+ )
return self.log.info(message)
def debug(self, message, *args, **kwargs):
self.log.setLevel(logging.DEBUG)
- self.change_format("{} - {} - %(message)s".format(self.get_time().to_datetime_string(), "DEBUG"))
+ self.change_format(
+ "{} - {} - %(message)s".format(
+ self.get_time().to_datetime_string(), "DEBUG"
+ )
+ )
return self.log.debug(message)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSlackDriver.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSlackDriver.py
index ebcd03e4..2e837a4f 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSlackDriver.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSlackDriver.py
@@ -1,6 +1,6 @@
-import requests
-
+import os
from .BaseDriver import BaseDriver
+import requests
class LogSlackDriver(BaseDriver):
@@ -67,7 +67,9 @@ def find_channel(self, name):
Returns:
self
"""
- response = requests.post("https://slack.com/api/channels.list", {"token": self.token})
+ response = requests.post(
+ "https://slack.com/api/channels.list", {"token": self.token}
+ )
for channel in response.json()["channels"]:
if channel["name"] == name.split("#")[1]:
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSyslogDriver.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSyslogDriver.py
index a68cc3f0..a814065f 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSyslogDriver.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogSyslogDriver.py
@@ -1,8 +1,7 @@
+from .BaseDriver import BaseDriver
import logging
import logging.handlers
-from .BaseDriver import BaseDriver
-
class LogSyslogDriver(BaseDriver):
def __init__(self, *args, **kwargs):
@@ -11,7 +10,11 @@ def __init__(self, *args, **kwargs):
handler = logging.handlers.SysLogHandler(address=path)
- formatter = logging.Formatter("{} - %(levelname)s - %(message)s".format(self.get_time().to_datetime_string()))
+ formatter = logging.Formatter(
+ "{} - %(levelname)s - %(message)s".format(
+ self.get_time().to_datetime_string()
+ )
+ )
handler.setFormatter(formatter)
self.log.addHandler(handler)
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogTerminalDriver.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogTerminalDriver.py
index 3c929fc8..446fe6c3 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogTerminalDriver.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/LogTerminalDriver.py
@@ -1,5 +1,7 @@
# from logging import Logger
+import os
+from fastapi_startkit.facades import Config
from fastapi_startkit.utils.console import HasColoredOutput
from .BaseDriver import BaseDriver
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/drivers/__init__.py b/fastapi_startkit/src/fastapi_startkit/logging/drivers/__init__.py
index 45e2c4bb..043a3ab8 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/drivers/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/drivers/__init__.py
@@ -1,5 +1,5 @@
-from .BaseDriver import BaseDriver
from .LogSingleDriver import LogSingleDriver
+from .LogTerminalDriver import LogTerminalDriver
from .LogSlackDriver import LogSlackDriver
from .LogSyslogDriver import LogSyslogDriver
-from .LogTerminalDriver import LogTerminalDriver
+from .BaseDriver import BaseDriver
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/factory.py b/fastapi_startkit/src/fastapi_startkit/logging/factory.py
index e98d2cb9..51e3560f 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/factory.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/factory.py
@@ -1,4 +1,4 @@
-from .drivers import LogSingleDriver, LogSlackDriver, LogSyslogDriver, LogTerminalDriver
+from .drivers import LogSingleDriver, LogTerminalDriver, LogSlackDriver, LogSyslogDriver
class DriverFactory:
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/listeners.py b/fastapi_startkit/src/fastapi_startkit/logging/listeners.py
index 77c72517..97bdd2c5 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/listeners.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/listeners.py
@@ -8,4 +8,6 @@ def __init__(self, logger: Logger):
self.logger = logger
def handle(self, exception, file, line):
- self.logger.error("{} in {} on line {}".format(exception.__class__.__name__, file, line))
+ self.logger.error(
+ "{} in {} on line {}".format(exception.__class__.__name__, file, line)
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/logging/providers/log_provider.py b/fastapi_startkit/src/fastapi_startkit/logging/providers/log_provider.py
index 1d361416..4363e82e 100644
--- a/fastapi_startkit/src/fastapi_startkit/logging/providers/log_provider.py
+++ b/fastapi_startkit/src/fastapi_startkit/logging/providers/log_provider.py
@@ -1,7 +1,7 @@
+import os
from pathlib import Path
from fastapi_startkit.providers import Provider
-
from ..ChannelFactory import ChannelFactory
from ..config.logging import LoggingConfig
from ..factory import DriverFactory
@@ -21,7 +21,13 @@ def register(self):
self.app.bind("LoggingManager", LoggingManager(ChannelFactory, DriverFactory))
def boot(self):
- self.publishes({Path(__file__).resolve().parent.parent.joinpath("config/logging.py"): "config/logging.py"})
+ self.publishes(
+ {
+ Path(__file__)
+ .resolve()
+ .parent.parent.joinpath("config/logging.py"): "config/logging.py"
+ }
+ )
config = self.app.make("config")
if not config.get("logging.default"):
return
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/__init__.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/__init__.py
index 056f7152..a18a46cf 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/__init__.py
@@ -1,2 +1,2 @@
-from .models.fields import Field
from .models.model import Model
+from .models.fields import Field
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/config.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/config.py
index 2a5228ff..459173a5 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/config.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/config.py
@@ -1,5 +1,6 @@
import os
import pydoc
+import sys
import urllib.parse as urlparse
from .exceptions import ConfigurationNotFound, InvalidUrlConfiguration
@@ -16,11 +17,15 @@ def load_config(config_path=None):
os.environ["DB_CONFIG_PATH"] = selected_config_path
# format path as python module if needed
- selected_config_path = selected_config_path.replace("/", ".").replace("\\", ".").rstrip(".py")
+ selected_config_path = (
+ selected_config_path.replace("/", ".").replace("\\", ".").rstrip(".py")
+ )
config_module = pydoc.locate(selected_config_path)
if config_module is None:
- raise ConfigurationNotFound(f"ORM configuration file has not been found in {selected_config_path}")
+ raise ConfigurationNotFound(
+ f"ORM configuration file has not been found in {selected_config_path}"
+ )
return config_module
@@ -91,7 +96,9 @@ def db_url(database_url=None, prefix="", options={}, log_queries=False):
# lookup specified driver
driver = DRIVERS_MAP[url.scheme]
- port = str(url.port) if url.port and driver in [DRIVERS_MAP["mssql"]] else url.port
+ port = (
+ str(url.port) if url.port and driver in [DRIVERS_MAP["mssql"]] else url.port
+ )
# build final configuration
config = {
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/factories/Factory.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/factories/Factory.py
index aed8fcdb..83f24115 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/factories/Factory.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/factories/Factory.py
@@ -11,7 +11,9 @@ def faker(self):
try:
from faker import Faker
except ImportError:
- raise ImportError("Could not find the 'faker' library. Run 'pip install faker' to fix this.")
+ raise ImportError(
+ "Could not find the 'faker' library. Run 'pip install faker' to fix this."
+ )
if not Factory._faker:
Factory._faker = Faker()
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/schema/Schema.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/schema/Schema.py
index 3779ffcf..b6e0c4ab 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/schema/Schema.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/schema/Schema.py
@@ -98,7 +98,9 @@ def on(self, connection_key):
if connection_detail:
self._connection_driver = connection_detail.get("driver")
else:
- raise ConnectionNotRegistered(f"Could not find the '{connection_key}' connection details")
+ raise ConnectionNotRegistered(
+ f"Could not find the '{connection_key}' connection details"
+ )
self.connection_class = resolver._drivers.get(self._connection_driver)
@@ -184,12 +186,18 @@ async def table(self, table):
def get_connection_information(self):
return {
"host": self.connection_details.get(self.connection, {}).get("host"),
- "database": self.connection_details.get(self.connection, {}).get("database"),
+ "database": self.connection_details.get(self.connection, {}).get(
+ "database"
+ ),
"user": self.connection_details.get(self.connection, {}).get("user"),
"port": self.connection_details.get(self.connection, {}).get("port"),
- "password": self.connection_details.get(self.connection, {}).get("password"),
+ "password": self.connection_details.get(self.connection, {}).get(
+ "password"
+ ),
"prefix": self.connection_details.get(self.connection, {}).get("prefix"),
- "options": self.connection_details.get(self.connection, {}).get("options", {}),
+ "options": self.connection_details.get(self.connection, {}).get(
+ "options", {}
+ ),
"full_details": self.connection_details.get(self.connection),
}
@@ -200,7 +208,9 @@ async def new_connection(self):
# TODO: review
if not self._connection:
connection_details = self.get_connection_information().get("full_details")
- self._connection = self.connection_class(connection_details=connection_details, name=self.connection)
+ self._connection = self.connection_class(
+ connection_details=connection_details, name=self.connection
+ )
if hasattr(self._connection, "set_schema"):
self._connection.set_schema(self.schema)
await self._connection.make_connection()
@@ -225,7 +235,9 @@ async def has_column(self, table, column, query_only=False):
return bool(await (await self.new_connection()).query(sql, ()))
async def get_columns(self, table, dict=True):
- table = self.platform().get_current_schema(await self.new_connection(), table, schema=self.get_schema())
+ table = self.platform().get_current_schema(
+ await self.new_connection(), table, schema=self.get_schema()
+ )
result = {}
if dict:
for column in table.get_added_columns().items():
@@ -280,7 +292,9 @@ async def truncate(self, table, foreign_keys=False):
def get_schema(self):
"""Gets the schema set on the migration class"""
- return self.schema or self.get_connection_information().get("full_details").get("schema")
+ return self.schema or self.get_connection_information().get("full_details").get(
+ "schema"
+ )
async def get_all_tables(self):
"""Gets all tables in the database"""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/SoftDeleteScope.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/SoftDeleteScope.py
index 2b6ea510..c53df3d1 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/SoftDeleteScope.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/SoftDeleteScope.py
@@ -24,7 +24,9 @@ def on_remove(self, builder):
builder.remove_global_scope("_query_set_null_on_delete", action="delete")
def _where_null(self, builder):
- return builder.where_null(f"{builder.get_table_name()}.{self.deleted_at_column}")
+ return builder.where_null(
+ f"{builder.get_table_name()}.{self.deleted_at_column}"
+ )
def _with_trashed(self, model, builder):
builder.remove_global_scope("_where_null", action="select")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/UUIDPrimaryKeyScope.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/UUIDPrimaryKeyScope.py
index 30b4bee4..96e26b7c 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/UUIDPrimaryKeyScope.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/scopes/UUIDPrimaryKeyScope.py
@@ -7,7 +7,9 @@ class UUIDPrimaryKeyScope(BaseScope):
"""Global scope class to use UUID4 as primary key."""
def on_boot(self, builder):
- builder.set_global_scope("_UUID_primary_key", self.set_uuid_create, action="insert")
+ builder.set_global_scope(
+ "_UUID_primary_key", self.set_uuid_create, action="insert"
+ )
builder.set_global_scope(
"_UUID_primary_key",
self.set_bulk_uuid_create,
@@ -32,7 +34,11 @@ def generate_uuid(self, builder, uuid_version, bytes=False):
def build_uuid_pk(self, builder):
uuid_version = getattr(builder._model, "__uuid_version__", 4)
uuid_bytes = getattr(builder._model, "__uuid_bytes__", False)
- return {builder._model.__primary_key__: self.generate_uuid(builder, uuid_version, uuid_bytes)}
+ return {
+ builder._model.__primary_key__: self.generate_uuid(
+ builder, uuid_version, uuid_bytes
+ )
+ }
def set_uuid_create(self, builder):
# if there is already a primary key, no need to set a new one
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/BaseTestCaseSelectGrammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/BaseTestCaseSelectGrammar.py
index b3035306..7ca3a9db 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/BaseTestCaseSelectGrammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/BaseTestCaseSelectGrammar.py
@@ -25,131 +25,205 @@ def setUp(self):
def test_can_compile_select(self):
to_sql = self.builder.to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_order_by_and_first(self):
to_sql = self.builder.order_by("id", "asc").first(query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_columns(self):
to_sql = self.builder.select("username", "password").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_where(self):
to_sql = self.builder.select("username", "password").where("id", 1).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_or_where(self):
to_sql = self.builder.where("name", 2).or_where("name", 3).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_grouped_where(self):
- to_sql = self.builder.where(lambda query: query.where("age", 2).where("name", "Joe")).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = self.builder.where(
+ lambda query: query.where("age", 2).where("name", "Joe")
+ ).to_sql()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_several_where(self):
- to_sql = self.builder.select("username", "password").where("id", 1).where("username", "joe").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.select("username", "password")
+ .where("id", 1)
+ .where("username", "joe")
+ .to_sql()
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_several_where_and_limit(self):
- to_sql = self.builder.select("username", "password").where("id", 1).where("username", "joe").limit(10).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.select("username", "password")
+ .where("id", 1)
+ .where("username", "joe")
+ .limit(10)
+ .to_sql()
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_sum(self):
to_sql = self.builder.sum("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_max(self):
to_sql = self.builder.max("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_max_and_columns(self):
to_sql = self.builder.select("username").max("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_max_and_columns_different_order(self):
to_sql = self.builder.max("age").select("username").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_order_by(self):
to_sql = self.builder.select("username").order_by("age", "desc").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_multiple_order_by(self):
- to_sql = self.builder.select("username").order_by("age", "desc").order_by("name").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.select("username")
+ .order_by("age", "desc")
+ .order_by("name")
+ .to_sql()
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_with_group_by(self):
to_sql = self.builder.select("username").group_by("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_in(self):
to_sql = self.builder.select("username").where_in("age", [1, 2, 3]).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_in_empty(self):
to_sql = self.builder.where_in("age", []).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_not_in(self):
to_sql = self.builder.select("username").where_not_in("age", [1, 2, 3]).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_null(self):
to_sql = self.builder.select("username").where_null("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_not_null(self):
to_sql = self.builder.select("username").where_not_null("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_count(self):
to_sql = self.builder.count("*").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_count_column(self):
to_sql = self.builder.count("money").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_column(self):
to_sql = self.builder.where_column("name", "email").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_sub_select(self):
- to_sql = self.builder.where_in("name", self.builder.new().select("age")).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = self.builder.where_in(
+ "name", self.builder.new().select("age")
+ ).to_sql()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_complex_sub_select(self):
to_sql = self.builder.where_in(
"name",
- (self.builder.new().select("age").where_in("email", self.builder.new().select("email"))),
+ (
+ self.builder.new()
+ .select("age")
+ .where_in("email", self.builder.new().select("email"))
+ ),
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_sub_select_where(self):
@@ -157,7 +231,9 @@ def test_can_compile_sub_select_where(self):
"age",
self.builder.new().select("age").where("age", 2).where("name", "Joe"),
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_sub_select_from_lambda(self):
@@ -174,41 +250,61 @@ def test_can_compile_sub_select_from_lambda(self):
def test_can_compile_sub_select_value(self):
to_sql = self.builder.where("name", self.builder.new().sum("age")).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_exists(self):
to_sql = (
- self.builder.select("age").where_exists(self.builder.new().select("username").where("age", 12)).to_sql()
+ self.builder.select("age")
+ .where_exists(self.builder.new().select("username").where("age", 12))
+ .to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_not_exists(self):
to_sql = (
- self.builder.select("age").where_not_exists(self.builder.new().select("username").where("age", 12)).to_sql()
+ self.builder.select("age")
+ .where_not_exists(self.builder.new().select("username").where("age", 12))
+ .to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_having(self):
to_sql = self.builder.sum("age").group_by("age").having("age").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_having_with_expression(self):
to_sql = self.builder.sum("age").group_by("age").having("age", 10).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_having_with_greater_than_expression(self):
to_sql = self.builder.sum("age").group_by("age").having("age", ">", 10).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join(self):
- to_sql = self.builder.join("contacts", "users.id", "=", "contacts.user_id").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = self.builder.join(
+ "contacts", "users.id", "=", "contacts.user_id"
+ ).to_sql()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join_clause(self):
@@ -221,30 +317,50 @@ def test_can_compile_join_clause(self):
)
to_sql = self.builder.join(clause).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join_clause_with_value(self):
- clause = JoinClause("report_groups as rg").on_value("bgt.active", "=", "1").or_on_value("bgt.acct", "=", "1234")
+ clause = (
+ JoinClause("report_groups as rg")
+ .on_value("bgt.active", "=", "1")
+ .or_on_value("bgt.acct", "=", "1234")
+ )
to_sql = self.builder.join(clause).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join_clause_with_null(self):
- clause = JoinClause("report_groups as rg").on_null("bgt.acct").or_on_null("bgt.dept").on_value("rg.abc", 10)
+ clause = (
+ JoinClause("report_groups as rg")
+ .on_null("bgt.acct")
+ .or_on_null("bgt.dept")
+ .on_value("rg.abc", 10)
+ )
to_sql = self.builder.join(clause).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join_clause_with_not_null(self):
clause = (
- JoinClause("report_groups as rg").on_not_null("bgt.acct").or_on_not_null("bgt.dept").on_value("rg.abc", 10)
+ JoinClause("report_groups as rg")
+ .on_not_null("bgt.acct")
+ .or_on_not_null("bgt.dept")
+ .on_value("rg.abc", 10)
)
to_sql = self.builder.join(clause).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_join_clause_with_lambda(self):
@@ -253,7 +369,9 @@ def test_can_compile_join_clause_with_lambda(self):
lambda clause: clause.on("bgt.fund", "=", "rg.fund").on_null("bgt"),
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_left_join_clause_with_lambda(self):
@@ -262,7 +380,9 @@ def test_can_compile_left_join_clause_with_lambda(self):
lambda clause: clause.on("bgt.fund", "=", "rg.fund").or_on_null("bgt"),
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_right_join_clause_with_lambda(self):
@@ -271,12 +391,18 @@ def test_can_compile_right_join_clause_with_lambda(self):
lambda clause: clause.on("bgt.fund", "=", "rg.fund").or_on_null("bgt"),
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_left_join(self):
- to_sql = self.builder.left_join("contacts", "users.id", "=", "contacts.user_id").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = self.builder.left_join(
+ "contacts", "users.id", "=", "contacts.user_id"
+ ).to_sql()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_multiple_join(self):
@@ -285,93 +411,135 @@ def test_can_compile_multiple_join(self):
.join("posts", "comments.post_id", "=", "posts.id")
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_limit_and_offset(self):
to_sql = self.builder.limit(10).offset(10).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_between(self):
to_sql = self.builder.between("age", 18, 21).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_not_between(self):
to_sql = self.builder.not_between("age", 18, 21).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_user_where_raw_and_where(self):
- to_sql = self.builder.where_raw("age = '18'").where("name", "=", "James").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.where_raw("age = '18'").where("name", "=", "James").to_sql()
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_where_raw_and_where_with_multiple_bindings(self):
- query = self.builder.where_raw("`age` = ? AND `is_admin` = ?", [18, True]).where("email", "test@example.com")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ query = self.builder.where_raw(
+ "`age` = ? AND `is_admin` = ?", [18, True]
+ ).where("email", "test@example.com")
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(query.to_qmark(), sql)
self.assertEqual(query._bindings, [18, True, "test@example.com"])
def test_can_compile_first_or_fail(self):
- to_sql = self.builder.where("is_admin", "=", True).first_or_fail(query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.where("is_admin", "=", True).first_or_fail(query=True).to_sql()
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_where_like(self):
to_sql = self.builder.where("age", "like", "%name%").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_where_regexp(self):
to_sql = self.builder.where("age", "regexp", "Joe").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_where_exists_with_lambda(self):
to_sql = self.builder.where_exists(lambda q: q.where("age", 1)).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
print(to_sql)
self.assertEqual(to_sql, sql)
def test_where_not_exists_with_lambda(self):
to_sql = self.builder.where_not_exists(lambda q: q.where("age", 1)).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
print(to_sql)
self.assertEqual(to_sql, sql)
def test_where_not_regexp(self):
to_sql = self.builder.where("age", "not regexp", "Joe").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_where_not_like(self):
to_sql = self.builder.where("age", "not like", "%name%").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_shared_lock(self):
to_sql = self.builder.where("votes", ">=", 100).shared_lock().to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_update_lock(self):
to_sql = self.builder.where("votes", ">=", 100).lock_for_update().to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_where_date(self):
to_sql = self.builder.where_date("created_at", "2022-06-01").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_or_where_null(self):
to_sql = self.builder.where_null("column1").or_where_null("column2").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_select_distinct(self):
to_sql = self.builder.select("group").distinct().to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/Database.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/Database.py
index 250368d8..02908b40 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/Database.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/Database.py
@@ -1,3 +1,4 @@
+import os
from ..config import load_config
from ..migrations import Migration
from ..seeds import Seeder
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/TestCase.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/TestCase.py
index a95bc653..e94956e2 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/TestCase.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/TestCase.py
@@ -1,5 +1,4 @@
from unittest import IsolatedAsyncioTestCase
-
from .Database import Database
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/__init__.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/__init__.py
index 658eb527..bca81271 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/testing/__init__.py
@@ -1,2 +1,2 @@
-from .Database import Database
from .TestCase import TestCase
+from .Database import Database
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/collection/test_collection.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/collection/test_collection.py
index a6b4307a..7553fd08 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/collection/test_collection.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/collection/test_collection.py
@@ -14,7 +14,9 @@
class TestCollection(unittest.IsolatedAsyncioTestCase):
async def asyncSetUp(self):
# Set config path for Schema.on() to work in tests
- os.environ["DB_CONFIG_PATH"] = "fastapi_startkit.masoniteorm.tests.integrations.config.database"
+ os.environ["DB_CONFIG_PATH"] = (
+ "fastapi_startkit.masoniteorm.tests.integrations.config.database"
+ )
self.schema = Schema(
connection="dev",
@@ -39,7 +41,9 @@ async def asyncSetUp(self):
User.__connection__ = "dev"
# Seed data
- await User.create({"name": "Joe", "email": "joe@example.com", "password": "password"})
+ await User.create(
+ {"name": "Joe", "email": "joe@example.com", "password": "password"}
+ )
async def asyncTearDown(self):
# Drop table while still on 'dev' connection
@@ -269,7 +273,9 @@ def test_count(self):
collection = Collection([1, 1, 2, 4])
self.assertEqual(collection.count(), 4)
- collection = Collection([{"name": "Corentin All", "age": 1}, {"name": "Corentin All", "age": 2}])
+ collection = Collection(
+ [{"name": "Corentin All", "age": 1}, {"name": "Corentin All", "age": 2}]
+ )
self.assertEqual(collection.count(), 2)
def test_chunk(self):
@@ -391,7 +397,9 @@ def test_reject(self):
collection.reject(lambda x: x if x["age"] > 2 else None)
self.assertEqual(
- Collection([{"name": "Corentin All", "age": 3}, {"name": "Corentin All", "age": 4}]),
+ Collection(
+ [{"name": "Corentin All", "age": 3}, {"name": "Corentin All", "age": 4}]
+ ),
collection.all(),
)
@@ -532,7 +540,9 @@ def test_implode(self):
result = collection.implode("-")
self.assertEqual(result, "1-2-3-4")
- collection = Collection([{"name": "Corentin"}, {"name": "Joe"}, {"name": "Marlysson"}])
+ collection = Collection(
+ [{"name": "Corentin"}, {"name": "Joe"}, {"name": "Marlysson"}]
+ )
result = collection.implode(key="name")
self.assertEqual(result, "Corentin,Joe,Marlysson")
@@ -547,7 +557,9 @@ def __eq__(self, other):
return self.code == other.code
currencies = collection.map_into(Currency)
- self.assertEqual(currencies.all(), [Currency("USD"), Currency("EUR"), Currency("GBP")])
+ self.assertEqual(
+ currencies.all(), [Currency("USD"), Currency("EUR"), Currency("GBP")]
+ )
def test_map(self):
collection = Collection([1, 2, 3, 4])
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/commands/test_shell.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/commands/test_shell.py
index 7d18f371..50735da0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/commands/test_shell.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/commands/test_shell.py
@@ -1,5 +1,4 @@
import unittest
-
from cleo.testers.command_tester import CommandTester
from fastapi_startkit.masoniteorm.commands import ShellCommand
@@ -63,7 +62,10 @@ def test_for_mssql(self):
"full_details": {"driver": "mssql"},
}
command, _ = self.command.get_command(config)
- assert command == "sqlcmd -d orm -U root -P secretpostgres -S tcp:db.masonite.com,1234"
+ assert (
+ command
+ == "sqlcmd -d orm -U root -P secretpostgres -S tcp:db.masonite.com,1234"
+ )
def test_running_command_with_sqlite(self):
self.command_tester.execute("-c dev")
@@ -82,4 +84,6 @@ def test_hiding_sensitive_options(self):
}
command, _ = self.command.get_command(config)
cleaned_command = self.command.hide_sensitive_options(config, command)
- assert cleaned_command == "mysql orm --host localhost --user root --password ***"
+ assert (
+ cleaned_command == "mysql orm --host localhost --user root --password ***"
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/eagers/test_eager.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/eagers/test_eager.py
index 759f64bb..b162c180 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/eagers/test_eager.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/eagers/test_eager.py
@@ -5,7 +5,9 @@
class TestEagerRelation(unittest.TestCase):
def test_can_register_string_eager_load(self):
- self.assertEqual(EagerRelations().register("profile").get_eagers(), [["profile"]])
+ self.assertEqual(
+ EagerRelations().register("profile").get_eagers(), [["profile"]]
+ )
self.assertEqual(EagerRelations().register("profile").is_nested, False)
self.assertEqual(
EagerRelations().register("profile.user").get_eagers(),
@@ -16,7 +18,9 @@ def test_can_register_string_eager_load(self):
[{"profile": ["user", "logo"]}],
)
self.assertEqual(
- EagerRelations().register("profile.user", "profile.logo", "profile.bio").get_eagers(),
+ EagerRelations()
+ .register("profile.user", "profile.logo", "profile.bio")
+ .get_eagers(),
[{"profile": ["user", "logo", "bio"]}],
)
self.assertEqual(
@@ -25,7 +29,9 @@ def test_can_register_string_eager_load(self):
)
def test_can_register_tuple_eager_load(self):
- self.assertEqual(EagerRelations().register(("profile",)).get_eagers(), [["profile"]])
+ self.assertEqual(
+ EagerRelations().register(("profile",)).get_eagers(), [["profile"]]
+ )
self.assertEqual(
EagerRelations().register(("profile", "user")).get_eagers(),
[["profile", "user"]],
@@ -36,7 +42,9 @@ def test_can_register_tuple_eager_load(self):
)
def test_can_register_list_eager_load(self):
- self.assertEqual(EagerRelations().register(["profile"]).get_eagers(), [["profile"]])
+ self.assertEqual(
+ EagerRelations().register(["profile"]).get_eagers(), [["profile"]]
+ )
self.assertEqual(
EagerRelations().register(["profile", "user"]).get_eagers(),
[["profile", "user"]],
@@ -54,6 +62,8 @@ def test_can_register_list_eager_load(self):
[["logo"], {"profile": ["name"]}],
)
self.assertEqual(
- EagerRelations().register(["profile.name", "logo", "profile.user"]).get_eagers(),
+ EagerRelations()
+ .register(["profile.name", "logo", "profile.user"])
+ .get_eagers(),
[["logo"], {"profile": ["name", "user"]}],
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/config/database.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/config/database.py
index 0fc3199b..d963cdae 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/config/database.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/config/database.py
@@ -7,6 +7,7 @@
from fastapi_startkit.masoniteorm.connections.factory import ConnectionFactory
+
load_dotenv(".env")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/model.py
index f44c77f9..ca04b543 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/model.py
@@ -1,7 +1,9 @@
-from dataclasses import asdict, dataclass
+from dataclasses import dataclass, asdict
from enum import StrEnum
+from fastapi_startkit.carbon import Carbon
from fastapi_startkit.masoniteorm import Model
+from fastapi_startkit.masoniteorm.models.fields import Field
@dataclass
@@ -16,7 +18,11 @@ def get(self, value):
if isinstance(value, str):
value = json.loads(value)
- return Address(city=value.get("city"), country=value.get("country"), street=value.get("street"))
+ return Address(
+ city=value.get("city"),
+ country=value.get("country"),
+ street=value.get("street"),
+ )
def set(self, value):
import json
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/test_model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/test_model.py
index fc03b590..b516bd10 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/test_model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/integrations/test_model.py
@@ -1,16 +1,20 @@
from fastapi_startkit.masoniteorm.testing import TestCase
-from fastapi_startkit.masoniteorm.tests.integrations.model import Address, Gender, User
+from fastapi_startkit.masoniteorm.tests.integrations.model import User, Gender, Address
class TestModelCast(TestCase):
- migration_directory = "src/fastapi_startkit/masoniteorm/tests/integrations/databases/migrations"
+ migration_directory = (
+ "src/fastapi_startkit/masoniteorm/tests/integrations/databases/migrations"
+ )
async def test_database_is_isolated(self):
user = await User.first()
self.assertIsNone(user)
async def test_first_record_can_be_fetch(self):
- await User.create(name="Joe", username="joe", email="joe@test.com", password="password")
+ await User.create(
+ name="Joe", username="joe", email="joe@test.com", password="password"
+ )
user = await User.first()
self.assertEqual(user.name, "Joe")
@@ -19,7 +23,14 @@ async def test_first_record_can_be_fetch(self):
self.assertEqual(user.password, "password")
async def test_can_create_with_dict(self):
- await User.create({"name": "Jane", "username": "jane", "email": "jane@test.com", "password": "password"})
+ await User.create(
+ {
+ "name": "Jane",
+ "username": "jane",
+ "email": "jane@test.com",
+ "password": "password",
+ }
+ )
user = await User.first()
self.assertEqual(user.name, "Jane")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/models/test_models.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/models/test_models.py
index a1e518f7..59d7a65b 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/models/test_models.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/models/test_models.py
@@ -61,14 +61,22 @@ def test_model_can_access_str_dates_as_pendulum_from_correct_datetimes(
):
model = ModelTest()
- self.assertEqual(model.get_new_date(datetime.datetime(2021, 1, 1, 7, 10)).hour, 7)
+ self.assertEqual(
+ model.get_new_date(datetime.datetime(2021, 1, 1, 7, 10)).hour, 7
+ )
self.assertEqual(model.get_new_date(datetime.date(2021, 1, 1)).hour, 0)
self.assertEqual(model.get_new_date(datetime.time(1, 1, 1)).hour, 1)
self.assertEqual(model.get_new_date("2020-11-28 11:42:07").hour, 11)
def test_model_can_access_str_dates_on_relationships(self):
model = ModelTest.hydrate({"user": "joe", "due_date": "2020-11-28 11:42:07"})
- model.add_relation({"profile": ModelTest.hydrate({"name": "bob", "due_date": "2020-11-28 11:42:07"})})
+ model.add_relation(
+ {
+ "profile": ModelTest.hydrate(
+ {"name": "bob", "due_date": "2020-11-28 11:42:07"}
+ )
+ }
+ )
self.assertEqual(model.profile.name, "bob")
self.assertTrue(model.profile.due_date.is_past())
@@ -77,7 +85,9 @@ def test_model_original_and_dirty_attributes(self):
model = ModelTest.hydrate({"username": "joe", "admin": True})
self.assertEqual(model.username, "joe")
- self.assertEqual(model.__original_attributes__, {"username": "joe", "admin": True})
+ self.assertEqual(
+ model.__original_attributes__, {"username": "joe", "admin": True}
+ )
model.username = "bob"
@@ -87,7 +97,9 @@ def test_model_original_and_dirty_attributes(self):
self.assertEqual(model.__dirty_attributes__["username"], "bob")
self.assertEqual(model.get_dirty_keys(), ["username"])
self.assertTrue(model.is_dirty() is True)
- self.assertEqual(model.__original_attributes__, {"username": "joe", "admin": True})
+ self.assertEqual(
+ model.__original_attributes__, {"username": "joe", "admin": True}
+ )
def test_model_creates_when_new(self):
model = ModelTest.hydrate({"id": 1, "username": "joe", "admin": True})
@@ -161,15 +173,21 @@ def test_model_can_cast_dict_attributes(self):
self.assertEqual(type(model.d), Decimal)
def test_valid_json_cast(self):
- model = ModelTest.hydrate({"payload": {"this": "dict", "is": "usable", "as": "json"}})
+ model = ModelTest.hydrate(
+ {"payload": {"this": "dict", "is": "usable", "as": "json"}}
+ )
self.assertEqual(type(model.payload), dict)
- model = ModelTest.hydrate({"payload": {"this": "dict", "is": "invalid", "as": "json"}})
+ model = ModelTest.hydrate(
+ {"payload": {"this": "dict", "is": "invalid", "as": "json"}}
+ )
self.assertEqual(type(model.payload), dict)
- model = ModelTest.hydrate({"payload": '{"this": "dict", "is": "usable", "as": "json"}'})
+ model = ModelTest.hydrate(
+ {"payload": '{"this": "dict", "is": "usable", "as": "json"}'}
+ )
self.assertEqual(type(model.payload), dict)
@@ -186,7 +204,9 @@ def test_valid_json_cast(self):
model.save()
def test_model_update_without_changes(self):
- model = ModelTest.hydrate({"id": 1, "username": "joe", "name": "Joe", "admin": True})
+ model = ModelTest.hydrate(
+ {"id": 1, "username": "joe", "name": "Joe", "admin": True}
+ )
model.username = "joe"
model.name = "Bill"
@@ -195,7 +215,9 @@ def test_model_update_without_changes(self):
self.assertNotIn("username", sql)
def test_force_update_on_model_class(self):
- model = ModelTestForced.hydrate({"id": 1, "username": "joe", "name": "Joe", "admin": True})
+ model = ModelTestForced.hydrate(
+ {"id": 1, "username": "joe", "name": "Joe", "admin": True}
+ )
model.username = "joe"
model.name = "Bill"
@@ -205,13 +227,17 @@ def test_force_update_on_model_class(self):
self.assertIn("name", sql)
def test_only_method(self):
- model = ModelTestForced.hydrate({"id": 1, "username": "joe", "name": "Joe", "admin": True})
+ model = ModelTestForced.hydrate(
+ {"id": 1, "username": "joe", "name": "Joe", "admin": True}
+ )
self.assertEqual({"username": "joe"}, model.only("username"))
self.assertEqual({"username": "joe"}, model.only(["username"]))
def test_model_update_without_changes_at_all(self):
- model = ModelTest.hydrate({"id": 1, "username": "joe", "name": "Joe", "admin": True})
+ model = ModelTest.hydrate(
+ {"id": 1, "username": "joe", "name": "Joe", "admin": True}
+ )
model.username = "joe"
model.name = "Joe"
@@ -232,7 +258,11 @@ def test_model_using_or_where_and_chaining_wheres(self):
sql = (
model.where("name", "=", "joe")
- .or_where(lambda query: query.where("username", "Joseph").or_where("age", ">=", 18))
+ .or_where(
+ lambda query: query.where("username", "Joseph").or_where(
+ "age", ">=", 18
+ )
+ )
.to_sql()
)
@@ -272,7 +302,9 @@ def test_model_can_provide_default_select(self):
)
def test_model_can_override_to_default_select(self):
- sql = ModelWithBaseModel.select(["products.name", "products.id", "store.name"]).to_sql()
+ sql = ModelWithBaseModel.select(
+ ["products.name", "products.id", "store.name"]
+ ).to_sql()
self.assertEqual(
sql,
"""SELECT `products`.`name`, `products`.`id`, `store`.`name` FROM `users`""",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder.py
index bdc51648..206f72b5 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder.py
@@ -38,7 +38,9 @@ def test_sum(self):
builder = self.get_builder()
builder.sum("age")
- self.assertEqual(builder.to_sql(), "SELECT SUM([users].[age]) AS age FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT SUM([users].[age]) AS age FROM [users]"
+ )
def test_where_like(self):
builder = self.get_builder()
@@ -62,19 +64,25 @@ def test_max(self):
builder = self.get_builder()
builder.max("age")
- self.assertEqual(builder.to_sql(), "SELECT MAX([users].[age]) AS age FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT MAX([users].[age]) AS age FROM [users]"
+ )
def test_min(self):
builder = self.get_builder()
builder.min("age")
- self.assertEqual(builder.to_sql(), "SELECT MIN([users].[age]) AS age FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT MIN([users].[age]) AS age FROM [users]"
+ )
def test_avg(self):
builder = self.get_builder()
builder.avg("age")
- self.assertEqual(builder.to_sql(), "SELECT AVG([users].[age]) AS age FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT AVG([users].[age]) AS age FROM [users]"
+ )
def test_all(self):
builder = self.get_builder()
@@ -122,7 +130,9 @@ def test_select_raw(self):
builder = self.get_builder()
builder.select_raw("count(email) as email_count")
- self.assertEqual(builder.to_sql(), "SELECT count(email) as email_count FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT count(email) as email_count FROM [users]"
+ )
def test_create(self):
builder = self.get_builder().without_global_scopes()
@@ -199,7 +209,9 @@ def test_right_join(self):
)
def test_update(self):
- builder = self.get_builder().update({"name": "Joe", "email": "joe@yopmail.com"}, dry=True)
+ builder = self.get_builder().update(
+ {"name": "Joe", "email": "joe@yopmail.com"}, dry=True
+ )
self.assertEqual(
builder.to_sql(),
"UPDATE [users] SET [users].[name] = 'Joe', [users].[email] = 'joe@yopmail.com'",
@@ -222,7 +234,9 @@ def test_update(self):
def test_count(self):
builder = self.get_builder()
builder.count("id")
- self.assertEqual(builder.to_sql(), "SELECT COUNT([users].[id]) AS id FROM [users]")
+ self.assertEqual(
+ builder.to_sql(), "SELECT COUNT([users].[id]) AS id FROM [users]"
+ )
def test_order_by_asc(self):
builder = self.get_builder()
@@ -232,7 +246,9 @@ def test_order_by_asc(self):
def test_order_by_desc(self):
builder = self.get_builder()
builder.order_by("email", "desc")
- self.assertEqual(builder.to_sql(), "SELECT * FROM [users] ORDER BY [email] DESC")
+ self.assertEqual(
+ builder.to_sql(), "SELECT * FROM [users] ORDER BY [email] DESC"
+ )
def test_where_column(self):
builder = self.get_builder()
@@ -295,7 +311,9 @@ def test_where_not_null(self):
def test_having(self):
builder = self.get_builder(table="payments")
- builder.select("user_id").avg("salary").group_by("user_id").having("salary", ">=", "1000")
+ builder.select("user_id").avg("salary").group_by("user_id").having(
+ "salary", ">=", "1000"
+ )
self.assertEqual(
builder.to_sql(),
@@ -382,7 +400,12 @@ def test_or_where(self):
def test_can_call_with_schema(self):
builder = self.get_builder()
- sql = builder.table("information_schema.columns").select("table_name").where("table_name", "users").to_sql()
+ sql = (
+ builder.table("information_schema.columns")
+ .select("table_name")
+ .where("table_name", "users")
+ .to_sql()
+ )
self.assertEqual(
sql,
"""SELECT [information_schema].[columns].[table_name] FROM [information_schema].[columns] WHERE [information_schema].[columns].[table_name] = 'users'""",
@@ -401,7 +424,9 @@ def test_truncate_without_foreign_keys(self):
def test_latest(self):
builder = self.get_builder()
builder.latest("email")
- self.assertEqual(builder.to_sql(), "SELECT * FROM [users] ORDER BY [email] DESC")
+ self.assertEqual(
+ builder.to_sql(), "SELECT * FROM [users] ORDER BY [email] DESC"
+ )
def test_latest_multiple(self):
builder = self.get_builder()
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder_relationships.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder_relationships.py
index 42c3d82f..82350dc4 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder_relationships.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/builder/test_mssql_query_builder_relationships.py
@@ -1,6 +1,7 @@
import unittest
from dotenv import load_dotenv
+
from src.masoniteorm.models import Model
from src.masoniteorm.query import QueryBuilder
from src.masoniteorm.query.grammars import MSSQLGrammar
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_delete_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_delete_grammar.py
index 07a44114..1e5007a0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_delete_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_delete_grammar.py
@@ -15,7 +15,15 @@ def test_can_compile_delete(self):
self.assertEqual(to_sql, sql)
def test_can_compile_delete_with_where(self):
- to_sql = self.builder.where("age", 20).where("profile", 1).set_action("delete").delete(query=True).to_sql()
+ to_sql = (
+ self.builder.where("age", 20)
+ .where("profile", 1)
+ .set_action("delete")
+ .delete(query=True)
+ .to_sql()
+ )
- sql = "DELETE FROM [users] WHERE [users].[age] = '20' AND [users].[profile] = '1'"
+ sql = (
+ "DELETE FROM [users] WHERE [users].[age] = '20' AND [users].[profile] = '1'"
+ )
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_insert_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_insert_grammar.py
index ca69af6c..8980db78 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_insert_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_insert_grammar.py
@@ -29,7 +29,9 @@ def test_can_compile_bulk_create(self):
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_qmark(self):
- to_sql = self.builder.bulk_create([{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True).to_qmark()
+ to_sql = self.builder.bulk_create(
+ [{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True
+ ).to_qmark()
sql = "INSERT INTO [users] ([name]) VALUES (?), (?), (?)"
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_select_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_select_grammar.py
index 7860c318..a0595df8 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_select_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_select_grammar.py
@@ -117,7 +117,9 @@ def can_compile_where_raw(self):
return "SELECT * FROM [users] WHERE [users].[age] = '18'"
def test_can_compile_where_raw_and_where_with_multiple_bindings(self):
- query = self.builder.where_raw("[age] = ? AND [is_admin] = ?", [18, True]).where("email", "test@example.com")
+ query = self.builder.where_raw(
+ "[age] = ? AND [is_admin] = ?", [18, True]
+ ).where("email", "test@example.com")
self.assertEqual(
query.to_qmark(),
"SELECT * FROM [users] WHERE [age] = ? AND [is_admin] = ? AND [users].[email] = ?",
@@ -173,7 +175,9 @@ def can_compile_or_where(self):
"""
self.builder.where('name', 2).or_where('name', 3).to_sql()
"""
- return "SELECT * FROM [users] WHERE [users].[name] = '2' OR [users].[name] = '3'"
+ return (
+ "SELECT * FROM [users] WHERE [users].[name] = '2' OR [users].[name] = '3'"
+ )
def can_grouped_where(self):
"""
@@ -300,12 +304,21 @@ def test_can_compile_where_raw(self):
self.assertEqual(to_sql, "SELECT * FROM [users] WHERE [age] = '18'")
def test_can_compile_having_raw(self):
- to_sql = self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").to_sql()
- self.assertEqual(to_sql, "SELECT COUNT(*) as counts FROM [users] HAVING counts > 10")
+ to_sql = (
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .to_sql()
+ )
+ self.assertEqual(
+ to_sql, "SELECT COUNT(*) as counts FROM [users] HAVING counts > 10"
+ )
def test_can_compile_having_raw_order(self):
to_sql = (
- self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").order_by_raw("counts DESC").to_sql()
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .order_by_raw("counts DESC")
+ .to_sql()
)
self.assertEqual(
to_sql,
@@ -314,12 +327,16 @@ def test_can_compile_having_raw_order(self):
def test_can_compile_select_raw(self):
to_sql = self.builder.select_raw("COUNT(*)").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_select_raw_with_select(self):
to_sql = self.builder.select("id").select_raw("COUNT(*)").to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def can_compile_first_or_fail(self):
@@ -380,9 +397,7 @@ def can_compile_join_clause_with_value(self):
)
builder.join(clause).to_sql()
"""
- return (
- "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[active] = '1' OR [bgt].[acct] = '1234'"
- )
+ return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[active] = '1' OR [bgt].[acct] = '1234'"
def can_compile_join_clause_with_null(self):
"""
@@ -421,9 +436,7 @@ def can_compile_join_clause_with_lambda(self):
),
).to_sql()
"""
- return (
- "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[fund] = [rg].[fund] AND [bgt] IS NULL"
- )
+ return "SELECT * FROM [users] INNER JOIN [report_groups] AS [rg] ON [bgt].[fund] = [rg].[fund] AND [bgt] IS NULL"
def can_compile_left_join_clause_with_lambda(self):
"""
@@ -478,7 +491,9 @@ def where_not_exists_with_lambda(self):
return """SELECT * FROM [users] WHERE NOT EXISTS (SELECT * FROM [users] WHERE [users].[age] = '1')"""
def where_date(self):
- return """SELECT * FROM [users] WHERE DATE([users].[created_at]) = '2022-06-01'"""
+ return (
+ """SELECT * FROM [users] WHERE DATE([users].[created_at]) = '2022-06-01'"""
+ )
def or_where_null(self):
return """SELECT * FROM [users] WHERE [users].[column1] IS NULL OR [users].[column2] IS NULL"""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_update_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_update_grammar.py
index aec241b1..49c6e4ab 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_update_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/grammar/test_mssql_update_grammar.py
@@ -1,8 +1,8 @@
import unittest
-from src.masoniteorm.expressions import Raw
from src.masoniteorm.query import QueryBuilder
from src.masoniteorm.query.grammars import MSSQLGrammar
+from src.masoniteorm.expressions import Raw
class TestMSSQLUpdateGrammar(unittest.TestCase):
@@ -10,13 +10,20 @@ def setUp(self):
self.builder = QueryBuilder(MSSQLGrammar, table="users")
def test_can_compile_update(self):
- to_sql = self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ to_sql = (
+ self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ )
sql = "UPDATE [users] SET [users].[name] = 'Joe' WHERE [users].[name] = 'bob'"
self.assertEqual(to_sql, sql)
def test_can_compile_update_with_multiple_where(self):
- to_sql = self.builder.where("name", "bob").where("age", 20).update({"name": "Joe"}, dry=True).to_sql()
+ to_sql = (
+ self.builder.where("name", "bob")
+ .where("age", 20)
+ .update({"name": "Joe"}, dry=True)
+ .to_sql()
+ )
sql = "UPDATE [users] SET [users].[name] = 'Joe' WHERE [users].[name] = 'bob' AND [users].[age] = '20'"
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder.py
index b92b8be6..4205bc7e 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder.py
@@ -1,9 +1,9 @@
import unittest
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import MSSQLConnection
from src.masoniteorm.schema import Schema
from src.masoniteorm.schema.platforms import MSSQLPlatform
-from tests.integrations.config.database import DATABASES
class TestMSSQLSchemaBuilder(unittest.TestCase):
@@ -169,7 +169,9 @@ def test_can_advanced_table_creation2(self):
blueprint.string("thumbnail").nullable()
blueprint.integer("premium")
blueprint.integer("author_id").unsigned().nullable()
- blueprint.foreign("author_id").references("id").on("users").on_delete("CASCADE")
+ blueprint.foreign("author_id").references("id").on("users").on_delete(
+ "CASCADE"
+ )
blueprint.text("description")
blueprint.timestamps()
@@ -190,7 +192,9 @@ def test_can_advanced_table_creation2(self):
def test_can_add_columns_with_foreign_key_constraint_name(self):
with self.schema.create("users") as blueprint:
blueprint.integer("profile_id")
- blueprint.foreign("profile_id", name="profile_foreign").references("id").on("profiles")
+ blueprint.foreign("profile_id", name="profile_foreign").references("id").on(
+ "profiles"
+ )
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder_alter.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder_alter.py
index de587748..f1b323e2 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder_alter.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mssql/schema/test_mssql_schema_builder_alter.py
@@ -1,10 +1,10 @@
import unittest
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import MSSQLConnection
from src.masoniteorm.schema import Schema
from src.masoniteorm.schema.platforms import MSSQLPlatform
from src.masoniteorm.schema.Table import Table
-from tests.integrations.config.database import DATABASES
class TestMySQLSchemaBuilderAlter(unittest.TestCase):
@@ -26,7 +26,9 @@ def test_can_add_columns(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
- sql = ["ALTER TABLE [users] ADD [name] VARCHAR(255) NOT NULL, [age] INT NOT NULL"]
+ sql = [
+ "ALTER TABLE [users] ADD [name] VARCHAR(255) NOT NULL, [age] INT NOT NULL"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -79,7 +81,9 @@ def test_alter_drop1(self):
def test_alter_add_column_and_foreign_key(self):
with self.schema.table("users") as blueprint:
blueprint.unsigned_integer("playlist_id").nullable()
- blueprint.foreign("playlist_id").references("id").on("playlists").on_delete("cascade")
+ blueprint.foreign("playlist_id").references("id").on("playlists").on_delete(
+ "cascade"
+ )
sql = [
"ALTER TABLE [users] ADD [playlist_id] INT NULL",
@@ -128,7 +132,9 @@ def test_alter_add_primary(self):
with self.schema.table("users") as blueprint:
blueprint.primary("playlist_id")
- sql = ["ALTER TABLE [users] ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)"]
+ sql = [
+ "ALTER TABLE [users] ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_mysql_builder_transaction.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_mysql_builder_transaction.py
index 67f3de9a..9ee7950a 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_mysql_builder_transaction.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_mysql_builder_transaction.py
@@ -18,7 +18,9 @@ class BaseTestQueryRelationships(unittest.TestCase):
def get_builder(self, table="users"):
connection = ConnectionFactory().make("mysql")
- return QueryBuilder(grammar=MySQLGrammar, connection=connection, table=table).on("mysql")
+ return QueryBuilder(
+ grammar=MySQLGrammar, connection=connection, table=table
+ ).on("mysql")
def test_transaction(self):
builder = self.get_builder()
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder.py
index b274311b..6bbd662b 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder.py
@@ -41,72 +41,94 @@ def test_sum(self):
builder = self.get_builder()
builder.sum("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_sum_chained(self):
builder = self.get_builder()
builder.sum("age").max("salary")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_with_(self):
builder = self.get_builder()
builder.with_("articles").sum("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_like(self):
builder = self.get_builder()
builder.where("age", "like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_like(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_max(self):
builder = self.get_builder()
builder.max("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_min(self):
builder = self.get_builder()
builder.min("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_avg(self):
builder = self.get_builder()
builder.avg("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_all(self):
builder = self.get_builder()
builder.all()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_get(self):
builder = self.get_builder()
builder.get()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_first(self):
builder = self.get_builder().first(query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_find_with_model(self):
@@ -150,31 +172,41 @@ def test_find_with_builder_without_column(self):
def test_select(self):
builder = self.get_builder()
builder.select("name", "email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_with_table(self):
builder = self.get_builder()
builder.select("users.*")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_with_table_raw(self):
builder = self.get_builder()
builder.select("users.*").from_raw("orders, customers")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_with_alias(self):
builder = self.get_builder()
builder.select("users.username as name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_raw(self):
builder = self.get_builder()
builder.select_raw("count(email) as email_count")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_add_select(self):
@@ -185,7 +217,9 @@ def test_add_select(self):
.add_select("salary", lambda q: q.count("*").table("salary"))
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_add_select_no_table(self):
@@ -201,7 +235,9 @@ def test_add_select_no_table(self):
)
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_create(self):
@@ -210,60 +246,82 @@ def test_create(self):
{"name": "Corentin All", "email": "corentin@yopmail.com"},
query=True,
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_delete(self):
builder = self.get_builder()
builder.delete("name", "Joe", query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where(self):
builder = self.get_builder()
builder.where("name", "Joe")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_exists(self):
builder = self.get_builder()
builder.where_exists("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_limit(self):
builder = self.get_builder()
builder.limit(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_offset(self):
builder = self.get_builder()
builder.offset(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_join(self):
builder = self.get_builder()
builder.join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_left_join(self):
builder = self.get_builder()
builder.left_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_right_join(self):
builder = self.get_builder()
builder.right_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_update(self):
- builder = self.get_builder().update({"name": "Joe", "email": "joe@yopmail.com"}, dry=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ builder = self.get_builder().update(
+ {"name": "Joe", "email": "joe@yopmail.com"}, dry=True
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
# def test_increment(self):
@@ -285,78 +343,104 @@ def test_update(self):
def test_count(self):
builder = self.get_builder()
builder.count("id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_asc(self):
builder = self.get_builder()
builder.order_by("email", "asc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_desc(self):
builder = self.get_builder()
builder.order_by("email", "desc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_column(self):
builder = self.get_builder()
builder.where_column("name", "username")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_in(self):
builder = self.get_builder()
builder.where_not_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_between(self):
builder = self.get_builder()
builder.between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_not_between(self):
builder = self.get_builder()
builder.not_between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_in(self):
builder = self.get_builder()
builder.where_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_null(self):
builder = self.get_builder()
builder.where_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_null(self):
builder = self.get_builder()
builder.where_not_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_having(self):
builder = self.get_builder(table="payments")
- builder.select("user_id").avg("salary").group_by("user_id").having("salary", ">=", "1000")
+ builder.select("user_id").avg("salary").group_by("user_id").having(
+ "salary", ">=", "1000"
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by(self):
builder = self.get_builder(table="payments")
builder.select("user_id").min("salary").group_by("user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_builder_alone(self):
@@ -383,43 +467,57 @@ def test_builder_alone(self):
def test_where_lt(self):
builder = self.get_builder()
builder.where("age", "<", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_lte(self):
builder = self.get_builder()
builder.where("age", "<=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gt(self):
builder = self.get_builder()
builder.where("age", ">", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gte(self):
builder = self.get_builder()
builder.where("age", ">=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_ne(self):
builder = self.get_builder()
builder.where("age", "!=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_or_where(self):
builder = self.get_builder()
builder.where("age", "20").or_where("age", "<", 20)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_or_where(self):
builder = self.get_builder()
builder.where("age", "20").or_where("age", "<", 20)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_like_as_operator(self):
@@ -448,7 +546,12 @@ def test_where_not_like(self):
def test_can_call_with_multi_tables(self):
builder = self.get_builder()
- sql = builder.table("information_schema.columns").select("table_name").where("table_name", "users").to_sql()
+ sql = (
+ builder.table("information_schema.columns")
+ .select("table_name")
+ .where("table_name", "users")
+ .to_sql()
+ )
self.assertEqual(
sql,
"""SELECT `information_schema`.`columns`.`table_name` FROM `information_schema`.`columns` WHERE `information_schema`.`columns`.`table_name` = 'users'""",
@@ -457,25 +560,33 @@ def test_can_call_with_multi_tables(self):
def test_truncate(self):
builder = self.get_builder(dry=True)
sql = builder.truncate()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_truncate_without_foreign_keys(self):
builder = self.get_builder(dry=True)
sql = builder.truncate(foreign_keys=True)
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_shared_lock(self):
builder = self.get_builder(dry=True)
sql = builder.where("votes", ">=", 100).shared_lock().to_sql()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_update_lock(self):
builder = self.get_builder(dry=True)
sql = builder.where("votes", ">=", 100).lock_for_update().to_sql()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
@@ -788,7 +899,9 @@ def or_where(self):
builder = self.get_builder()
builder.where('age', '20').or_where('age','<', 20)
"""
- return "SELECT * FROM `users` WHERE `users`.`age` = '20' OR `users`.`age` < '20'"
+ return (
+ "SELECT * FROM `users` WHERE `users`.`age` = '20' OR `users`.`age` < '20'"
+ )
def where_like(self):
"""
@@ -839,13 +952,17 @@ def update_lock(self):
def test_latest(self):
builder = self.get_builder()
builder.latest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_oldest(self):
builder = self.get_builder()
builder.oldest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def latest(self):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder_scopes.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder_scopes.py
index bba513a3..50339a02 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder_scopes.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/builder/test_query_builder_scopes.py
@@ -21,7 +21,9 @@ def get_builder(self, table="users"):
)
def test_scopes(self):
- builder = self.get_builder().set_scope("gender", lambda model, q: q.where("gender", "w"))
+ builder = self.get_builder().set_scope(
+ "gender", lambda model, q: q.where("gender", "w")
+ )
self.assertEqual(
builder.gender().where("id", 1).to_sql(),
@@ -49,7 +51,11 @@ def test_global_scope_from_class(self):
)
def test_global_scope_remove_from_class(self):
- builder = self.get_builder().set_global_scope(SoftDeleteScope()).remove_global_scope(SoftDeleteScope())
+ builder = (
+ self.get_builder()
+ .set_global_scope(SoftDeleteScope())
+ .remove_global_scope(SoftDeleteScope())
+ )
self.assertEqual(
builder.where("id", 1).to_sql(),
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_delete_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_delete_grammar.py
index 93a73a94..c17acee7 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_delete_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_delete_grammar.py
@@ -12,19 +12,31 @@ def setUp(self):
def test_can_compile_delete(self):
to_sql = self.builder.delete("id", 1, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_in(self):
to_sql = self.builder.delete("id", [1, 2, 3], query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_with_where(self):
- to_sql = self.builder.where("age", 20).where("profile", 1).set_action("delete").delete(query=True).to_sql()
+ to_sql = (
+ self.builder.where("age", 20)
+ .where("profile", 1)
+ .set_action("delete")
+ .delete(query=True)
+ .to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
@@ -62,4 +74,6 @@ def can_compile_delete_with_where(self):
.to_sql()
)
"""
- return "DELETE FROM `users` WHERE `users`.`age` = '20' AND `users`.`profile` = '1'"
+ return (
+ "DELETE FROM `users` WHERE `users`.`age` = '20' AND `users`.`profile` = '1'"
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_insert_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_insert_grammar.py
index 7d3e727b..0089ba2c 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_insert_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_insert_grammar.py
@@ -12,13 +12,17 @@ def setUp(self):
def test_can_compile_insert(self):
to_sql = self.builder.create({"name": "Joe"}, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_insert_with_keywords(self):
to_sql = self.builder.create(name="Joe", query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create(self):
@@ -32,13 +36,19 @@ def test_can_compile_bulk_create(self):
query=True,
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_qmark(self):
- to_sql = self.builder.bulk_create([{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True).to_qmark()
+ to_sql = self.builder.bulk_create(
+ [{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True
+ ).to_qmark()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_multiple(self):
@@ -51,7 +61,9 @@ def test_can_compile_bulk_create_multiple(self):
query=True,
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_qmark.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_qmark.py
index 532a22cf..f276101d 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_qmark.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_qmark.py
@@ -12,78 +12,104 @@ def setUp(self):
def test_can_compile_select(self):
mark = self.builder.select("username").where("name", "Joe")
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_delete(self):
mark = self.builder.where("name", "Joe").delete(query=True)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_update(self):
mark = self.builder.update({"name": "Bob"}, dry=True).where("name", "Joe")
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_where_in(self):
mark = self.builder.where_in("id", [1, 2, 3])
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_where_not_null(self):
mark = self.builder.where_not_null("id")
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, [])
def test_can_compile_where_with_falsy_values(self):
mark = self.builder.where("name", 0)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_where_with_true_value(self):
mark = self.builder.where("is_admin", True)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_where_with_false_value(self):
mark = self.builder.where("is_admin", False)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_compile_sub_group_bindings(self):
mark = self.builder.where(
- lambda query: query.where("challenger", 1).or_where("proposer", 1).or_where("referee", 1)
+ lambda query: (
+ query.where("challenger", 1)
+ .or_where("proposer", 1)
+ .or_where("referee", 1)
+ )
)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(mark.to_qmark(), sql)
self.assertEqual(mark._bindings, bindings)
def test_can_increment(self):
builder = self.builder.increment("age", dry=True)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_qmark(), sql)
self.assertEqual(builder._bindings, bindings)
def test_can_decrement(self):
builder = self.builder.decrement("age", dry=True)
- sql, bindings = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql, bindings = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_qmark(), sql)
self.assertEqual(builder._bindings, bindings)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_select_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_select_grammar.py
index 0d6ccb2c..a87dd772 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_select_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_select_grammar.py
@@ -176,7 +176,9 @@ def can_compile_or_where(self):
"""
self.builder.where('name', 2).or_where('name', 3).to_sql()
"""
- return "SELECT * FROM `users` WHERE `users`.`name` = '2' OR `users`.`name` = '3'"
+ return (
+ "SELECT * FROM `users` WHERE `users`.`name` = '2' OR `users`.`name` = '3'"
+ )
def can_grouped_where(self):
"""
@@ -297,12 +299,21 @@ def test_can_compile_where_raw(self):
self.assertEqual(to_sql, "SELECT * FROM `users` WHERE `age` = '18'")
def test_can_compile_having_raw(self):
- to_sql = self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").to_sql()
- self.assertEqual(to_sql, "SELECT COUNT(*) as counts FROM `users` HAVING counts > 10")
+ to_sql = (
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .to_sql()
+ )
+ self.assertEqual(
+ to_sql, "SELECT COUNT(*) as counts FROM `users` HAVING counts > 10"
+ )
def test_can_compile_having_raw_order(self):
to_sql = (
- self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").order_by_raw("counts DESC").to_sql()
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .order_by_raw("counts DESC")
+ .to_sql()
)
self.assertEqual(
to_sql,
@@ -375,9 +386,7 @@ def can_compile_join_clause_with_value(self):
)
builder.join(clause).to_sql()
"""
- return (
- "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`active` = '1' OR `bgt`.`acct` = '1234'"
- )
+ return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`active` = '1' OR `bgt`.`acct` = '1234'"
def can_compile_join_clause_with_null(self):
"""
@@ -416,9 +425,7 @@ def can_compile_join_clause_with_lambda(self):
),
).to_sql()
"""
- return (
- "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`fund` = `rg`.`fund` AND `bgt` IS NULL"
- )
+ return "SELECT * FROM `users` INNER JOIN `report_groups` AS `rg` ON `bgt`.`fund` = `rg`.`fund` AND `bgt` IS NULL"
def can_compile_left_join_clause_with_lambda(self):
"""
@@ -473,7 +480,9 @@ def where_not_exists_with_lambda(self):
return """SELECT * FROM `users` WHERE NOT EXISTS (SELECT * FROM `users` WHERE `users`.`age` = '1')"""
def where_date(self):
- return """SELECT * FROM `users` WHERE DATE(`users`.`created_at`) = '2022-06-01'"""
+ return (
+ """SELECT * FROM `users` WHERE DATE(`users`.`created_at`) = '2022-06-01'"""
+ )
def or_where_null(self):
return """SELECT * FROM `users` WHERE `users`.`column1` IS NULL OR `users`.`column2` IS NULL"""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_update_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_update_grammar.py
index fb0ba1c4..0212ec8f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_update_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/grammar/test_mysql_update_grammar.py
@@ -1,9 +1,9 @@
import inspect
import unittest
-from src.masoniteorm.expressions import Raw
from src.masoniteorm.query import QueryBuilder
from src.masoniteorm.query.grammars import MySQLGrammar
+from src.masoniteorm.expressions import Raw
class BaseTestCaseUpdateGrammar:
@@ -11,21 +11,36 @@ def setUp(self):
self.builder = QueryBuilder(self.grammar, table="users")
def test_can_compile_update(self):
- to_sql = self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ to_sql = (
+ self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_multiple_update(self):
- to_sql = self.builder.update({"name": "Joe", "email": "user@email.com"}, dry=True).to_sql()
+ to_sql = self.builder.update(
+ {"name": "Joe", "email": "user@email.com"}, dry=True
+ ).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_update_with_multiple_where(self):
- to_sql = self.builder.where("name", "bob").where("age", 20).update({"name": "Joe"}, dry=True).to_sql()
-
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.where("name", "bob")
+ .where("age", 20)
+ .update({"name": "Joe"}, dry=True)
+ .to_sql()
+ )
+
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
# def test_can_compile_increment(self):
@@ -47,7 +62,9 @@ def test_can_compile_update_with_multiple_where(self):
def test_raw_expression(self):
to_sql = self.builder.update({"name": Raw("`username`")}, dry=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_accessors_and_mutators.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_accessors_and_mutators.py
index c18f25a7..609785b2 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_accessors_and_mutators.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_accessors_and_mutators.py
@@ -22,7 +22,9 @@ def set_name_attribute(self, attribute):
class TestAccessor(unittest.TestCase):
def test_can_get_accessor(self):
- user = User.hydrate({"name": "joe", "email": "joe@masoniteproject.com", "is_admin": 1})
+ user = User.hydrate(
+ {"name": "joe", "email": "joe@masoniteproject.com", "is_admin": 1}
+ )
self.assertEqual(user.email, "joe@masoniteproject.com")
self.assertEqual(user.name, "Hello, joe")
self.assertTrue(user.is_admin is True, f"{user.is_admin} is not True")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_model.py
index f1db3f48..60a06502 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/model/test_model.py
@@ -4,6 +4,7 @@
import unittest
import pendulum
+
from src.masoniteorm.collection import Collection
from src.masoniteorm.exceptions import ModelNotFound
from src.masoniteorm.models import Model
@@ -78,12 +79,18 @@ class ProductNames(Model):
class TestModel(unittest.TestCase):
def test_create_can_use_fillable(self):
- sql = ProfileFillable.create({"name": "Joe", "email": "user@example.com"}, query=True).to_sql()
+ sql = ProfileFillable.create(
+ {"name": "Joe", "email": "user@example.com"}, query=True
+ ).to_sql()
- self.assertEqual(sql, "INSERT INTO `profiles` (`profiles`.`name`) VALUES ('Joe')")
+ self.assertEqual(
+ sql, "INSERT INTO `profiles` (`profiles`.`name`) VALUES ('Joe')"
+ )
def test_create_can_use_fillable_asterisk(self):
- sql = ProfileFillAsterisk.create({"name": "Joe", "email": "user@example.com"}, query=True).to_sql()
+ sql = ProfileFillAsterisk.create(
+ {"name": "Joe", "email": "user@example.com"}, query=True
+ ).to_sql()
self.assertEqual(
sql,
@@ -91,12 +98,18 @@ def test_create_can_use_fillable_asterisk(self):
)
def test_create_can_use_guarded(self):
- sql = ProfileGuarded.create({"name": "Joe", "email": "user@example.com"}, query=True).to_sql()
+ sql = ProfileGuarded.create(
+ {"name": "Joe", "email": "user@example.com"}, query=True
+ ).to_sql()
- self.assertEqual(sql, "INSERT INTO `profiles` (`profiles`.`name`) VALUES ('Joe')")
+ self.assertEqual(
+ sql, "INSERT INTO `profiles` (`profiles`.`name`) VALUES ('Joe')"
+ )
def test_create_can_use_guarded_asterisk(self):
- sql = ProfileGuardedAsterisk.create({"name": "Joe", "email": "user@example.com"}, query=True).to_sql()
+ sql = ProfileGuardedAsterisk.create(
+ {"name": "Joe", "email": "user@example.com"}, query=True
+ ).to_sql()
# An asterisk guarded attribute excludes all fields from mass-assignment.
# This would raise a DB error if there are any required fields.
@@ -156,10 +169,14 @@ def test_bulk_create_can_use_guarded_asterisk(self):
# An asterisk guarded attribute excludes all fields from mass-assignment.
# This would obviously raise an invalid SQL syntax error.
# TODO: Raise a clearer error?
- self.assertEqual(query_builder.to_sql(), "INSERT INTO `profiles` () VALUES (), ()")
+ self.assertEqual(
+ query_builder.to_sql(), "INSERT INTO `profiles` () VALUES (), ()"
+ )
def test_update_can_use_fillable(self):
- query_builder = ProfileFillable().update({"name": "Joe", "email": "user@example.com"}, dry=True)
+ query_builder = ProfileFillable().update(
+ {"name": "Joe", "email": "user@example.com"}, dry=True
+ )
self.assertEqual(
query_builder.to_sql(),
@@ -167,7 +184,9 @@ def test_update_can_use_fillable(self):
)
def test_update_can_use_fillable_asterisk(self):
- query_builder = ProfileFillAsterisk().update({"name": "Joe", "email": "user@example.com"}, dry=True)
+ query_builder = ProfileFillAsterisk().update(
+ {"name": "Joe", "email": "user@example.com"}, dry=True
+ )
self.assertEqual(
query_builder.to_sql(),
@@ -175,7 +194,9 @@ def test_update_can_use_fillable_asterisk(self):
)
def test_update_can_use_guarded(self):
- query_builder = ProfileGuarded().update({"name": "Joe", "email": "user@example.com"}, dry=True)
+ query_builder = ProfileGuarded().update(
+ {"name": "Joe", "email": "user@example.com"}, dry=True
+ )
self.assertEqual(
query_builder.to_sql(),
@@ -185,7 +206,9 @@ def test_update_can_use_guarded(self):
def test_update_can_use_guarded_asterisk(self):
profile = ProfileGuardedAsterisk()
initial_sql = profile.get_builder().to_sql()
- query_builder = profile.update({"name": "Joe", "email": "user@example.com"}, dry=True)
+ query_builder = profile.update(
+ {"name": "Joe", "email": "user@example.com"}, dry=True
+ )
# An asterisk guarded attribute excludes all fields from mass-assignment.
# The query builder's sql should not have been altered in any way.
@@ -212,7 +235,9 @@ def test_json(self):
self.assertEqual(profile.to_json(), '{"name": "Joe", "id": 1}')
def test_serialize_with_hidden(self):
- profile = ProfileSerialize.hydrate({"name": "Joe", "id": 1, "password": "secret"})
+ profile = ProfileSerialize.hydrate(
+ {"name": "Joe", "id": 1, "password": "secret"}
+ )
self.assertTrue(profile.serialize().get("name"))
self.assertTrue(profile.serialize().get("id"))
@@ -227,7 +252,9 @@ def test_serialize_with_visible(self):
"email": "joe@masonite.com",
}
)
- self.assertTrue({"name": "Joe", "email": "joe@masonite.com"}, profile.serialize())
+ self.assertTrue(
+ {"name": "Joe", "email": "joe@masonite.com"}, profile.serialize()
+ )
def test_serialize_with_visible_and_hidden_raise_error(self):
profile = ProfileSerializeWithVisibleAndHidden.hydrate(
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_belongs_to_many.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_belongs_to_many.py
index 2003f488..69494f9b 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_belongs_to_many.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_belongs_to_many.py
@@ -1,6 +1,7 @@
import unittest
from dotenv import load_dotenv
+
from src.masoniteorm.models import Model
from src.masoniteorm.relationships import (
belongs_to_many,
@@ -46,7 +47,9 @@ class MySQLRelationships(unittest.TestCase):
maxDiff = None
def test_belongs_to_many(self):
- sql = Permission.where_has("role", lambda query: query.where("slug", "users")).to_sql()
+ sql = Permission.where_has(
+ "role", lambda query: query.where("slug", "users")
+ ).to_sql()
self.assertEqual(
sql,
@@ -71,7 +74,9 @@ def test_belongs_to_many_or_has(self):
def test_belongs_to_many_or_where_has(self):
sql = (
- Role.where("name", "role_name").or_where_has("permissions", lambda q: q.where("permission_id", 1)).to_sql()
+ Role.where("name", "role_name")
+ .or_where_has("permissions", lambda q: q.where("permission_id", 1))
+ .to_sql()
)
self.assertEqual(
@@ -90,7 +95,9 @@ def test_belongs_to_many_or_doesnt_have(self):
def test_where_doesnt_have(self):
sql = (
Role.where("name", "role_name")
- .where_doesnt_have("permissions", lambda q: q.where("name", "Creates Users"))
+ .where_doesnt_have(
+ "permissions", lambda q: q.where("name", "Creates Users")
+ )
.to_sql()
)
@@ -102,7 +109,9 @@ def test_where_doesnt_have(self):
def test_or_where_doesnt_have(self):
sql = (
Role.where("name", "role_name")
- .or_where_doesnt_have("permissions", lambda q: q.where("name", "Creates Users"))
+ .or_where_doesnt_have(
+ "permissions", lambda q: q.where("name", "Creates Users")
+ )
.to_sql()
)
@@ -112,7 +121,9 @@ def test_or_where_doesnt_have(self):
)
def test_belongs_to_many_where_has(self):
- sql = Role.where_has("permissions", lambda q: q.where("name", "Creates Users")).to_sql()
+ sql = Role.where_has(
+ "permissions", lambda q: q.where("name", "Creates Users")
+ ).to_sql()
self.assertEqual(
sql,
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_many_through.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_many_through.py
index 332e8740..3c6d5b7e 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_many_through.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_many_through.py
@@ -1,10 +1,10 @@
import unittest
-from dotenv import load_dotenv
from src.masoniteorm.models import Model
from src.masoniteorm.relationships import (
has_many_through,
)
+from dotenv import load_dotenv
load_dotenv(".env")
@@ -43,7 +43,9 @@ def test_or_has(self):
)
def test_where_has_query(self):
- sql = InboundShipment.where_has("from_country", lambda query: query.where("name", "USA")).to_sql()
+ sql = InboundShipment.where_has(
+ "from_country", lambda query: query.where("name", "USA")
+ ).to_sql()
self.assertEqual(
sql,
@@ -73,7 +75,9 @@ def test_doesnt_have(self):
def test_or_where_doesnt_have(self):
sql = (
InboundShipment.where("name", "Joe")
- .or_where_doesnt_have("from_country", lambda query: query.where("name", "USA"))
+ .or_where_doesnt_have(
+ "from_country", lambda query: query.where("name", "USA")
+ )
.to_sql()
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_one_through.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_one_through.py
index bc863060..4337dc83 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_one_through.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_has_one_through.py
@@ -1,10 +1,10 @@
import unittest
-from dotenv import load_dotenv
from src.masoniteorm.models import Model
from src.masoniteorm.relationships import (
has_one_through,
)
+from dotenv import load_dotenv
load_dotenv(".env")
@@ -43,7 +43,9 @@ def test_or_has(self):
)
def test_where_has_query(self):
- sql = InboundShipment.where_has("from_country", lambda query: query.where("name", "USA")).to_sql()
+ sql = InboundShipment.where_has(
+ "from_country", lambda query: query.where("name", "USA")
+ ).to_sql()
self.assertEqual(
sql,
@@ -73,7 +75,9 @@ def test_doesnt_have(self):
def test_or_where_doesnt_have(self):
sql = (
InboundShipment.where("name", "Joe")
- .or_where_doesnt_have("from_country", lambda query: query.where("name", "USA"))
+ .or_where_doesnt_have(
+ "from_country", lambda query: query.where("name", "USA")
+ )
.to_sql()
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_relationships.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_relationships.py
index 309d01fe..a1eddcf0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_relationships.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/relationships/test_relationships.py
@@ -1,6 +1,7 @@
import unittest
from dotenv import load_dotenv
+
from src.masoniteorm.models import Model
from src.masoniteorm.relationships import (
has_one,
@@ -59,7 +60,11 @@ def test_or_has_nested(self):
)
def test_relationship_where_has(self):
- sql = User.where("name", "Joe").where_has("profile", lambda q: q.where("profile_id", 1)).to_sql()
+ sql = (
+ User.where("name", "Joe")
+ .where_has("profile", lambda q: q.where("profile_id", 1))
+ .to_sql()
+ )
self.assertEqual(
sql,
@@ -82,7 +87,11 @@ def test_relationship_where_has_nested(self):
)
def test_relationship_or_where_has(self):
- sql = User.where("name", "Joe").or_where_has("profile", lambda q: q.where("profile_id", 1)).to_sql()
+ sql = (
+ User.where("name", "Joe")
+ .or_where_has("profile", lambda q: q.where("profile_id", 1))
+ .to_sql()
+ )
self.assertEqual(
sql,
@@ -121,7 +130,9 @@ def test_relationship_doesnt_have_nested(self):
)
def test_relationship_where_doesnt_have(self):
- sql = User.where_doesnt_have("profile", lambda q: q.where("profile_id", 1)).to_sql()
+ sql = User.where_doesnt_have(
+ "profile", lambda q: q.where("profile_id", 1)
+ ).to_sql()
self.assertEqual(
sql,
@@ -129,7 +140,9 @@ def test_relationship_where_doesnt_have(self):
)
def test_relationship_where_doesnt_have_nested(self):
- sql = User.where_doesnt_have("profile.identification", lambda q: q.where("identification_id", 1)).to_sql()
+ sql = User.where_doesnt_have(
+ "profile.identification", lambda q: q.where("identification_id", 1)
+ ).to_sql()
self.assertEqual(
sql,
@@ -137,7 +150,9 @@ def test_relationship_where_doesnt_have_nested(self):
)
def test_relationship_or_where_doesnt_have(self):
- sql = User.or_where_doesnt_have("profile", lambda q: q.where("profile_id", 1)).to_sql()
+ sql = User.or_where_doesnt_have(
+ "profile", lambda q: q.where("profile_id", 1)
+ ).to_sql()
self.assertEqual(
sql,
@@ -145,7 +160,9 @@ def test_relationship_or_where_doesnt_have(self):
)
def test_relationship_or_where_doesnt_have_nested(self):
- sql = User.or_where_doesnt_have("profile.identification", lambda q: q.where("identification_id", 1)).to_sql()
+ sql = User.or_where_doesnt_have(
+ "profile.identification", lambda q: q.where("identification_id", 1)
+ ).to_sql()
self.assertEqual(
sql,
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder.py
index 15e12e84..09c2ecc8 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder.py
@@ -2,9 +2,11 @@
import unittest
from src.masoniteorm import Model
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import MySQLConnection
from src.masoniteorm.schema import Schema
from src.masoniteorm.schema.platforms import MySQLPlatform
+
from tests.integrations.config.database import DATABASES
@@ -32,7 +34,9 @@ def test_can_add_columns1(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ["CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL, `age` INT(11) NOT NULL)"],
+ [
+ "CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL, `age` INT(11) NOT NULL)"
+ ],
)
def test_can_add_tiny_text(self):
@@ -63,7 +67,9 @@ def test_can_create_table_if_not_exists(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ["CREATE TABLE IF NOT EXISTS `users` (`name` VARCHAR(255) NOT NULL, `age` INT(11) NOT NULL)"],
+ [
+ "CREATE TABLE IF NOT EXISTS `users` (`name` VARCHAR(255) NOT NULL, `age` INT(11) NOT NULL)"
+ ],
)
def test_can_add_columns_with_constaint(self):
@@ -88,7 +94,9 @@ def test_add_column_comment(self):
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
blueprint.to_sql(),
- ["CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL COMMENT 'A users username')"],
+ [
+ "CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL COMMENT 'A users username')"
+ ],
)
def test_can_add_table_comment(self):
@@ -99,7 +107,9 @@ def test_can_add_table_comment(self):
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
blueprint.to_sql(),
- ["CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL) COMMENT 'A users table'"],
+ [
+ "CREATE TABLE `users` (`name` VARCHAR(255) NOT NULL) COMMENT 'A users table'"
+ ],
)
def test_can_add_columns_with_foreign_key_constaint(self):
@@ -183,7 +193,11 @@ def test_can_add_primary_constraint_without_column_name(self):
self.assertEqual(len(blueprint.table.added_columns), 3)
self.assertEqual(len(blueprint.table.added_constraints), 1)
- self.assertTrue(blueprint.to_sql()[0].startswith("CREATE TABLE `users` (`user_id` INT(11) NOT NULL"))
+ self.assertTrue(
+ blueprint.to_sql()[0].startswith(
+ "CREATE TABLE `users` (`user_id` INT(11) NOT NULL"
+ )
+ )
def test_can_advanced_table_creation2(self):
with self.schema.create("users") as blueprint:
@@ -198,7 +212,9 @@ def test_can_advanced_table_creation2(self):
blueprint.string("thumbnail").nullable()
blueprint.integer("premium")
blueprint.integer("author_id").unsigned().nullable()
- blueprint.foreign("author_id").references("id").on("users").on_delete("CASCADE")
+ blueprint.foreign("author_id").references("id").on("users").on_delete(
+ "CASCADE"
+ )
blueprint.text("description")
blueprint.timestamps()
@@ -217,7 +233,9 @@ def test_can_advanced_table_creation2(self):
def test_can_add_columns_with_foreign_key_constraint_name(self):
with self.schema.create("users") as blueprint:
blueprint.integer("profile_id")
- blueprint.foreign("profile_id", name="profile_foreign").references("id").on("profiles")
+ blueprint.foreign("profile_id", name="profile_foreign").references("id").on(
+ "profiles"
+ )
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
@@ -374,5 +392,7 @@ def test_can_add_enum(self):
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
blueprint.to_sql(),
- ["CREATE TABLE `users` (`status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active')"],
+ [
+ "CREATE TABLE `users` (`status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active')"
+ ],
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder_alter.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder_alter.py
index c48ecf62..a437f0d5 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder_alter.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/schema/test_mysql_schema_builder_alter.py
@@ -26,7 +26,9 @@ def test_can_add_columns(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
- sql = ["ALTER TABLE `users` ADD `name` VARCHAR(255) NOT NULL, ADD `age` INT(11) NOT NULL"]
+ sql = [
+ "ALTER TABLE `users` ADD `name` VARCHAR(255) NOT NULL, ADD `age` INT(11) NOT NULL"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -126,7 +128,9 @@ def test_alter_drop1(self):
def test_alter_add_column_and_foreign_key(self):
with self.schema.table("users") as blueprint:
blueprint.unsigned_integer("playlist_id").nullable()
- blueprint.foreign("playlist_id").references("id").on("playlists").on_delete("cascade")
+ blueprint.foreign("playlist_id").references("id").on("playlists").on_delete(
+ "cascade"
+ )
sql = [
"ALTER TABLE `users` ADD `playlist_id` INT UNSIGNED NULL",
@@ -179,7 +183,9 @@ def test_alter_add_primary(self):
with self.schema.table("users") as blueprint:
blueprint.primary("playlist_id")
- sql = ["ALTER TABLE `users` ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)"]
+ sql = [
+ "ALTER TABLE `users` ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -294,7 +300,9 @@ def test_can_add_column_enum(self):
self.assertEqual(len(blueprint.table.added_columns), 1)
- sql = ["ALTER TABLE `users` ADD `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active'"]
+ sql = [
+ "ALTER TABLE `users` ADD `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active'"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -304,6 +312,8 @@ def test_can_change_column_enum(self):
self.assertEqual(len(blueprint.table.changed_columns), 1)
- sql = ["ALTER TABLE `users` MODIFY `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active'"]
+ sql = [
+ "ALTER TABLE `users` MODIFY `status` ENUM('active', 'inactive') NOT NULL DEFAULT 'active'"
+ ]
self.assertEqual(blueprint.to_sql(), sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_can_use_global_scopes.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_can_use_global_scopes.py
index 0d881582..89b94d19 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_can_use_global_scopes.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_can_use_global_scopes.py
@@ -31,7 +31,9 @@ def test_can_use_global_scopes_on_select(self):
def test_can_use_global_scopes_on_time(self):
sql = "INSERT INTO `users` (`users`.`name`, `users`.`updated_at`, `users`.`created_at`) VALUES ('Joe'"
- self.assertTrue(User.create({"name": "Joe"}, query=True).to_sql().startswith(sql))
+ self.assertTrue(
+ User.create({"name": "Joe"}, query=True).to_sql().startswith(sql)
+ )
# def test_can_use_global_scopes_on_inherit(self):
# sql = "SELECT * FROM `user_softs` WHERE `user_softs`.`deleted_at` IS NULL"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_soft_delete.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_soft_delete.py
index f8289abc..7d6689b4 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_soft_delete.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/mysql/scopes/test_soft_delete.py
@@ -48,7 +48,9 @@ def test_restore(self):
def test_force_delete_with_wheres(self):
sql = "DELETE FROM `users` WHERE `users`.`active` = '1'"
- self.assertEqual(sql, UserSoft.where("active", 1).force_delete(query=True).to_sql())
+ self.assertEqual(
+ sql, UserSoft.where("active", 1).force_delete(query=True).to_sql()
+ )
def test_that_trashed_users_are_not_returned_by_default(self):
sql = "SELECT * FROM `users` WHERE `users`.`deleted_at` IS NULL"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/builder/test_postgres_query_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/builder/test_postgres_query_builder.py
index d77f82d4..93dc273e 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/builder/test_postgres_query_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/builder/test_postgres_query_builder.py
@@ -38,64 +38,84 @@ def test_sum(self):
builder = self.get_builder()
builder.sum("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_like(self):
builder = self.get_builder()
builder.where("age", "like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_like(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_max(self):
builder = self.get_builder()
builder.max("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_min(self):
builder = self.get_builder()
builder.min("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_avg(self):
builder = self.get_builder()
builder.avg("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_all(self):
builder = self.get_builder()
builder.all()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_get(self):
builder = self.get_builder()
builder.get()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_first(self):
builder = self.get_builder().first(query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select(self):
builder = self.get_builder()
builder.select("name", "email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_add_select_no_table(self):
@@ -111,13 +131,17 @@ def test_add_select_no_table(self):
)
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_raw(self):
builder = self.get_builder()
builder.select_raw("count(email) as email_count")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_create(self):
@@ -126,60 +150,82 @@ def test_create(self):
{"name": "Corentin All", "email": "corentin@yopmail.com"},
query=True,
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_delete(self):
builder = self.get_builder()
builder.delete("name", "Joe", query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where(self):
builder = self.get_builder()
builder.where("name", "Joe")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_exists(self):
builder = self.get_builder()
builder.where_exists("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_limit(self):
builder = self.get_builder()
builder.limit(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_offset(self):
builder = self.get_builder()
builder.offset(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_join(self):
builder = self.get_builder()
builder.join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_left_join(self):
builder = self.get_builder()
builder.left_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_right_join(self):
builder = self.get_builder()
builder.right_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_update(self):
- builder = self.get_builder().update({"name": "Joe", "email": "joe@yopmail.com"}, dry=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ builder = self.get_builder().update(
+ {"name": "Joe", "email": "joe@yopmail.com"}, dry=True
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
# def test_increment(self):
@@ -201,78 +247,104 @@ def test_update(self):
def test_count(self):
builder = self.get_builder()
builder.count("id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_asc(self):
builder = self.get_builder()
builder.order_by("email", "asc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_desc(self):
builder = self.get_builder()
builder.order_by("email", "desc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_column(self):
builder = self.get_builder()
builder.where_column("name", "username")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_in(self):
builder = self.get_builder()
builder.where_not_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_between(self):
builder = self.get_builder()
builder.between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_not_between(self):
builder = self.get_builder()
builder.not_between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_in(self):
builder = self.get_builder()
builder.where_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_null(self):
builder = self.get_builder()
builder.where_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_null(self):
builder = self.get_builder()
builder.where_not_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_having(self):
builder = self.get_builder(table="payments")
- builder.select("user_id").avg("salary").group_by("user_id").having("salary", ">=", "1000")
+ builder.select("user_id").avg("salary").group_by("user_id").having(
+ "salary", ">=", "1000"
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by(self):
builder = self.get_builder(table="payments")
builder.select("user_id").min("salary").group_by("user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_builder_alone(self):
@@ -299,42 +371,59 @@ def test_builder_alone(self):
def test_where_lt(self):
builder = self.get_builder()
builder.where("age", "<", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_lte(self):
builder = self.get_builder()
builder.where("age", "<=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gt(self):
builder = self.get_builder()
builder.where("age", ">", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gte(self):
builder = self.get_builder()
builder.where("age", ">=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_ne(self):
builder = self.get_builder()
builder.where("age", "!=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_or_where(self):
builder = self.get_builder()
builder.where("age", "20").or_where("age", "<", 20)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_can_call_with_schema(self):
builder = self.get_builder()
- sql = builder.table("information_schema.columns").select("table_name").where("table_name", "users").to_sql()
+ sql = (
+ builder.table("information_schema.columns")
+ .select("table_name")
+ .where("table_name", "users")
+ .to_sql()
+ )
self.assertEqual(
sql,
"""SELECT "information_schema"."columns"."table_name" FROM "information_schema"."columns" WHERE "information_schema"."columns"."table_name" = 'users'""",
@@ -343,25 +432,33 @@ def test_can_call_with_schema(self):
def test_truncate(self):
builder = self.get_builder(dry=True)
sql = builder.truncate()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_truncate_without_foreign_keys(self):
builder = self.get_builder(dry=True)
sql = builder.truncate(foreign_keys=True)
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_shared_lock(self):
builder = self.get_builder(dry=True)
sql = builder.where("votes", ">=", 100).shared_lock().to_sql()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_update_lock(self):
builder = self.get_builder(dry=True)
sql = builder.where("votes", ">=", 100).lock_for_update().to_sql()
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
@@ -679,13 +776,17 @@ def shared_lock(self):
def test_latest(self):
builder = self.get_builder()
builder.latest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_oldest(self):
builder = self.get_builder()
builder.oldest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def oldest(self):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_delete_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_delete_grammar.py
index 3a1b5398..690e7253 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_delete_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_delete_grammar.py
@@ -12,19 +12,31 @@ def setUp(self):
def test_can_compile_delete(self):
to_sql = self.builder.delete("id", 1, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_in(self):
to_sql = self.builder.delete("id", [1, 2, 3], query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_with_where(self):
- to_sql = self.builder.where("age", 20).where("profile", 1).set_action("delete").delete(query=True).to_sql()
+ to_sql = (
+ self.builder.where("age", 20)
+ .where("profile", 1)
+ .set_action("delete")
+ .delete(query=True)
+ .to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_insert_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_insert_grammar.py
index 85ec9138..6404d2e3 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_insert_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_insert_grammar.py
@@ -12,13 +12,17 @@ def setUp(self):
def test_can_compile_insert(self):
to_sql = self.builder.create({"name": "Joe"}, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_insert_with_keywords(self):
to_sql = self.builder.create(name="Joe", query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create(self):
@@ -32,13 +36,19 @@ def test_can_compile_bulk_create(self):
query=True,
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_qmark(self):
- to_sql = self.builder.bulk_create([{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True).to_qmark()
+ to_sql = self.builder.bulk_create(
+ [{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True
+ ).to_qmark()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_select_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_select_grammar.py
index 81e7bda8..475d6eee 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_select_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_select_grammar.py
@@ -71,7 +71,9 @@ def can_compile_with_multiple_order_by(self):
"""
self.builder.select('username').order_by('age', 'desc').order_by('name').to_sql()
"""
- return """SELECT "users"."username" FROM "users" ORDER BY "age" DESC, "name" ASC"""
+ return (
+ """SELECT "users"."username" FROM "users" ORDER BY "age" DESC, "name" ASC"""
+ )
def can_compile_with_group_by(self):
"""
@@ -107,7 +109,9 @@ def can_compile_where_not_null(self):
"""
self.builder.select('username').where_not_null('age').to_sql()
"""
- return """SELECT "users"."username" FROM "users" WHERE "users"."age" IS NOT NULL"""
+ return (
+ """SELECT "users"."username" FROM "users" WHERE "users"."age" IS NOT NULL"""
+ )
def can_compile_where_raw(self):
"""
@@ -300,7 +304,11 @@ def test_can_compile_where_raw(self):
self.assertEqual(to_sql, """SELECT * FROM "users" WHERE "age" = '18'""")
def test_can_compile_having_raw(self):
- to_sql = self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").to_sql()
+ to_sql = (
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .to_sql()
+ )
self.assertEqual(
to_sql,
"""SELECT COUNT(*) as counts FROM "users" HAVING counts > 10""",
@@ -308,7 +316,10 @@ def test_can_compile_having_raw(self):
def test_can_compile_having_raw_order(self):
to_sql = (
- self.builder.select_raw("COUNT(*) as counts").having_raw("counts > 10").order_by_raw("counts DESC").to_sql()
+ self.builder.select_raw("COUNT(*) as counts")
+ .having_raw("counts > 10")
+ .order_by_raw("counts DESC")
+ .to_sql()
)
self.assertEqual(
to_sql,
@@ -316,9 +327,9 @@ def test_can_compile_having_raw_order(self):
)
def test_can_compile_where_raw_and_where_with_multiple_bindings(self):
- query = self.builder.where_raw(""" "age" = ? AND "is_admin" = ?""", [18, True]).where(
- "email", "test@example.com"
- )
+ query = self.builder.where_raw(
+ """ "age" = ? AND "is_admin" = ?""", [18, True]
+ ).where("email", "test@example.com")
self.assertEqual(
query.to_qmark(),
"""SELECT * FROM "users" WHERE "age" = ? AND "is_admin" = ? AND "users"."email" = ?""",
@@ -443,9 +454,7 @@ def can_compile_left_join_clause_with_lambda(self):
),
).to_sql()
"""
- return (
- """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
- )
+ return """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
def can_compile_right_join_clause_with_lambda(self):
"""
@@ -487,7 +496,9 @@ def where_not_exists_with_lambda(self):
return """SELECT * FROM "users" WHERE NOT EXISTS (SELECT * FROM "users" WHERE "users"."age" = '1')"""
def where_date(self):
- return """SELECT * FROM "users" WHERE DATE("users"."created_at") = '2022-06-01'"""
+ return (
+ """SELECT * FROM "users" WHERE DATE("users"."created_at") = '2022-06-01'"""
+ )
def or_where_null(self):
return """SELECT * FROM "users" WHERE "users"."column1" IS NULL OR "users"."column2" IS NULL"""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_update_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_update_grammar.py
index fa8cb3c3..76d19f7f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_update_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/grammar/test_update_grammar.py
@@ -2,31 +2,48 @@
import unittest
from src.masoniteorm.connections import PostgresConnection
-from src.masoniteorm.expressions import Raw
from src.masoniteorm.query import QueryBuilder
from src.masoniteorm.query.grammars import PostgresGrammar
+from src.masoniteorm.expressions import Raw
class BaseTestCaseUpdateGrammar:
def setUp(self):
- self.builder = QueryBuilder(PostgresGrammar, connection_class=PostgresConnection, table="users")
+ self.builder = QueryBuilder(
+ PostgresGrammar, connection_class=PostgresConnection, table="users"
+ )
def test_can_compile_update(self):
- to_sql = self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ to_sql = (
+ self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_multiple_update(self):
- to_sql = self.builder.update({"name": "Joe", "email": "user@email.com"}, dry=True).to_sql()
+ to_sql = self.builder.update(
+ {"name": "Joe", "email": "user@email.com"}, dry=True
+ ).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_update_with_multiple_where(self):
- to_sql = self.builder.where("name", "bob").where("age", 20).update({"name": "Joe"}, dry=True).to_sql()
-
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.where("name", "bob")
+ .where("age", 20)
+ .update({"name": "Joe"}, dry=True)
+ .to_sql()
+ )
+
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
# def test_can_compile_increment(self):
@@ -48,7 +65,9 @@ def test_can_compile_update_with_multiple_where(self):
def test_raw_expression(self):
to_sql = self.builder.update({"name": Raw('"username"')}, dry=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder.py
index 0ba045a6..1dd4b761 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder.py
@@ -1,9 +1,9 @@
import unittest
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import PostgresConnection
from src.masoniteorm.schema import Schema
from src.masoniteorm.schema.platforms import PostgresPlatform
-from tests.integrations.config.database import DATABASES
class TestPostgresSchemaBuilder(unittest.TestCase):
@@ -26,7 +26,9 @@ def test_can_add_columns(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ['CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'],
+ [
+ 'CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'
+ ],
)
def test_can_add_tiny_text(self):
@@ -34,7 +36,9 @@ def test_can_add_tiny_text(self):
blueprint.tiny_text("description")
self.assertEqual(len(blueprint.table.added_columns), 1)
- self.assertEqual(blueprint.to_sql(), ['CREATE TABLE "users" ("description" TEXT NOT NULL)'])
+ self.assertEqual(
+ blueprint.to_sql(), ['CREATE TABLE "users" ("description" TEXT NOT NULL)']
+ )
def test_can_add_unsigned_decimal(self):
with self.schema.create("users") as blueprint:
@@ -54,7 +58,9 @@ def test_can_create_table_if_not_exists(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ['CREATE TABLE IF NOT EXISTS "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'],
+ [
+ 'CREATE TABLE IF NOT EXISTS "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'
+ ],
)
def test_can_add_column_comment(self):
@@ -131,7 +137,9 @@ def test_can_add_columns_with_long_text(self):
blueprint.long_text("description")
self.assertEqual(len(blueprint.table.added_columns), 1)
- self.assertEqual(blueprint.to_sql(), ['CREATE TABLE "users" ("description" TEXT NOT NULL)'])
+ self.assertEqual(
+ blueprint.to_sql(), ['CREATE TABLE "users" ("description" TEXT NOT NULL)']
+ )
def test_can_have_unsigned_columns(self):
with self.schema.create("users") as blueprint:
@@ -211,7 +219,9 @@ def test_can_advanced_table_creation2(self):
blueprint.integer("premium")
blueprint.double("amount").default(0.0)
blueprint.integer("author_id").unsigned().nullable()
- blueprint.foreign("author_id").references("id").on("authors").on_delete("CASCADE")
+ blueprint.foreign("author_id").references("id").on("authors").on_delete(
+ "CASCADE"
+ )
blueprint.text("description")
blueprint.timestamps()
@@ -251,7 +261,9 @@ def test_can_add_uuid_column(self):
def test_can_add_columns_with_foreign_key_constraint_name(self):
with self.schema.create("users") as blueprint:
blueprint.integer("profile_id")
- blueprint.foreign("profile_id", name="profile_foreign").references("id").on("profiles")
+ blueprint.foreign("profile_id", name="profile_foreign").references("id").on(
+ "profiles"
+ )
self.assertEqual(len(blueprint.table.added_columns), 1)
self.assertEqual(
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder_alter.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder_alter.py
index 05fa9c99..32a16b55 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder_alter.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/postgres/schema/test_postgres_schema_builder_alter.py
@@ -1,10 +1,10 @@
import unittest
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import PostgresConnection
from src.masoniteorm.schema import Schema
from src.masoniteorm.schema.platforms import PostgresPlatform
from src.masoniteorm.schema.Table import Table
-from tests.integrations.config.database import DATABASES
class TestPostgresSchemaBuilderAlter(unittest.TestCase):
@@ -26,7 +26,9 @@ def test_can_add_columns(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
- sql = ['ALTER TABLE "users" ADD COLUMN "name" VARCHAR(255) NOT NULL, ADD COLUMN "age" INTEGER NOT NULL']
+ sql = [
+ 'ALTER TABLE "users" ADD COLUMN "name" VARCHAR(255) NOT NULL, ADD COLUMN "age" INTEGER NOT NULL'
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -96,7 +98,9 @@ def test_alter_drop(self):
def test_alter_add_column_and_foreign_key(self):
with self.schema.table("users") as blueprint:
blueprint.unsigned_integer("playlist_id").nullable()
- blueprint.foreign("playlist_id").references("id").on("playlists").on_delete("cascade")
+ blueprint.foreign("playlist_id").references("id").on("playlists").on_delete(
+ "cascade"
+ )
sql = [
'ALTER TABLE "users" ADD COLUMN "playlist_id" INTEGER NULL',
@@ -160,7 +164,9 @@ def test_alter_add_primary(self):
with self.schema.table("users") as blueprint:
blueprint.primary("playlist_id")
- sql = ['ALTER TABLE "users" ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)']
+ sql = [
+ 'ALTER TABLE "users" ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)'
+ ]
self.assertEqual(blueprint.to_sql(), sql)
@@ -239,7 +245,9 @@ def test_change_string(self):
blueprint.table.from_table = table
- sql = ['ALTER TABLE "users" ALTER COLUMN "name" TYPE VARCHAR(93), ALTER COLUMN "name" SET NOT NULL']
+ sql = [
+ 'ALTER TABLE "users" ALTER COLUMN "name" TYPE VARCHAR(93), ALTER COLUMN "name" SET NOT NULL'
+ ]
self.assertEqual(blueprint.to_sql(), sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/scopes/test_default_global_scopes.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/scopes/test_default_global_scopes.py
index 6bf19e86..0a7b7568 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/scopes/test_default_global_scopes.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/scopes/test_default_global_scopes.py
@@ -4,6 +4,7 @@
import uuid
import pendulum
+
from src.masoniteorm.models import Model
from src.masoniteorm.scopes import (
SoftDeletesMixin,
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder.py
index 558cb90d..d41299ef 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder.py
@@ -4,6 +4,7 @@
from pathlib import Path
import pytest
+
from src.masoniteorm.config import load_config
from src.masoniteorm.connections import ConnectionResolver
from src.masoniteorm.exceptions import (
@@ -70,7 +71,9 @@ def test_sum(self):
builder = self.get_builder()
builder.sum("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_sum_aggregate(self):
@@ -84,7 +87,9 @@ def test_sum_aggregate_with_alias(self):
builder = self.get_builder()
builder.aggregate("SUM", "age", alias="number")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_sum_aggregate_with_alias_in_column_name(self):
@@ -98,51 +103,67 @@ def test_where_like(self):
builder = self.get_builder()
builder.where("age", "like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_like(self):
builder = self.get_builder()
builder.where("age", "not like", "%name%")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_max(self):
builder = self.get_builder()
builder.max("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_min(self):
builder = self.get_builder()
builder.min("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_avg(self):
builder = self.get_builder()
builder.avg("age")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_all(self):
builder = self.get_builder()
builder.all()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_get(self):
builder = self.get_builder()
builder.get()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_first(self):
builder = self.get_builder().first(query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_last(self):
@@ -166,7 +187,9 @@ def test_find_or_404_exception(self):
def test_select(self):
builder = self.get_builder()
builder.select("name", "email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_multiple(self):
@@ -183,7 +206,9 @@ def test_add_select(self):
.add_select("salary", lambda q: q.count("*").table("salary"))
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_add_select_no_table(self):
@@ -199,7 +224,9 @@ def test_add_select_no_table(self):
)
.to_sql()
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_add_select_with_raw(self):
@@ -209,16 +236,24 @@ def test_add_select_with_raw(self):
.from_("some_table")
.add_select(
"other_test",
- lambda query: query.max("updated_at").from_("different_table").where("some_id", "=", "3"),
+ lambda query: (
+ query.max("updated_at")
+ .from_("different_table")
+ .where("some_id", "=", "3")
+ ),
)
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_select_raw(self):
builder = self.get_builder()
builder.select_raw("count(email) as email_count")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_create(self):
@@ -227,19 +262,25 @@ def test_create(self):
{"name": "Corentin All", "email": "corentin@yopmail.com"},
query=True,
)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_delete(self):
builder = self.get_builder()
builder.delete("name", "Joe", query=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where(self):
builder = self.get_builder()
builder.where("name", "Joe")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_dictionary(self):
@@ -251,112 +292,152 @@ def test_where_dictionary(self):
def test_where_exists(self):
builder = self.get_builder()
builder.where_exists("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_limit(self):
builder = self.get_builder()
builder.limit(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_offset(self):
builder = self.get_builder()
builder.offset(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_offset_with_limit(self):
builder = self.get_builder()
builder.limit(2).offset(5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_join(self):
builder = self.get_builder()
builder.join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_left_join(self):
builder = self.get_builder()
builder.left_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_right_join(self):
builder = self.get_builder()
builder.right_join("profiles", "users.id", "=", "profiles.user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_update(self):
- builder = self.get_builder().update({"name": "Joe", "email": "joe@yopmail.com"}, dry=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ builder = self.get_builder().update(
+ {"name": "Joe", "email": "joe@yopmail.com"}, dry=True
+ )
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_increment(self):
builder = self.get_builder().increment("age", 1, dry=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_decrement(self):
builder = self.get_builder().decrement("age", 1, dry=True)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_count(self):
builder = self.get_builder()
builder.count("id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_asc(self):
builder = self.get_builder()
builder.order_by("email", "asc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_multiple(self):
builder = self.get_builder()
builder.order_by("email, name, active")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_reference_direction(self):
builder = self.get_builder()
builder.order_by("email, name desc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_raw(self):
builder = self.get_builder()
builder.order_by_raw("col asc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_order_by_desc(self):
builder = self.get_builder()
builder.order_by("email", "desc")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_column(self):
builder = self.get_builder()
builder.where_column("name", "username")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_in(self):
builder = self.get_builder()
builder.where_not_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_between(self):
builder = self.get_builder()
builder.between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_between_persisted(self):
@@ -368,7 +449,9 @@ def test_between_persisted(self):
def test_not_between(self):
builder = self.get_builder()
builder.not_between("id", 2, 5)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_not_between_persisted(self):
@@ -381,49 +464,65 @@ def test_where_in(self):
builder = self.get_builder()
builder.where_in("id", [1, 2, 3])
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_null(self):
builder = self.get_builder()
builder.where_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_not_null(self):
builder = self.get_builder()
builder.where_not_null("name")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_having(self):
builder = self.get_builder(table="payments")
- builder.select("user_id").avg("salary").group_by("user_id").having("salary", ">=", "1000")
+ builder.select("user_id").avg("salary").group_by("user_id").having(
+ "salary", ">=", "1000"
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by(self):
builder = self.get_builder(table="payments")
builder.select("user_id").min("salary").group_by("user_id")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by_raw(self):
builder = self.get_builder(table="payments")
builder.select("user_id").min("salary").group_by_raw("count(*)")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by_multiple(self):
builder = self.get_builder(table="payments")
builder.select("user_id").min("salary").group_by("user_id").group_by("salary")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_group_by_multiple_in_same_group_by(self):
@@ -450,42 +549,59 @@ def test_builder_alone(self):
def test_where_lt(self):
builder = self.get_builder()
builder.where("age", "<", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_lte(self):
builder = self.get_builder()
builder.where("age", "<=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gt(self):
builder = self.get_builder()
builder.where("age", ">", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_gte(self):
builder = self.get_builder()
builder.where("age", ">=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_where_ne(self):
builder = self.get_builder()
builder.where("age", "!=", "20")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_or_where(self):
builder = self.get_builder()
builder.where("age", "20").or_where("age", "<", 20)
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_can_call_with_schema(self):
builder = self.get_builder()
- sql = builder.table("information_schema.columns").select("table_name").where("table_name", "users").to_sql()
+ sql = (
+ builder.table("information_schema.columns")
+ .select("table_name")
+ .where("table_name", "users")
+ .to_sql()
+ )
self.assertEqual(
sql,
"""SELECT "information_schema"."columns"."table_name" FROM "information_schema"."columns" WHERE "information_schema"."columns"."table_name" = 'users'""",
@@ -499,13 +615,17 @@ def test_can_call_with_raw(self):
def test_truncate(self):
builder = self.get_builder()
sql = builder.truncate(dry=True)
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
def test_truncate_without_foreign_keys(self):
builder = self.get_builder()
sql = builder.truncate(foreign_keys=True)
- sql_ref = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql_ref = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(sql, sql_ref)
@@ -732,7 +852,9 @@ def order_by_multiple(self):
"""
builder.order_by('email', 'asc')
"""
- return """SELECT * FROM "users" ORDER BY "email" ASC, "name" ASC, "active" ASC"""
+ return (
+ """SELECT * FROM "users" ORDER BY "email" ASC, "name" ASC, "active" ASC"""
+ )
def order_by_raw(self):
"""
@@ -907,13 +1029,17 @@ def truncate_without_foreign_keys(self):
def test_latest(self):
builder = self.get_builder()
builder.latest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def test_oldest(self):
builder = self.get_builder()
builder.oldest("email")
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(builder.to_sql(), sql)
def oldest(self):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder_relationships.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder_relationships.py
index 1da114eb..7e883ed4 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder_relationships.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/builder/test_sqlite_query_builder_relationships.py
@@ -1,6 +1,7 @@
import unittest
from dotenv import load_dotenv
+
from src.masoniteorm.connections import ConnectionFactory
from src.masoniteorm.models import Model
from src.masoniteorm.query import QueryBuilder
@@ -74,7 +75,9 @@ def test_doesnt_have(self):
def test_where_doesnt_have(self):
builder = self.get_builder()
- sql = builder.where_doesnt_have("articles", lambda q: q.where("title", "Eggs and Ham")).to_sql()
+ sql = builder.where_doesnt_have(
+ "articles", lambda q: q.where("title", "Eggs and Ham")
+ ).to_sql()
self.assertEqual(
sql,
"""SELECT * FROM "users" WHERE NOT EXISTS ("""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_delete_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_delete_grammar.py
index 15fdd558..3bd36a87 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_delete_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_delete_grammar.py
@@ -12,19 +12,30 @@ def setUp(self):
def test_can_compile_delete(self):
to_sql = self.builder.delete("id", 1, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_in(self):
to_sql = self.builder.delete("id", [1, 2, 3], query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_delete_with_where(self):
- to_sql = self.builder.where("age", 20).where("profile", 1).delete(query=True).to_sql()
+ to_sql = (
+ self.builder.where("age", 20)
+ .where("profile", 1)
+ .delete(query=True)
+ .to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_insert_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_insert_grammar.py
index 8215320c..35ee7eb9 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_insert_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_insert_grammar.py
@@ -12,13 +12,17 @@ def setUp(self):
def test_can_compile_insert(self):
to_sql = self.builder.create({"name": "Joe"}, query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_insert_with_keywords(self):
to_sql = self.builder.create(name="Joe", query=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create(self):
@@ -32,13 +36,19 @@ def test_can_compile_bulk_create(self):
query=True,
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_qmark(self):
- to_sql = self.builder.bulk_create([{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True).to_qmark()
+ to_sql = self.builder.bulk_create(
+ [{"name": "Joe"}, {"name": "Bill"}, {"name": "John"}], query=True
+ ).to_qmark()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_bulk_create_multiple(self):
@@ -51,7 +61,9 @@ def test_can_compile_bulk_create_multiple(self):
query=True,
).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_select_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_select_grammar.py
index c1af0f3b..45575648 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_select_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_select_grammar.py
@@ -78,7 +78,9 @@ def can_compile_with_multiple_order_by(self):
"""
self.builder.select('username').order_by('age', 'desc').order_by('name').to_sql()
"""
- return """SELECT "users"."username" FROM "users" ORDER BY "age" DESC, "name" ASC"""
+ return (
+ """SELECT "users"."username" FROM "users" ORDER BY "age" DESC, "name" ASC"""
+ )
def can_compile_with_group_by(self):
"""
@@ -114,7 +116,9 @@ def can_compile_where_not_null(self):
"""
self.builder.select('username').where_not_null('age').to_sql()
"""
- return """SELECT "users"."username" FROM "users" WHERE "users"."age" IS NOT NULL"""
+ return (
+ """SELECT "users"."username" FROM "users" WHERE "users"."age" IS NOT NULL"""
+ )
def can_compile_where_raw(self):
"""
@@ -292,9 +296,9 @@ def test_can_compile_where_raw(self):
self.assertEqual(to_sql, """SELECT * FROM "users" WHERE "age" = '18'""")
def test_can_compile_where_raw_and_where_with_multiple_bindings(self):
- query = self.builder.where_raw(""" "age" = ? AND "is_admin" = ? """, [18, True]).where(
- "email", "test@example.com"
- )
+ query = self.builder.where_raw(
+ """ "age" = ? AND "is_admin" = ? """, [18, True]
+ ).where("email", "test@example.com")
self.assertEqual(
query.to_qmark(),
"""SELECT * FROM "users" WHERE "age" = ? AND "is_admin" = ? AND "users"."email" = ?""",
@@ -419,9 +423,7 @@ def can_compile_left_join_clause_with_lambda(self):
),
).to_sql()
"""
- return (
- """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
- )
+ return """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
def can_compile_right_join_clause_with_lambda(self):
"""
@@ -434,9 +436,7 @@ def can_compile_right_join_clause_with_lambda(self):
),
).to_sql()
"""
- return (
- """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
- )
+ return """SELECT * FROM "users" LEFT JOIN "report_groups" AS "rg" ON "bgt"."fund" = "rg"."fund" OR "bgt" IS NULL"""
def update_lock(self):
"""
@@ -465,7 +465,9 @@ def where_not_exists_with_lambda(self):
return """SELECT * FROM "users" WHERE NOT EXISTS (SELECT * FROM "users" WHERE "users"."age" = '1')"""
def where_date(self):
- return """SELECT * FROM "users" WHERE DATE("users"."created_at") = '2022-06-01'"""
+ return (
+ """SELECT * FROM "users" WHERE DATE("users"."created_at") = '2022-06-01'"""
+ )
def or_where_null(self):
return """SELECT * FROM "users" WHERE "users"."column1" IS NULL OR "users"."column2" IS NULL"""
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_update_grammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_update_grammar.py
index df8a289e..4ee26543 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_update_grammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/grammar/test_sqlite_update_grammar.py
@@ -1,9 +1,9 @@
import inspect
import unittest
-from src.masoniteorm.expressions import Raw
from src.masoniteorm.query import QueryBuilder
from src.masoniteorm.query.grammars import SQLiteGrammar
+from src.masoniteorm.expressions import Raw
class BaseTestCaseUpdateGrammar:
@@ -11,21 +11,36 @@ def setUp(self):
self.builder = QueryBuilder(SQLiteGrammar, table="users")
def test_can_compile_update(self):
- to_sql = self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ to_sql = (
+ self.builder.where("name", "bob").update({"name": "Joe"}, dry=True).to_sql()
+ )
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_multiple_update(self):
- to_sql = self.builder.update({"name": "Joe", "email": "user@email.com"}, dry=True).to_sql()
+ to_sql = self.builder.update(
+ {"name": "Joe", "email": "user@email.com"}, dry=True
+ ).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
def test_can_compile_update_with_multiple_where(self):
- to_sql = self.builder.where("name", "bob").where("age", 20).update({"name": "Joe"}, dry=True).to_sql()
-
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ to_sql = (
+ self.builder.where("name", "bob")
+ .where("age", 20)
+ .update({"name": "Joe"}, dry=True)
+ .to_sql()
+ )
+
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
# def test_can_compile_increment(self):
@@ -45,7 +60,9 @@ def test_can_compile_update_with_multiple_where(self):
def test_raw_expression(self):
to_sql = self.builder.update({"name": Raw('"username"')}, dry=True).to_sql()
- sql = getattr(self, inspect.currentframe().f_code.co_name.replace("test_", ""))()
+ sql = getattr(
+ self, inspect.currentframe().f_code.co_name.replace("test_", "")
+ )()
self.assertEqual(to_sql, sql)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_many_through_relationship.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_many_through_relationship.py
index 4fcab9a9..f9c7bcc3 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_many_through_relationship.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_many_through_relationship.py
@@ -1,5 +1,4 @@
import pytest_asyncio
-from fastapi_startkit.masoniteorm.tests.integrations.config.database import DATABASES
from fastapi_startkit.masoniteorm.collection import Collection
from fastapi_startkit.masoniteorm.connections.sqlite_connection import SQLiteConnection
@@ -7,6 +6,7 @@
from fastapi_startkit.masoniteorm.relationships import HasManyThrough
from fastapi_startkit.masoniteorm.schema import Schema
from fastapi_startkit.masoniteorm.schema.platforms import SQLitePlatform
+from fastapi_startkit.masoniteorm.tests.integrations.config.database import DATABASES
class Enrolment(Model):
@@ -33,7 +33,11 @@ class Course(Model):
name: str
students: list[Student] = HasManyThrough(
- ["Student", "Enrolment"], "in_course_id", "active_student_id", "course_id", "student_id"
+ ["Student", "Enrolment"],
+ "in_course_id",
+ "active_student_id",
+ "course_id",
+ "student_id",
)
@@ -158,5 +162,7 @@ async def test_has_many_through_can_get_related(self):
assert students.count() == 2
async def test_has_many_through_has_query(self):
- courses = await Course.where_has("students", lambda query: query.where("name", "Bob")).get()
+ courses = await Course.where_has(
+ "students", lambda query: query.where("name", "Bob")
+ ).get()
assert courses.count() == 2
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_one_through_relationship.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_one_through_relationship.py
index e39b5401..37b11e92 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_one_through_relationship.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_has_one_through_relationship.py
@@ -42,7 +42,9 @@ async def setup(self):
config_path="fastapi_startkit/masoniteorm/tests/integrations/config/database",
).on("dev")
- async with await self.schema.create_table_if_not_exists("incoming_shipments") as table:
+ async with await self.schema.create_table_if_not_exists(
+ "incoming_shipments"
+ ) as table:
table.integer("shipment_id").primary()
table.string("name")
table.integer("from_port_id")
@@ -110,7 +112,9 @@ async def setup(self):
SQLiteConnection._shared_engines.clear()
async def test_has_one_through_can_eager_load(self):
- shipments = await IncomingShipment.where("name", "Bread").with_("from_country").get()
+ shipments = await (
+ IncomingShipment.where("name", "Bread").with_("from_country").get()
+ )
assert shipments.count() == 2
shipment1 = shipments.shift()
@@ -122,11 +126,19 @@ async def test_has_one_through_can_eager_load(self):
assert shipment2.from_country.country_id == 40
# check .first() and .get() produce the same result
- single = await IncomingShipment.where("name", "Tractor Parts").with_("from_country").first()
- single_get = await IncomingShipment.where("name", "Tractor Parts").with_("from_country").get()
+ single = await (
+ IncomingShipment.where("name", "Tractor Parts")
+ .with_("from_country")
+ .first()
+ )
+ single_get = await (
+ IncomingShipment.where("name", "Tractor Parts").with_("from_country").get()
+ )
assert single.from_country.country_id == 10
assert single_get.count() == 1
- assert single.from_country.country_id == single_get.first().from_country.country_id
+ assert (
+ single.from_country.country_id == single_get.first().from_country.country_id
+ )
async def test_has_one_through_eager_load_can_be_empty(self):
shipments = await (
@@ -144,5 +156,7 @@ async def test_has_one_through_can_get_related(self):
assert country.country_id == 10
async def test_has_one_through_has_query(self):
- shipments = await IncomingShipment.where_has("from_country", lambda query: query.where("name", "USA")).get()
+ shipments = await IncomingShipment.where_has(
+ "from_country", lambda query: query.where("name", "USA")
+ ).get()
assert shipments.count() == 2
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_polymorphic.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_polymorphic.py
index 7876ed81..c926b3e6 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_polymorphic.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/relationships/test_sqlite_polymorphic.py
@@ -1,11 +1,11 @@
import pytest_asyncio
-from fastapi_startkit.masoniteorm.tests.integrations.config.database import DB
from fastapi_startkit.masoniteorm.connections.sqlite_connection import SQLiteConnection
from fastapi_startkit.masoniteorm.models import Model
from fastapi_startkit.masoniteorm.relationships import BelongsTo, MorphTo
from fastapi_startkit.masoniteorm.schema import Schema
from fastapi_startkit.masoniteorm.schema.platforms import SQLitePlatform
+from fastapi_startkit.masoniteorm.tests.integrations.config.database import DB
class Profile(Model):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder.py
index cd5c4fa7..c31c74ee 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder.py
@@ -1,9 +1,8 @@
import unittest
-from fastapi_startkit.masoniteorm.tests.integrations.config.database import DATABASES
-
from fastapi_startkit.masoniteorm.schema import Schema
from fastapi_startkit.masoniteorm.schema.platforms import SQLitePlatform
+from fastapi_startkit.masoniteorm.tests.integrations.config.database import DATABASES
class TestSQLiteSchemaBuilder(unittest.TestCase):
@@ -25,7 +24,9 @@ def test_can_add_columns(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ['CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'],
+ [
+ 'CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'
+ ],
)
def test_can_add_tiny_text(self):
@@ -56,7 +57,9 @@ def test_can_create_table_if_not_exists(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ['CREATE TABLE IF NOT EXISTS "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'],
+ [
+ 'CREATE TABLE IF NOT EXISTS "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL)'
+ ],
)
def test_can_add_columns_with_constraint(self):
@@ -68,7 +71,9 @@ def test_can_add_columns_with_constraint(self):
self.assertEqual(len(blueprint.table.added_columns), 2)
self.assertEqual(
blueprint.to_sql(),
- ['CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL, UNIQUE(name))'],
+ [
+ 'CREATE TABLE "users" ("name" VARCHAR(255) NOT NULL, "age" INTEGER NOT NULL, UNIQUE(name))'
+ ],
)
def test_can_have_float_type(self):
@@ -108,7 +113,9 @@ def test_can_add_columns_with_foreign_key_constraint_name(self):
blueprint.string("name").unique()
blueprint.integer("age")
blueprint.integer("profile_id")
- blueprint.foreign("profile_id", name="profile_foreign").references("id").on("profiles")
+ blueprint.foreign("profile_id", name="profile_foreign").references("id").on(
+ "profiles"
+ )
self.assertEqual(len(blueprint.table.added_columns), 3)
self.assertEqual(
@@ -252,7 +259,9 @@ def test_can_advanced_table_creation2(self):
blueprint.string("thumbnail").nullable()
blueprint.integer("premium")
blueprint.integer("author_id").unsigned().nullable()
- blueprint.foreign("author_id").references("id").on("users").on_delete("set null")
+ blueprint.foreign("author_id").references("id").on("users").on_delete(
+ "set null"
+ )
blueprint.text("description")
blueprint.timestamps()
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder_alter.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder_alter.py
index ed752ac1..45179ced 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder_alter.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_sqlite_schema_builder_alter.py
@@ -155,14 +155,18 @@ def test_alter_add_primary(self):
with self.schema.table("users") as blueprint:
blueprint.primary("playlist_id")
- sql = ['ALTER TABLE "users" ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)']
+ sql = [
+ 'ALTER TABLE "users" ADD CONSTRAINT users_playlist_id_primary PRIMARY KEY (playlist_id)'
+ ]
self.assertEqual(blueprint.to_sql(), sql)
def test_alter_add_column_and_foreign_key(self):
with self.schema.table("users") as blueprint:
blueprint.unsigned_integer("playlist_id").nullable()
- blueprint.foreign("playlist_id").references("id").on("playlists").on_delete("cascade").on_update("SET NULL")
+ blueprint.foreign("playlist_id").references("id").on("playlists").on_delete(
+ "cascade"
+ ).on_update("SET NULL")
table = Table("users")
table.add_column("age", "string")
@@ -184,7 +188,9 @@ def test_alter_add_column_and_foreign_key(self):
def test_alter_add_foreign_key_only(self):
with self.schema.table("users") as blueprint:
- blueprint.foreign("playlist_id").references("id").on("playlists").on_delete("cascade").on_update("set null")
+ blueprint.foreign("playlist_id").references("id").on("playlists").on_delete(
+ "cascade"
+ ).on_update("set null")
table = Table("users")
table.add_column("age", "string")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_table.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_table.py
index bf8be546..2e73a4ab 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_table.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm.backup/tests/sqlite/schema/test_table.py
@@ -1,9 +1,9 @@
import unittest
+from tests.integrations.config.database import DATABASES
from src.masoniteorm.connections import SQLiteConnection
from src.masoniteorm.schema import Column, Table
from src.masoniteorm.schema.platforms.SQLitePlatform import SQLitePlatform
-from tests.integrations.config.database import DATABASES
class TestTable(unittest.TestCase):
@@ -100,7 +100,9 @@ def test_create_sql_with_foreign_key_constraint(self):
def test_can_build_table_from_connection_call(self):
sql_details = DATABASES["dev"]
table = self.platform.get_current_schema(
- SQLiteConnection(database=sql_details["database"], name="dev").make_connection(),
+ SQLiteConnection(
+ database=sql_details["database"], name="dev"
+ ).make_connection(),
"table_schema",
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/__init__.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/__init__.py
index 882b4773..3b0ab691 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/__init__.py
@@ -1,2 +1,2 @@
-from .config.config import MySQLConfig, PostgresConfig, SQLiteConfig
from .providers import DatabaseProvider
+from .config.config import PostgresConfig, MySQLConfig, SQLiteConfig
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py
index 0cdc6249..b8750f00 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBMigrateCommand.py
@@ -1,8 +1,6 @@
import os
-
-from cleo.helpers import option
-
from .Command import Command
+from cleo.helpers import option
class DBMigrateCommand(Command):
@@ -24,7 +22,12 @@ class DBMigrateCommand(Command):
default="default",
description="The connection you want to run migrations on",
),
- option("force", "f", flag=True, description="Force migrations without prompt in production"),
+ option(
+ "force",
+ "f",
+ flag=True,
+ description="Force migrations without prompt in production",
+ ),
option(
"show",
"s",
@@ -52,7 +55,9 @@ async def handle_async(self):
if os.getenv("APP_ENV") == "production" and not self.option("force"):
answer = ""
while answer not in ["y", "n"]:
- answer = input("Do you want to run migrations in PRODUCTION ? (y/n)\n").lower()
+ answer = input(
+ "Do you want to run migrations in PRODUCTION ? (y/n)\n"
+ ).lower()
if answer != "y":
self.info("Migrations cancelled")
exit(0)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py
index 0d57df12..3b90c96a 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/DBSeedCommand.py
@@ -8,7 +8,14 @@ class DBSeedCommand(Command):
name = "db:seed"
description = "Run seeds."
- arguments = [argument("table", default="None", description="Name of the table to seed", optional=True)]
+ arguments = [
+ argument(
+ "table",
+ default="None",
+ description="Name of the table to seed",
+ optional=True,
+ )
+ ]
options = [
option(
@@ -66,7 +73,9 @@ async def handle_async(self):
seeder_seeded = seeder_file.split(".")[-1]
elif table != "None":
- seeder_file = f"{underscore(table)}_table_seeder.{camelize(table)}TableSeeder"
+ seeder_file = (
+ f"{underscore(table)}_table_seeder.{camelize(table)}TableSeeder"
+ )
await seeder.run_specific_seed(seeder_file)
seeder_seeded = f"{camelize(table)}TableSeeder"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/Entry.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/Entry.py
index fed23855..67c83ea3 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/Entry.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/Entry.py
@@ -8,18 +8,18 @@
from cleo.application import Application
from . import (
- DBMigrateCommand,
- DBSeedCommand,
MakeMigrationCommand,
MakeModelCommand,
MakeModelDocstringCommand,
MakeObserverCommand,
MakeSeedCommand,
+ DBMigrateCommand,
MigrateFreshCommand,
MigrateRefreshCommand,
MigrateResetCommand,
MigrateRollbackCommand,
MigrateStatusCommand,
+ DBSeedCommand,
ShellCommand,
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py
index f1c03b1e..9d1b6b35 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeMigrationCommand.py
@@ -1,10 +1,8 @@
import datetime
import os
import pathlib
-
-from cleo.helpers import argument, option
from inflection import camelize, tableize
-
+from cleo.helpers import argument, option
from .Command import Command
@@ -15,8 +13,12 @@ class MakeMigrationCommand(Command):
arguments = [argument("name", description="The name of the migration")]
options = [
- option("create", "c", flag=False, default="None", description="The table to create"),
- option("table", "t", flag=False, default="None", description="The table to alter"),
+ option(
+ "create", "c", flag=False, default="None", description="The table to create"
+ ),
+ option(
+ "table", "t", flag=False, default="None", description="The table to alter"
+ ),
option(
"directory",
"d",
@@ -58,4 +60,6 @@ def handle(self):
with open(os.path.join(os.getcwd(), migration_directory, file_name), "w") as fp:
fp.write(output)
- self.info(f"Migration file created: {os.path.join(migration_directory, file_name)}")
+ self.info(
+ f"Migration file created: {os.path.join(migration_directory, file_name)}"
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py
index b01f0bf0..4666602f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelCommand.py
@@ -1,10 +1,8 @@
import os
import pathlib
-
-from cleo.helpers import argument, option
from inflection import camelize, tableize, underscore
-
from .Command import Command
+from cleo.helpers import argument, option
class MakeModelCommand(Command):
@@ -14,11 +12,28 @@ class MakeModelCommand(Command):
arguments = [argument("name", description="The name of the model")]
options = [
- option("migration", "m", description="Optionally create a migration file", flag=True),
+ option(
+ "migration",
+ "m",
+ description="Optionally create a migration file",
+ flag=True,
+ ),
option("seeder", "s", description="Optionally create a seeder file", flag=True),
- option("create", "c", description="If the migration file should create a table", flag=True),
- option("table", "t", description="If the migration file should modify an existing table", flag=True),
- option("pep", "p", description="Makes the file into pep 8 standards", flag=True),
+ option(
+ "create",
+ "c",
+ description="If the migration file should create a table",
+ flag=True,
+ ),
+ option(
+ "table",
+ "t",
+ description="If the migration file should modify an existing table",
+ flag=True,
+ ),
+ option(
+ "pep", "p", description="Makes the file into pep 8 standards", flag=True
+ ),
option(
"directory",
"d",
@@ -47,7 +62,9 @@ def handle(self):
model_directory = self.option("directory")
- with open(os.path.join(pathlib.Path(__file__).parent.absolute(), "stubs/model.stub")) as fp:
+ with open(
+ os.path.join(pathlib.Path(__file__).parent.absolute(), "stubs/model.stub")
+ ) as fp:
output = fp.read()
output = output.replace("__CLASS__", camelize(name))
@@ -59,7 +76,9 @@ def handle(self):
full_directory_path = os.path.join(os.getcwd(), model_directory)
if os.path.exists(os.path.join(full_directory_path, file_name)):
- self.line(f'Model "{name}" Already Exists ({full_directory_path}/{file_name})')
+ self.line(
+ f'Model "{name}" Already Exists ({full_directory_path}/{file_name})'
+ )
return
os.makedirs(os.path.dirname(os.path.join(full_directory_path)), exist_ok=True)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelDocstringCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelDocstringCommand.py
index 91895550..732e6daa 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelDocstringCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeModelDocstringCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import argument, option
-
from ..config import load_config
from .Command import Command
@@ -8,7 +7,12 @@ class MakeModelDocstringCommand(Command):
name = "model:docstring"
description = "Generate model docstring and type hints (for auto-completion)."
- arguments = [argument("table", description="The table you want to generate docstring and type hints")]
+ arguments = [
+ argument(
+ "table",
+ description="The table you want to generate docstring and type hints",
+ )
+ ]
options = [
option(
@@ -17,7 +21,13 @@ class MakeModelDocstringCommand(Command):
description="The table you want to generate docstring and type hints",
flag=True,
),
- option("connection", "c", flag=False, default="default", description="The connection you want to use"),
+ option(
+ "connection",
+ "c",
+ flag=False,
+ default="default",
+ description="The connection you want to use",
+ ),
]
def handle(self):
@@ -27,7 +37,9 @@ def handle(self):
schema = DB.get_schema_builder(self.option("connection"))
if not schema.has_table(table):
- return self.line_error(f"There is no such table {table} for this connection.")
+ return self.line_error(
+ f"There is no such table {table} for this connection."
+ )
self.info(f"Model Docstring for table: {table}")
print('"""')
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeObserverCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeObserverCommand.py
index cc1203fb..e46071d3 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeObserverCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeObserverCommand.py
@@ -1,9 +1,7 @@
+from cleo.helpers import argument, option
import os
import pathlib
-
-from cleo.helpers import argument, option
from inflection import camelize, underscore
-
from .Command import Command
@@ -14,7 +12,13 @@ class MakeObserverCommand(Command):
arguments = [argument("name", description="The name of the observer")]
options = [
- option("model", "m", flag=False, default="None", description="The name of the model"),
+ option(
+ "model",
+ "m",
+ flag=False,
+ default="None",
+ description="The name of the model",
+ ),
option(
"directory",
"d",
@@ -32,7 +36,11 @@ def handle(self):
observer_directory = self.option("directory")
- with open(os.path.join(pathlib.Path(__file__).parent.absolute(), "stubs/observer.stub")) as fp:
+ with open(
+ os.path.join(
+ pathlib.Path(__file__).parent.absolute(), "stubs/observer.stub"
+ )
+ ) as fp:
output = fp.read()
output = output.replace("__CLASS__", camelize(name))
output = output.replace("__MODEL_VARIABLE__", underscore(model))
@@ -43,7 +51,9 @@ def handle(self):
full_directory_path = os.path.join(os.getcwd(), observer_directory)
if os.path.exists(os.path.join(full_directory_path, file_name)):
- self.line(f'Observer "{name}" Already Exists ({full_directory_path}/{file_name})')
+ self.line(
+ f'Observer "{name}" Already Exists ({full_directory_path}/{file_name})'
+ )
return
os.makedirs(os.path.join(full_directory_path), exist_ok=True)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py
index adf89180..8349088d 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MakeSeedCommand.py
@@ -1,9 +1,7 @@
+from cleo.helpers import argument, option
import os
import pathlib
-
-from cleo.helpers import argument, option
from inflection import camelize, underscore
-
from .Command import Command
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py
index 84e9f85a..35aba878 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateFreshCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import option
-
from .Command import Command
@@ -22,7 +21,9 @@ class MigrateFreshCommand(Command):
default="databases/migrations",
description="The location of the migration directory",
),
- option("ignore-fk", "i", flag=True, description="Ignore foreign key constraints"),
+ option(
+ "ignore-fk", "i", flag=True, description="Ignore foreign key constraints"
+ ),
option(
"seed",
"s",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py
index d263fd11..c7a89836 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRefreshCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import option
-
from .Command import Command
@@ -22,7 +21,13 @@ class MigrateRefreshCommand(Command):
default="default",
description="The connection you want to run migrations on",
),
- option("schema", None, flag=False, default=None, description="Sets the schema to be migrated"),
+ option(
+ "schema",
+ None,
+ flag=False,
+ default=None,
+ description="Sets the schema to be migrated",
+ ),
option(
"directory",
"d",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py
index ae8ad3eb..3a1fd848 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateResetCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import option
-
from .Command import Command
@@ -22,7 +21,13 @@ class MigrateResetCommand(Command):
default="default",
description="The connection you want to run migrations on",
),
- option("schema", None, flag=False, default=None, description="Sets the schema to be migrated"),
+ option(
+ "schema",
+ None,
+ flag=False,
+ default=None,
+ description="Sets the schema to be migrated",
+ ),
option(
"directory",
"d",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py
index 3292adef..da874193 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateRollbackCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import option
-
from .Command import Command
@@ -28,7 +27,13 @@ class MigrateRollbackCommand(Command):
flag=True,
description="Shows the output of SQL for migrations that would be running",
),
- option("schema", None, flag=False, default=None, description="Sets the schema to be migrated"),
+ option(
+ "schema",
+ None,
+ flag=False,
+ default=None,
+ description="Sets the schema to be migrated",
+ ),
option(
"directory",
"d",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py
index 462573d8..66d4ae27 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/MigrateStatusCommand.py
@@ -1,5 +1,4 @@
from cleo.helpers import option
-
from ..migrations import Migration
from .Command import Command
@@ -16,7 +15,13 @@ class MigrateStatusCommand(Command):
default="default",
description="The connection you want to run migrations on",
),
- option("schema", None, flag=False, default=None, description="Sets the schema to be migrated"),
+ option(
+ "schema",
+ None,
+ flag=False,
+ default=None,
+ description="Sets the schema to be migrated",
+ ),
option(
"directory",
"d",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/ShellCommand.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/ShellCommand.py
index 755e8129..9cb6a0d0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/ShellCommand.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/ShellCommand.py
@@ -1,11 +1,9 @@
+from cleo.helpers import argument, option
import os
import re
import shlex
import subprocess
from collections import OrderedDict
-
-from cleo.helpers import option
-
from .Command import Command
@@ -44,7 +42,9 @@ def handle(self):
connection = resolver.get_connection_details()["default"]
config = resolver.get_connection_information(connection)
if not config.get("full_details"):
- self.line(f"Connection configuration for '{connection}' not found !")
+ self.line(
+ f"Connection configuration for '{connection}' not found !"
+ )
exit(-1)
command, env = self.get_command(config)
@@ -78,14 +78,19 @@ def get_command(self, config):
try:
get_driver_args = getattr(self, f"get_{driver}_args")
except AttributeError:
- self.line(f"Connecting with driver '{driver}' is not implemented !")
+ self.line(
+ f"Connecting with driver '{driver}' is not implemented !"
+ )
exit(-1)
args, options = get_driver_args(config)
# process positional arguments
args = " ".join(args)
# process optional arguments
options = self.remove_empty_options(options)
- options_string = " ".join(f"{option} {value}" if value else option for option, value in options.items())
+ options_string = " ".join(
+ f"{option} {value}" if value else option
+ for option, value in options.items()
+ )
# finally build command string
command = program
if args:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/__init__.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/__init__.py
index 05784e73..4c3b116f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/commands/__init__.py
@@ -3,15 +3,15 @@
sys.path.append(os.getcwd())
-from .DBMigrateCommand import DBMigrateCommand
-from .DBSeedCommand import DBSeedCommand
from .MakeMigrationCommand import MakeMigrationCommand
from .MakeModelCommand import MakeModelCommand
from .MakeObserverCommand import MakeObserverCommand
from .MakeSeedCommand import MakeSeedCommand
+from .DBMigrateCommand import DBMigrateCommand
from .MigrateFreshCommand import MigrateFreshCommand
from .MigrateRefreshCommand import MigrateRefreshCommand
from .MigrateResetCommand import MigrateResetCommand
from .MigrateRollbackCommand import MigrateRollbackCommand
from .MigrateStatusCommand import MigrateStatusCommand
+from .DBSeedCommand import DBSeedCommand
from .ShellCommand import ShellCommand
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/config.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/config.py
index c605d7fd..224b70ff 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/config.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/config.py
@@ -1,6 +1,5 @@
-from dataclasses import dataclass
-from typing import Any, Dict, Optional
-
+from typing import Optional, Dict, Any
+from pydantic.dataclasses import dataclass
from fastapi_startkit.environment.environment import env
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/database.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/database.py
index 5ad7c50f..0db7e1d7 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/database.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/config/database.py
@@ -1,5 +1,5 @@
from dataclasses import dataclass, field
-from typing import Any, Dict
+from typing import Dict, Any
from fastapi_startkit.environment import env
from fastapi_startkit.masoniteorm import SQLiteConfig
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/connection.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/connection.py
index 3826cf25..2da593b0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/connection.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/connection.py
@@ -1,5 +1,7 @@
+from typing import Any
+
from sqlalchemy import text
-from sqlalchemy.ext.asyncio import AsyncEngine
+from sqlalchemy.ext.asyncio import AsyncConnection, AsyncEngine
from fastapi_startkit.masoniteorm.models.builder import QueryBuilder
@@ -10,7 +12,11 @@ def __init__(self, connection: AsyncEngine, config: dict):
self.conn: AsyncEngine = connection
def query(self) -> "QueryBuilder":
- return QueryBuilder(connection=self, grammar=self.get_query_grammar(), processor=self.get_post_processor())
+ return QueryBuilder(
+ connection=self,
+ grammar=self.get_query_grammar(),
+ processor=self.get_post_processor(),
+ )
def get_query_grammar(cls):
pass
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/factory.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/factory.py
index 1d0ea2c5..73be80b4 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/factory.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/factory.py
@@ -1,11 +1,13 @@
from typing import Any
from sqlalchemy import StaticPool
-from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
+from sqlalchemy.ext.asyncio import create_async_engine, AsyncEngine
from fastapi_startkit.masoniteorm.connections.connection import Connection
-from fastapi_startkit.masoniteorm.connections.postgres_connection import PostgresConnection
from fastapi_startkit.masoniteorm.connections.sqlite_connection import SQliteConnection
+from fastapi_startkit.masoniteorm.connections.postgres_connection import (
+ PostgresConnection,
+)
class ConnectionFactory:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/manager.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/manager.py
index c663b003..d287fb0f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/manager.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/manager.py
@@ -13,11 +13,7 @@ def __init__(self, factory: "ConnectionFactory", config: dict):
def connection(self, name: str | None):
name = self.get_default_connection_name(name)
assert name is not None
- connections = self.config.get("connections", {})
- if name not in connections:
- raise ValueError(f"No connection name {name} found")
-
- config = connections[name]
+ config = self.config[name]
if name not in self.connections:
self.connections[name] = self.factory.make(config, name)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/postgres_connection.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/postgres_connection.py
index c53a6085..98f094db 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/postgres_connection.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/postgres_connection.py
@@ -1,9 +1,7 @@
from typing import Any
-
from fastapi_startkit.masoniteorm.query.grammars import PostgresGrammar
from fastapi_startkit.masoniteorm.query.processors import PostgresPostProcessor
from fastapi_startkit.masoniteorm.schema.platforms import PostgresPlatform
-
from .connection import Connection
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/sqlite_connection.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/sqlite_connection.py
index 56b107ad..3f705748 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/sqlite_connection.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/connections/sqlite_connection.py
@@ -1,7 +1,6 @@
from fastapi_startkit.masoniteorm.query.grammars import SQLiteGrammar
from fastapi_startkit.masoniteorm.query.processors import SQLitePostProcessor
from fastapi_startkit.masoniteorm.schema.platforms import SQLitePlatform
-
from .connection import Connection
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/expressions/expressions.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/expressions/expressions.py
index 4bef40c4..7eb77699 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/expressions/expressions.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/expressions/expressions.py
@@ -168,7 +168,9 @@ def on_value(self, column, *args):
def or_on_value(self, column, *args):
equality, value = self._extract_operator_value(*args)
- self.on_clauses += ((OnValueClause(column, equality, value, "value", operator="or")),)
+ self.on_clauses += (
+ (OnValueClause(column, equality, value, "value", operator="or")),
+ )
return self
def on_null(self, column):
@@ -216,7 +218,9 @@ def or_on_not_null(self, column: str):
Returns:
self
"""
- self.on_clauses += ((OnValueClause(column, "=", True, "NOT NULL", operator="or")),)
+ self.on_clauses += (
+ (OnValueClause(column, "=", True, "NOT NULL", operator="or")),
+ )
return self
@deprecated("Using where() in a Join clause has been superceded by on_value()")
@@ -237,7 +241,10 @@ def _extract_operator_value(self, *args):
value = args[0]
if operator not in operators:
- raise ValueError("Invalid comparison operator. The operator can be %s" % ", ".join(operators))
+ raise ValueError(
+ "Invalid comparison operator. The operator can be %s"
+ % ", ".join(operators)
+ )
return operator, value
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/facades/Schema.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/facades/Schema.py
index 36cf47b5..f7f7e363 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/facades/Schema.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/facades/Schema.py
@@ -3,8 +3,8 @@
from typing import TYPE_CHECKING
if TYPE_CHECKING:
- from fastapi_startkit.masoniteorm.schema.Blueprint import Blueprint
from fastapi_startkit.orm.schema.schema import Schema as SchemaBuilder
+ from fastapi_startkit.masoniteorm.schema.Blueprint import Blueprint
class Schema:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/factory/factory.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/factory/factory.py
index 03e22973..9d4c1b5f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/factory/factory.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/factory/factory.py
@@ -1,129 +1,20 @@
-import inspect
from abc import ABC, abstractmethod
-from typing import TYPE_CHECKING, Callable, List, Optional, Self, Tuple, Union
-
-from faker import Faker
+from typing import TYPE_CHECKING
if TYPE_CHECKING:
from fastapi_startkit.masoniteorm.models import Model
-fake = Faker()
-
class Factory(ABC):
model: "Model"
- fake: Faker = fake
- _after_making: List[Callable] = []
- _after_creating: List[Callable] = []
- _states: List[Callable] = []
- _has: List[Tuple["Factory", Optional[str]]] = []
- _for: Optional["Factory"] = None
- _count: Optional[int] = None
-
- def __init__(self):
- self._after_making = []
- self._after_creating = []
- self._states = []
- self._has = []
- self._for = None
- self._count = None
@abstractmethod
def definition(self) -> dict: ...
- def configure(self) -> Self:
- return self
-
- def count(self, n: int) -> Self:
- self._count = n
- return self
-
- def state(self, callback: Callable) -> Self:
- self._states.append(callback)
- return self
-
- def has(self, factory: "Factory", relationship: str = None) -> Self:
- self._has.append((factory, relationship))
- return self
-
- def for_(self, factory: "Factory") -> Self:
- self._for = factory
- return self
-
- def after_making(self, callback: Callable) -> Self:
- self._after_making.append(callback)
- return self
-
- def after_creating(self, callback: Callable) -> Self:
- self._after_creating.append(callback)
- return self
-
- def _apply_states(self, attributes: dict) -> dict:
- for state in self._states:
- if callable(state):
- if inspect.isfunction(state) or inspect.ismethod(state):
- # Check if it takes attributes
- sig = inspect.signature(state)
- if len(sig.parameters) > 0:
- attributes.update(state(attributes))
- else:
- attributes.update(state())
- else:
- attributes.update(state)
- elif isinstance(state, dict):
- attributes.update(state)
- return attributes
-
- async def make(self, **overrides) -> Union["Model", List["Model"]]:
- count = self._count or 1
- instances = []
-
- for _ in range(count):
- attributes = self.definition()
- attributes = self._apply_states(attributes)
- attributes.update(overrides)
-
- instance = self.model(attributes)
-
- for callback in self._after_making:
- await callback(instance)
-
- instances.append(instance)
-
- return instances if self._count is not None else instances[0]
-
- async def create(self, **overrides) -> Union["Model", List["Model"]]:
- count = self._count or 1
- results = []
-
- for _ in range(count):
- attributes = self.definition()
- attributes = self._apply_states(attributes)
- attributes.update(overrides)
-
- # Handle 'for' relationship
- if self._for:
- parent = await self._for.create()
- # Naive FK: parent_table_singular_id
- foreign_key = f"{parent.__table__[:-1]}_id"
- attributes[foreign_key] = parent.id
-
- result = await self.model.create(attributes)
-
- # Handle 'has' relationships
- for factory, relationship in self._has:
- # Naive FK: current_table_singular_id
- foreign_key = f"{self.model.__table__[:-1]}_id"
- await factory.create(**{foreign_key: result.id})
-
- for callback in self._after_creating:
- await callback(result)
-
- results.append(result)
-
- return results if self._count is not None else results[0]
-
@classmethod
- def new(cls) -> Self:
+ async def create(cls) -> "Model":
+ model: Model = cls.model
instance = cls()
- return instance.configure()
+
+ result = await model.create(instance.definition())
+ return result
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/migrations/Migration.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/migrations/Migration.py
index 57f30a1d..a88597df 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/migrations/Migration.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/migrations/Migration.py
@@ -38,7 +38,9 @@ async def get_unran_migrations(self):
all_migrations = [
f.replace(".py", "")
for f in listdir(directory_path)
- if isfile(join(directory_path, f)) and f != "__init__.py" and not f.startswith(".")
+ if isfile(join(directory_path, f))
+ and f != "__init__.py"
+ and not f.startswith(".")
]
all_migrations.sort()
unran_migrations = []
@@ -58,7 +60,9 @@ async def get_rollback_migrations(self):
async def get_all_migrations(self, reverse=False):
if reverse:
- return (await self.migration_model.order_by("migration_id", "desc").get()).pluck("migration")
+ return (
+ await self.migration_model.order_by("migration_id", "desc").get()
+ ).pluck("migration")
return (await self.migration_model.all()).pluck("migration")
@@ -71,7 +75,9 @@ async def delete_migration(self, file_path):
def locate(self, file_name):
migration_name = camelize("_".join(file_name.split("_")[4:]).replace(".py", ""))
file_name = file_name.replace(".py", "")
- migration_directory = self.migration_directory.replace("/", ".").replace("\\", ".")
+ migration_directory = self.migration_directory.replace("/", ".").replace(
+ "\\", "."
+ )
return locate(f"{migration_directory}.{file_name}.{migration_name}")
async def get_ran_migrations(self):
@@ -79,14 +85,18 @@ async def get_ran_migrations(self):
all_migrations = [
f.replace(".py", "")
for f in listdir(directory_path)
- if isfile(join(directory_path, f)) and f != "__init__.py" and not f.startswith(".")
+ if isfile(join(directory_path, f))
+ and f != "__init__.py"
+ and not f.startswith(".")
]
all_migrations.sort()
ran = []
database_migrations = await self.migration_model.all()
for migration in all_migrations:
- matched_migration = database_migrations.where("migration", migration).first()
+ matched_migration = database_migrations.where(
+ "migration", migration
+ ).first()
if matched_migration:
ran.append(
{
@@ -115,7 +125,9 @@ async def migrate(self, migration="all", output=False):
self.last_migrations_ran.append(migration)
if self.command_class:
- self.command_class.line(f"Migrating: {migration}")
+ self.command_class.line(
+ f"Migrating: {migration}"
+ )
migration_class = migration_class(connection=self.connection)
@@ -139,9 +151,13 @@ async def migrate(self, migration="all", output=False):
print(migration_class.schema._blueprint.to_sql())
if self.command_class:
- self.command_class.line(f"Migrated: {migration} ({duration}s)")
+ self.command_class.line(
+ f"Migrated: {migration} ({duration}s)"
+ )
- await self.migration_model.create({"batch": batch, "migration": migration.replace(".py", "")})
+ await self.migration_model.create(
+ {"batch": batch, "migration": migration.replace(".py", "")}
+ )
async def rollback(self, migration="all", output=False):
default_migrations = await self.get_rollback_migrations()
@@ -152,7 +168,9 @@ async def rollback(self, migration="all", output=False):
migration = migration.replace(".py", "")
if self.command_class:
- self.command_class.line(f"Rolling back: {migration}")
+ self.command_class.line(
+ f"Rolling back: {migration}"
+ )
try:
migration_class = self.locate(migration)
@@ -160,7 +178,9 @@ async def rollback(self, migration="all", output=False):
self.command_class.line(f"Not Found: {migration}")
continue
- migration_class = migration_class(connection=self.connection, schema=self.schema_name)
+ migration_class = migration_class(
+ connection=self.connection, schema=self.schema_name
+ )
if output:
migration_class.schema.dry()
@@ -173,7 +193,10 @@ async def rollback(self, migration="all", output=False):
if self.command_class:
table = self.command_class.table()
table.set_header_row(["SQL"])
- if hasattr(migration_class.schema, "_blueprint") and migration_class.schema._blueprint:
+ if (
+ hasattr(migration_class.schema, "_blueprint")
+ and migration_class.schema._blueprint
+ ):
sql = migration_class.schema._blueprint.to_sql()
if isinstance(sql, list):
sql = ",".join(sql)
@@ -189,13 +212,19 @@ async def rollback(self, migration="all", output=False):
await self.delete_migration(migration)
if self.command_class:
- self.command_class.line(f"Rolled back: {migration} ({duration}s)")
+ self.command_class.line(
+ f"Rolled back: {migration} ({duration}s)"
+ )
async def delete_migrations(self, migrations=None):
- return await self.migration_model.where_in("migration", migrations or []).delete()
+ return await self.migration_model.where_in(
+ "migration", migrations or []
+ ).delete()
async def delete_last_batch(self):
- return await self.migration_model.where("batch", await self.get_last_batch_number()).delete()
+ return await self.migration_model.where(
+ "batch", await self.get_last_batch_number()
+ ).delete()
async def reset(self, migration="all"):
default_migrations = await self.get_all_migrations(reverse=True)
@@ -209,10 +238,14 @@ async def reset(self, migration="all"):
for migration in migrations:
if self.command_class:
- self.command_class.line(f"Rolling back: {migration}")
+ self.command_class.line(
+ f"Rolling back: {migration}"
+ )
try:
- migration_instance = self.locate(migration)(connection=self.connection, schema=self.schema_name)
+ migration_instance = self.locate(migration)(
+ connection=self.connection, schema=self.schema_name
+ )
await migration_instance.down()
except TypeError:
self.command_class.line(f"Not Found: {migration}")
@@ -223,7 +256,9 @@ async def reset(self, migration="all"):
await self.delete_migration(migration)
if self.command_class:
- self.command_class.line(f"Rolled back: {migration}")
+ self.command_class.line(
+ f"Rolled back: {migration}"
+ )
await self.delete_migrations([migration])
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/__init__.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/__init__.py
index a18664ef..7c7cf005 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/__init__.py
@@ -1,3 +1,3 @@
-from .caster import Caster
from .model import Model
+from .caster import Caster
from .registry import Registry
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/attribute.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/attribute.py
index 27a81a7a..ba774ce4 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/attribute.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/attribute.py
@@ -29,7 +29,11 @@ def __init__(self, attributes: dict = None, **kwargs):
def __setattr__(self, key: str, value):
# Before _dirty_attributes is initialised (early __init__), or for
# internal/meta attributes, fall back to normal object assignment.
- if key.startswith("_") or key in self._META_ATTRIBUTES or "_dirty_attributes" not in self.__dict__:
+ if (
+ key.startswith("_")
+ or key in self._META_ATTRIBUTES
+ or "_dirty_attributes" not in self.__dict__
+ ):
super().__setattr__(key, value)
else:
self.set_attribute(key, value)
@@ -61,7 +65,10 @@ def get_attribute(self, key: str):
if "_attributes" in self.__dict__ and key in self.__dict__["_attributes"]:
value = self.__dict__["_attributes"][key]
- if "_dirty_attributes" in self.__dict__ and key in self.__dict__["_dirty_attributes"]:
+ if (
+ "_dirty_attributes" in self.__dict__
+ and key in self.__dict__["_dirty_attributes"]
+ ):
value = self.__dict__["_dirty_attributes"][key]
return self.caster.get(key, value)
@@ -91,7 +98,11 @@ def is_dirty(self) -> bool:
return bool(self.get_dirty())
def get_dirty(self) -> dict:
- return {key: value for key, value in self.get_attributes().items() if not self.original_is_equivalent(key)}
+ return {
+ key: value
+ for key, value in self.get_attributes().items()
+ if not self.original_is_equivalent(key)
+ }
def get_attributes_for_insert(self) -> dict:
return {**self._attributes, **self._dirty_attributes}
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/builder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/builder.py
index 3e700dc9..ba23113c 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/builder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/builder.py
@@ -1,13 +1,14 @@
import inspect
+
+import inflection
from typing import TYPE_CHECKING
from fastapi_startkit.masoniteorm.expressions.expressions import (
- AggregateExpression,
QueryExpression,
SelectExpression,
- SubGroupExpression,
- SubSelectExpression,
UpdateQueryExpression,
+ SubSelectExpression,
+ SubGroupExpression,
)
from fastapi_startkit.masoniteorm.query.EagerLoadMixin import EagerLoadMixin
from fastapi_startkit.masoniteorm.query.support import SupportMixin
@@ -26,9 +27,7 @@ def __init__(self, connection: "Connection", grammar, processor):
self._columns = []
self._table = ""
self._limit = False
- self._offset = False
self._wheres = []
- self._aggregates = []
self._sql = ""
self._bindings = ()
@@ -53,17 +52,6 @@ def with_(self, *eagers) -> "QueryBuilder":
def get_table_name(self) -> str:
return self._table
- def when(self, condition, callback) -> "QueryBuilder":
- """Conditionally apply a query constraint.
-
- If *condition* is truthy the *callback* is called with this builder
- and its return value (also a QueryBuilder) is used to continue the
- chain. If falsy the builder is returned unchanged.
- """
- if condition:
- return callback(self)
- return self
-
def where_in(self, column: str, values) -> "QueryBuilder":
if hasattr(values, "_items"):
values = values._items
@@ -85,44 +73,8 @@ def limit(self, limit: int) -> "QueryBuilder":
self._limit = limit
return self
- def offset(self, offset: int) -> "QueryBuilder":
- self._offset = offset
- return self
-
- async def count(self) -> int:
- self._aggregates = [AggregateExpression("COUNT", "*")]
- self._columns = []
- results = await self.connection.select(self.to_qmark(), self.get_bindings())
- self._aggregates = []
- if results:
- row = results[0]
- return list(row.values())[0]
- return 0
-
- async def paginate(self, page: int = 1, per_page: int = 15):
- from fastapi_startkit.masoniteorm.pagination.LengthAwarePaginator import LengthAwarePaginator
-
- # Save state before count modifies it
- saved_columns = self._columns[:]
- saved_limit = self._limit
- saved_offset = self._offset
- saved_bindings = self._bindings
-
- total = await self.count()
-
- # Restore state for the actual data query
- self._columns = saved_columns
- self._limit = saved_limit
- self._offset = saved_offset
- self._bindings = saved_bindings
-
- offset = (page - 1) * per_page
- results = await self.limit(per_page).offset(offset).get()
-
- return LengthAwarePaginator(results, per_page, page, total)
-
async def find(self, primary_key: str | int, columns=None):
- return await self.where(self._model.__primary_key__, primary_key).first(columns)
+ return await self.where(self._model.primary_key, primary_key).first(columns)
async def first(self, columns=None):
if not columns:
@@ -142,7 +94,11 @@ async def get_models(self, columns=None):
models = await self.connection.select(self.to_qmark(), self.get_bindings())
collection = self._model.hydrate(models)
- if self._eager_relation.eagers or self._eager_relation.nested_eagers or self._eager_relation.callback_eagers:
+ if (
+ self._eager_relation.eagers
+ or self._eager_relation.nested_eagers
+ or self._eager_relation.callback_eagers
+ ):
await self._load_eagers(collection, self._model)
return collection
@@ -160,9 +116,7 @@ def get_grammar(self):
columns=self._columns,
table=self._table,
limit=self._limit,
- offset=self._offset,
wheres=self._wheres,
- aggregates=self._aggregates,
)
def to_qmark(self) -> str:
@@ -229,18 +183,16 @@ def where(self, column, *args):
if inspect.isfunction(column):
builder = column(self.new())
- self._wheres += ((QueryExpression(None, operator, SubGroupExpression(builder))),)
+ self._wheres += (
+ (QueryExpression(None, operator, SubGroupExpression(builder))),
+ )
elif isinstance(column, dict):
for key, value in column.items():
self._wheres += ((QueryExpression(key, "=", value, "value")),)
elif isinstance(value, QueryBuilder):
- self._wheres += ((QueryExpression(column, operator, SubSelectExpression(value))),)
+ self._wheres += (
+ (QueryExpression(column, operator, SubSelectExpression(value))),
+ )
else:
self._wheres += ((QueryExpression(column, operator, value, "value")),)
return self
-
- def or_where(self, column, *args):
- """Specifies an OR where expression."""
- operator, value = self._extract_operator_value(*args)
- self._wheres += ((QueryExpression(column, operator, value, "value", keyword="or")),)
- return self
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/caster.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/caster.py
index 91c53b88..edb1a264 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/caster.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/caster.py
@@ -1,13 +1,11 @@
-import datetime
import json
-from dataclasses import dataclass, field
+import pendulum
+import datetime
from decimal import Decimal
from enum import Enum
-from typing import TYPE_CHECKING, Any, Optional, get_type_hints
-
-import pendulum
+from dataclasses import dataclass, field
+from typing import TYPE_CHECKING, Any, get_type_hints, Optional
from pydantic.fields import FieldInfo
-
from fastapi_startkit.carbon import Carbon
if TYPE_CHECKING:
@@ -135,7 +133,10 @@ def __init__(self, model: "Model", casts: dict | None = None):
@classmethod
def build_casts(cls, model):
model = model if isinstance(model, type) else model.__class__
- from fastapi_startkit.masoniteorm.relationships.BaseRelationship import BaseRelationship
+ from .registry import Registry
+ from fastapi_startkit.masoniteorm.relationships.BaseRelationship import (
+ BaseRelationship,
+ )
try:
annotations = get_type_hints(model)
@@ -147,11 +148,15 @@ def build_casts(cls, model):
annotations[name] = hint
annotations = {
- k: v for k, v in annotations.items() if not isinstance(getattr(model, k, None), BaseRelationship)
+ k: v
+ for k, v in annotations.items()
+ if not isinstance(getattr(model, k, None), BaseRelationship)
}
# Ignore the builder
- annotations = {k: v for k, v in annotations.items() if k not in cls.IGNORE_CASTS}
+ annotations = {
+ k: v for k, v in annotations.items() if k not in cls.IGNORE_CASTS
+ }
from .fields import FieldDescriptor
# 1. Collect all potential fields (annotations + descriptors)
@@ -167,7 +172,11 @@ def build_casts(cls, model):
# 2. Get Type Hint and FieldInfo
typ = annotations.get(field_name) or "str"
descriptor = descriptors.get(field_name, None)
- field_info = descriptor.field_info if isinstance(descriptor, FieldDescriptor) else None
+ field_info = (
+ descriptor.field_info
+ if isinstance(descriptor, FieldDescriptor)
+ else None
+ )
caster = Caster.normalize_type(typ)
if caster in Caster.cast_class_map:
@@ -189,7 +198,12 @@ def normalize_type(t):
return "bool"
if t is dict or t is list:
return "json"
- if t is pendulum.DateTime or t is datetime.datetime or t is datetime.date or t is Carbon:
+ if (
+ t is pendulum.DateTime
+ or t is datetime.datetime
+ or t is datetime.date
+ or t is Carbon
+ ):
return "date"
if isinstance(t, type):
if issubclass(t, Enum) or hasattr(t, "get") or hasattr(t, "set"):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/fields.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/fields.py
index 13c30d09..35653383 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/fields.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/fields.py
@@ -1,9 +1,12 @@
-from typing import Any
-
-from pydantic import Field as BaseField
+import pendulum
from pydantic.fields import FieldInfo
+from pydantic import Field as BaseField
+from typing import Any
-from fastapi_startkit.masoniteorm.models.observer import CreatedAtObserver, UpdatedAtObserver
+from fastapi_startkit.masoniteorm.models.observer import (
+ CreatedAtObserver,
+ UpdatedAtObserver,
+)
class FieldDescriptor:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/model.py
index 3b0be5ef..06a065d5 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/model.py
@@ -1,17 +1,16 @@
from __future__ import annotations
+import inflection
from typing import TYPE_CHECKING
-import inflection
-
from fastapi_startkit.carbon import Carbon
from fastapi_startkit.masoniteorm.collection import Collection
-from fastapi_startkit.masoniteorm.connections.manager import DatabaseManager
-from fastapi_startkit.masoniteorm.models.attribute import Attribute
from fastapi_startkit.masoniteorm.models.fields import CreatedAtField, UpdatedAtField
from fastapi_startkit.masoniteorm.models.registry import Registry
-from fastapi_startkit.masoniteorm.models.relationship import Relationship
from fastapi_startkit.masoniteorm.observers import ObservesEvents
+from fastapi_startkit.masoniteorm.connections.manager import DatabaseManager
+from fastapi_startkit.masoniteorm.models.attribute import Attribute
+from fastapi_startkit.masoniteorm.models.relationship import Relationship
if TYPE_CHECKING:
from fastapi_startkit.orm.models.builder import QueryBuilder
@@ -35,7 +34,9 @@ def __init_subclass__(cls, **kwargs):
fillable = []
for name, _typ in cls.__annotations__.items():
attr = getattr(cls, name, None)
- from fastapi_startkit.masoniteorm.relationships.BaseRelationship import BaseRelationship
+ from fastapi_startkit.masoniteorm.relationships.BaseRelationship import (
+ BaseRelationship,
+ )
if isinstance(attr, BaseRelationship):
continue
@@ -152,7 +153,9 @@ def query(cls):
return cls().new_query()
@classmethod
- async def first_or_create(cls, search: dict, attributes: dict | None = None) -> "Model":
+ async def first_or_create(
+ cls, search: dict, attributes: dict | None = None
+ ) -> "Model":
return await cls.query().first_or_create(search, attributes)
@classmethod
@@ -200,8 +203,6 @@ async def perform_insert(self, query) -> bool:
# Store the auto-generated primary key so subsequent saves do an UPDATE
if inserted_id is not None:
- if isinstance(inserted_id, dict):
- inserted_id = inserted_id.get(self.__primary_key__)
self._dirty_attributes[self.__primary_key__] = inserted_id
self._exists = True
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/observer.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/observer.py
index f7bd5e52..0ce5a7ca 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/observer.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/observer.py
@@ -1,5 +1,4 @@
import pendulum
-
from fastapi_startkit.masoniteorm.expressions.expressions import UpdateQueryExpression
@@ -26,4 +25,6 @@ def creating(self, model):
def updating(self, model):
if model.__timestamps__:
- model.builder._updates += (UpdateQueryExpression({self.field_name: pendulum.now(self.tz)}),)
+ model.builder._updates += (
+ UpdateQueryExpression({self.field_name: pendulum.now(self.tz)}),
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/registry.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/registry.py
index a5827762..81dfca0d 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/registry.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/registry.py
@@ -6,7 +6,9 @@ class Registry:
@classmethod
def register(cls, model: type):
name = model.__name__
- morph_name = model.get_morph_class() if hasattr(model, "get_morph_class") else name
+ morph_name = (
+ model.get_morph_class() if hasattr(model, "get_morph_class") else name
+ )
cls._models[name] = model
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/relationship.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/relationship.py
index fca0e877..14dcceb7 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/relationship.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/models/relationship.py
@@ -1,3 +1,6 @@
+from fastapi_startkit.masoniteorm.query.EagerRelation import EagerRelations
+
+
class Relationship:
__relationship_hidden__ = {}
__with__ = ()
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/observers/ObservesEvents.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/observers/ObservesEvents.py
index 11bf88fc..401c14a7 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/observers/ObservesEvents.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/observers/ObservesEvents.py
@@ -1,6 +1,6 @@
class ObservesEvents:
def observe_events(self, model, event):
- if model.__has_events__:
+ if model.__has_events__ == True:
for klass in type(model).__mro__:
for observer in model.__observers__.get(klass, []):
try:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/providers/DatabaseProvider.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/providers/DatabaseProvider.py
index 1327b637..aa9c0c25 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/providers/DatabaseProvider.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/providers/DatabaseProvider.py
@@ -33,7 +33,13 @@ def register(self):
Migration.db_manager = db
def boot(self) -> None:
- self.publishes({Path(__file__).resolve().parent.parent.joinpath("config/database.py"): "config/database.py"})
+ self.publishes(
+ {
+ Path(__file__)
+ .resolve()
+ .parent.parent.joinpath("config/database.py"): "config/database.py"
+ }
+ )
self.commands(
[
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/EagerLoadMixin.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/EagerLoadMixin.py
index fde3a887..e0721662 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/EagerLoadMixin.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/EagerLoadMixin.py
@@ -52,7 +52,9 @@ async def _load_eagers(self, models, model):
relation_key=eager,
)
- async def _register_relationships_to_model(self, related, related_result, models, relation_key):
+ async def _register_relationships_to_model(
+ self, related, related_result, models, relation_key
+ ):
if related_result and isinstance(models, Collection):
map_related = self._map_related(related_result, related)
for model in models:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/BaseGrammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/BaseGrammar.py
index 48f44b3d..987241c0 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/BaseGrammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/BaseGrammar.py
@@ -176,7 +176,9 @@ def _compile_bulk_create(self, qmark=False):
return self
def columnize_bulk_columns(self, columns=[]):
- return ", ".join(self.column_string().format(column=x, separator="") for x in columns).rstrip(",")
+ return ", ".join(
+ self.column_string().format(column=x, separator="") for x in columns
+ ).rstrip(",")
def columnize_bulk_values(self, columns=[], qmark=False):
sql = ""
@@ -186,14 +188,24 @@ def columnize_bulk_values(self, columns=[], qmark=False):
for y in x:
if qmark:
self.add_binding(y)
- inner += "?, " if qmark else self.value_string().format(value=y, separator=", ")
+ inner += (
+ "?, "
+ if qmark
+ else self.value_string().format(value=y, separator=", ")
+ )
inner = inner.rstrip(", ")
sql += self.process_value_string().format(value=inner, separator=", ")
else:
if qmark:
self.add_binding(x)
- sql += "?, " if qmark else self.process_value_string().format(value="?" if qmark else x, separator=", ")
+ sql += (
+ "?, "
+ if qmark
+ else self.process_value_string().format(
+ value="?" if qmark else x, separator=", "
+ )
+ )
return sql.rstrip(", ")
@@ -266,13 +278,13 @@ def process_joins(self, qmark=False):
self.add_binding(clause.value)
else:
value = self._compile_value(clause.value)
- on_string += (
- f"{keyword} {self._table_column_string(clause.column)} {clause.equality} {value} "
- )
+ on_string += f"{keyword} {self._table_column_string(clause.column)} {clause.equality} {value} "
sql += self.join_string().format(
foreign_table=self.process_table(join.table),
- alias=(f" AS {self.process_table(join.alias)}" if join.alias else ""),
+ alias=(
+ f" AS {self.process_table(join.alias)}" if join.alias else ""
+ ),
on=on_string,
keyword=self.join_keywords[join.clause],
)
@@ -312,7 +324,11 @@ def _compile_key_value_equals(self, qmark=False):
else:
sql += sql_string.format(
column=self._table_column_string(key),
- value=(self.value_string().format(value=value, separator="") if not qmark else "?"),
+ value=(
+ self.value_string().format(value=value, separator="")
+ if not qmark
+ else "?"
+ ),
separator=", ",
)
@@ -321,7 +337,11 @@ def _compile_key_value_equals(self, qmark=False):
else:
sql += sql_string.format(
column=self._table_column_string(column),
- value=(self.value_string().format(value=value, separator=", ") if not qmark else "?"),
+ value=(
+ self.value_string().format(value=value, separator=", ")
+ if not qmark
+ else "?"
+ ),
separator=", ",
)
if qmark:
@@ -349,7 +369,9 @@ def process_aggregates(self):
sql += (
aggregate_string.format(
aggregate_function=aggregate_function,
- column=("*" if column == "*" else self._table_column_string(column)),
+ column=(
+ "*" if column == "*" else self._table_column_string(column)
+ ),
alias=self.process_alias(aggregates.alias or column),
)
+ ", "
@@ -370,7 +392,9 @@ def process_order_by(self):
if order_bys.raw:
order_crit += order_bys.column
if not isinstance(order_bys.bindings, (list, tuple)):
- raise ValueError(f"Bindings must be tuple or list. Received {type(order_bys.bindings)}")
+ raise ValueError(
+ f"Bindings must be tuple or list. Received {type(order_bys.bindings)}"
+ )
if order_bys.bindings:
self.add_binding(*order_bys.bindings)
@@ -384,8 +408,12 @@ def process_order_by(self):
if "." in column:
column_string = self._table_column_string(column)
else:
- column_string = self.column_string().format(column=column, separator="")
- order_crit += self.order_by_format().format(column=column_string, direction=direction.upper())
+ column_string = self.column_string().format(
+ column=column, separator=""
+ )
+ order_crit += self.order_by_format().format(
+ column=column_string, direction=direction.upper()
+ )
sql += self.order_by_string().format(order_columns=order_crit)
return sql
@@ -555,10 +583,14 @@ def process_wheres(self, query=None, qmark=False, strip_first_where=False):
"""If we have a raw query we just want to use the query supplied
and don't need to compile anything.
"""
- sql += self.raw_query_string().format(keyword=keyword, query=where.column)
+ sql += self.raw_query_string().format(
+ keyword=keyword, query=where.column
+ )
if not isinstance(where.bindings, (list, tuple)):
- raise ValueError(f"Bindings must be tuple or list. Received {type(where.bindings)}")
+ raise ValueError(
+ f"Bindings must be tuple or list. Received {type(where.bindings)}"
+ )
if where.bindings:
self.add_binding(*where.bindings)
@@ -603,7 +635,9 @@ def process_wheres(self, query=None, qmark=False, strip_first_where=False):
keyword=keyword,
)
elif value_type == "value_equals":
- sql_string = self.value_equal_string().format(value1=where.column, value2=where.value, keyword=keyword)
+ sql_string = self.value_equal_string().format(
+ value1=where.column, value2=where.value, keyword=keyword
+ )
elif value_type == "NULL":
sql_string = self.where_null_string()
elif value_type == "DATE":
@@ -631,7 +665,11 @@ def process_wheres(self, query=None, qmark=False, strip_first_where=False):
grammar = value.builder.get_grammar()
query_value = (
self.subquery_string()
- .format(query=grammar.process_wheres(qmark=qmark, strip_first_where=True))
+ .format(
+ query=grammar.process_wheres(
+ qmark=qmark, strip_first_where=True
+ )
+ )
.replace("( ", "(")
)
if grammar._bindings:
@@ -652,7 +690,9 @@ def process_wheres(self, query=None, qmark=False, strip_first_where=False):
query_value += "?, "
self.add_binding(val)
else:
- query_value += self.value_string().format(value=val, separator=",")
+ query_value += self.value_string().format(
+ value=val, separator=","
+ )
query_value = query_value.rstrip(",").rstrip(", ") + ")"
elif value is True and value_type != "NOT NULL":
sql_string = self.get_true_column_string()
@@ -857,7 +897,9 @@ def process_column(self, column, separator=""):
table = None
if column and "." in column:
table, column = column.split(".")
- return self.column_string().format(column=column, separator=separator, table=table or self.table)
+ return self.column_string().format(
+ column=column, separator=separator, table=table or self.table
+ )
def _table_column_string(self, column, alias=None, separator=""):
"""Compiles a column into the column syntax.
@@ -926,7 +968,9 @@ def drop_table_if_exists(self, table):
Returns:
self
"""
- self._sql = self.drop_table_if_exists_string().format(table=self.process_column(table))
+ self._sql = self.drop_table_if_exists_string().format(
+ table=self.process_column(table)
+ )
return self
def rename_table(self, current_table_name, new_table_name):
@@ -954,7 +998,9 @@ def truncate_table(self, table, foreign_keys=False):
Returns:
self
"""
- raise NotImplementedError(f"'{self.__class__.__name__}' does not support truncating")
+ raise NotImplementedError(
+ f"'{self.__class__.__name__}' does not support truncating"
+ )
def where_regexp_string(self):
return "{keyword} {column} REGEXP {value}"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/MySQLGrammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/MySQLGrammar.py
index 4ee2c167..e8eb6a53 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/MySQLGrammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/MySQLGrammar.py
@@ -120,10 +120,14 @@ def process_table(self, table):
if not table:
return ""
if isinstance(table, str):
- return ".".join(self.table_string().format(table=t) for t in table.split("."))
+ return ".".join(
+ self.table_string().format(table=t) for t in table.split(".")
+ )
if table.raw:
return table.name
- return ".".join(self.table_string().format(table=t) for t in table.name.split("."))
+ return ".".join(
+ self.table_string().format(table=t) for t in table.name.split(".")
+ )
def subquery_alias_string(self):
return "AS {alias}"
@@ -147,9 +151,7 @@ def column_exists_string(self):
return "SHOW COLUMNS FROM {table} LIKE {value}"
def table_exists_string(self):
- return (
- "SELECT * from information_schema.tables where table_name='{clean_table}' AND table_schema = '{database}'"
- )
+ return "SELECT * from information_schema.tables where table_name='{clean_table}' AND table_schema = '{database}'"
def create_column_length(self, column_type):
return "({length})"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/PostgresGrammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/PostgresGrammar.py
index cba95a06..4459c6dd 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/PostgresGrammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/PostgresGrammar.py
@@ -113,7 +113,9 @@ def column_exists_string(self):
return "SELECT column_name FROM information_schema.columns WHERE table_name='{clean_table}' and column_name={value}"
def table_exists_string(self):
- return "SELECT * from information_schema.tables where table_name='{clean_table}'"
+ return (
+ "SELECT * from information_schema.tables where table_name='{clean_table}'"
+ )
def create_column_length(self, column_type):
if column_type in self.types_without_lengths:
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/SQLiteGrammar.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/SQLiteGrammar.py
index 191c1591..2853ea3a 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/SQLiteGrammar.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/grammars/SQLiteGrammar.py
@@ -107,7 +107,9 @@ def column_exists_string(self):
return "SELECT column_name FROM information_schema.columns WHERE table_name='{clean_table}' and column_name={value}"
def table_exists_string(self):
- return "SELECT name FROM sqlite_master WHERE type='table' AND name='{clean_table}'"
+ return (
+ "SELECT name FROM sqlite_master WHERE type='table' AND name='{clean_table}'"
+ )
def to_sql(self):
"""Cleans up the SQL string and returns the SQL
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/support.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/support.py
index e6829ece..04f884a6 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/support.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/query/support.py
@@ -29,6 +29,9 @@ def _extract_operator_value(*args):
value = args[0]
if operator not in operators:
- raise ValueError("Invalid comparison operator. The operator can be %s" % ", ".join(operators))
+ raise ValueError(
+ "Invalid comparison operator. The operator can be %s"
+ % ", ".join(operators)
+ )
return operator, value
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BaseRelationship.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BaseRelationship.py
index 765642af..17848bb8 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BaseRelationship.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BaseRelationship.py
@@ -57,12 +57,16 @@ def apply_query(self, foreign, owner):
dict -- A dictionary of data which will be hydrated.
"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'apply_query' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'apply_query' method"
+ )
def query_where_exists(self, builder, callback, method="where_exists"):
"""Adds a criteria clause to the query filter for existing related records"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'query_where_exists' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'query_where_exists' method"
+ )
def joins(self, builder, clause=None):
"""Helper method for adding join clauses to a relationship"""
@@ -79,41 +83,59 @@ def joins(self, builder, clause=None):
def get_with_count_query(self, builder, callback):
"""Adds a clause to the query to get the record count of the relationship"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'get_with_count_query' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'get_with_count_query' method"
+ )
def attach(self, current_model, related_record):
"""Link a related model to the current model"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'attach' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'attach' method"
+ )
def get_related(self, query, relation, eagers=None, callback=None):
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'get_related' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'get_related' method"
+ )
def relate(self, related_record):
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'relate' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'relate' method"
+ )
def detach(self, current_model, related_record):
"""Unlink a related model from the current model"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'detach' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'detach' method"
+ )
def attach_related(self, current_model, related_record):
"""Unlink a related model from the current model"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'attach_related' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'attach_related' method"
+ )
def detach_related(self, current_model, related_record):
"""Unlink a related model from the current model"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'detach_related' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'detach_related' method"
+ )
def query_has(self, current_query_builder, method="where_exists"):
"""Adds a clause to the query to check if a relation exists"""
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'query_has' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'query_has' method"
+ )
def map_related(self, related_result):
klass = self.__class__.__name__
- raise NotImplementedError(f"{klass} relationship does not implement the 'map_related' method")
+ raise NotImplementedError(
+ f"{klass} relationship does not implement the 'map_related' method"
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsTo.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsTo.py
index 159c3040..d16d8793 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsTo.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsTo.py
@@ -1,7 +1,8 @@
-from fastapi_startkit.masoniteorm.models import registry
+from typing import Callable
from ..collection import Collection
from . import BaseRelationship
+from fastapi_startkit.masoniteorm.models import registry
class BelongsTo(BaseRelationship):
@@ -29,7 +30,9 @@ def apply_query(self, foreign, owner):
Returns:
dict -- A dictionary of data which will be hydrated.
"""
- return foreign.where(self.foreign_key, owner.__attributes__[self.local_key]).first()
+ return foreign.where(
+ self.foreign_key, owner.__attributes__[self.local_key]
+ ).first()
def query_has(self, current_query_builder, method="where_exists"):
related_builder = self.get_builder()
@@ -106,5 +109,7 @@ def relate(self, related_record):
return (
self.get_builder()
.where(self.foreign_key, related_record.__attributes__[self.local_key])
- ._set_creates_related({self.foreign_key: related_record.__attributes__[self.local_key]})
+ ._set_creates_related(
+ {self.foreign_key: related_record.__attributes__[self.local_key]}
+ )
)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsToMany.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsToMany.py
index c08e874b..eb4dcc59 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsToMany.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/BelongsToMany.py
@@ -1,11 +1,10 @@
import pendulum
from inflection import singularize
-from fastapi_startkit.masoniteorm.models import registry
-
from ..collection import Collection
from ..models.pivot import Pivot
from .BaseRelationship import BaseRelationship
+from fastapi_startkit.masoniteorm.models import registry
class BelongsToMany(BaseRelationship):
@@ -101,7 +100,9 @@ async def apply_query(self, query, owner):
)
if hasattr(owner, self.local_owner_key):
- result.where(f"{table1}.{self.local_owner_key}", getattr(owner, self.local_owner_key))
+ result.where(
+ f"{table1}.{self.local_owner_key}", getattr(owner, self.local_owner_key)
+ )
if self.with_fields:
for field in self.with_fields:
@@ -236,10 +237,14 @@ async def make_query(self, query, relation, eagers=None, callback=None):
Collection(relation._get_value(self.local_owner_key)).unique(),
).get()
else:
- return await result.where(self.local_owner_key, getattr(relation, self.local_owner_key)).get()
+ return await result.where(
+ self.local_owner_key, getattr(relation, self.local_owner_key)
+ ).get()
async def get_related(self, query, relation, eagers=None, callback=None):
- final_result = await self.make_query(query, relation, eagers=eagers, callback=callback)
+ final_result = await self.make_query(
+ query, relation, eagers=eagers, callback=callback
+ )
builder = self.make_builder(eagers)
for model in final_result:
@@ -330,7 +335,9 @@ def relate(self, related_record):
)
if hasattr(owner, self.local_owner_key):
- result.where(f"{table1}.{self.local_owner_key}", getattr(owner, self.local_owner_key))
+ result.where(
+ f"{table1}.{self.local_owner_key}", getattr(owner, self.local_owner_key)
+ )
if self.with_fields:
for field in self.with_fields:
@@ -342,7 +349,13 @@ def map_related(self, related_result):
return related_result
def register_related(self, key, model, collection):
- model.add_relation({key: collection.where(f"{self._table}_id", getattr(model, self.local_owner_key))})
+ model.add_relation(
+ {
+ key: collection.where(
+ f"{self._table}_id", getattr(model, self.local_owner_key)
+ )
+ }
+ )
def joins(self, builder, clause=None):
if not self._table:
@@ -424,7 +437,9 @@ def query_where_exists(self, builder, callback, method="where_exists"):
f"{pivot_table}.{self.local_key}",
f"{builder.get_table_name()}.{self.local_owner_key}",
)
- .where_in(self.other_owner_key, callback(query.select(self.other_owner_key)))
+ .where_in(
+ self.other_owner_key, callback(query.select(self.other_owner_key))
+ )
)
def query_has(self, builder, method="where_exists"):
@@ -488,7 +503,9 @@ def attach(self, current_model, related_record):
self.foreign_key: getattr(related_record, self.other_owner_key),
}
- self._table = self._table or self.get_pivot_table_name(current_model, related_record)
+ self._table = self._table or self.get_pivot_table_name(
+ current_model, related_record
+ )
if self.with_timestamps:
data.update(
@@ -498,7 +515,12 @@ def attach(self, current_model, related_record):
}
)
- return Pivot.on(current_model.get_builder().connection).table(self._table).without_global_scopes().create(data)
+ return (
+ Pivot.on(current_model.get_builder().connection)
+ .table(self._table)
+ .without_global_scopes()
+ .create(data)
+ )
def detach(self, current_model, related_record):
data = {
@@ -506,7 +528,9 @@ def detach(self, current_model, related_record):
self.foreign_key: getattr(related_record, self.other_owner_key),
}
- self._table = self._table or self.get_pivot_table_name(current_model, related_record)
+ self._table = self._table or self.get_pivot_table_name(
+ current_model, related_record
+ )
return (
Pivot.on(current_model.get_builder().connection)
@@ -522,7 +546,9 @@ def attach_related(self, current_model, related_record):
self.foreign_key: getattr(related_record, self.other_owner_key),
}
- self._table = self._table or self.get_pivot_table_name(current_model, related_record)
+ self._table = self._table or self.get_pivot_table_name(
+ current_model, related_record
+ )
if self.with_timestamps:
data.update(
@@ -545,7 +571,9 @@ def detach_related(self, current_model, related_record):
self.foreign_key: getattr(related_record, self.other_owner_key),
}
- self._table = self._table or self.get_pivot_table_name(current_model, related_record)
+ self._table = self._table or self.get_pivot_table_name(
+ current_model, related_record
+ )
if self.with_timestamps:
data.update(
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasMany.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasMany.py
index 03f45f28..61febe71 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasMany.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasMany.py
@@ -1,5 +1,5 @@
-from ..collection import Collection
from .BaseRelationship import BaseRelationship
+from ..collection import Collection
class HasMany(BaseRelationship):
@@ -15,7 +15,9 @@ def apply_query(self, foreign, owner):
Returns:
dict -- A dictionary of data which will be hydrated.
"""
- result = foreign.where(self.foreign_key, owner.__attributes__[self.local_key]).get()
+ result = foreign.where(
+ self.foreign_key, owner.__attributes__[self.local_key]
+ ).get()
return result
@@ -26,7 +28,9 @@ def set_keys(self, owner, attribute):
return self
def register_related(self, key, model, collection):
- model.add_relation({key: collection.get(getattr(model, self.local_key)) or Collection()})
+ model.add_relation(
+ {key: collection.get(getattr(model, self.local_key)) or Collection()}
+ )
def map_related(self, related_result):
return related_result.group_by(self.foreign_key)
@@ -35,7 +39,9 @@ async def attach(self, current_model, related_record):
local_key_value = getattr(current_model, self.local_key)
if not related_record.is_created():
related_record.fill({self.foreign_key: local_key_value})
- return await related_record.create(related_record.all_attributes(), cast=True)
+ return await related_record.create(
+ related_record.all_attributes(), cast=True
+ )
return await related_record.update({self.foreign_key: local_key_value})
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasManyThrough.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasManyThrough.py
index 3795d727..501da892 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasManyThrough.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasManyThrough.py
@@ -1,5 +1,4 @@
from fastapi_startkit.masoniteorm.models import registry
-
from ..collection import Collection
from .BaseRelationship import BaseRelationship
@@ -62,7 +61,9 @@ def __get__(self, instance, owner):
if self.attribute in instance._relationships:
return instance._relationships[self.attribute]
- return self.apply_related_query(self.distant_builder, self.intermediary_builder, instance)
+ return self.apply_related_query(
+ self.distant_builder, self.intermediary_builder, instance
+ )
def apply_related_query(self, distant_builder, intermediary_builder, owner):
"""
@@ -83,7 +84,9 @@ def apply_related_query(self, distant_builder, intermediary_builder, owner):
intermediate_table = intermediary_builder.get_table_name()
return (
- self.distant_builder.select(f"{distant_table}.*, {intermediate_table}.{self.local_key}")
+ self.distant_builder.select(
+ f"{distant_table}.*, {intermediate_table}.{self.local_key}"
+ )
.join(
f"{intermediate_table}",
f"{intermediate_table}.{self.foreign_key}",
@@ -154,7 +157,9 @@ async def get_related(self, current_builder, relation, eagers=None, callback=Non
callback(current_builder)
(
- self.distant_builder.select(f"{distant_table}.*, {intermediate_table}.{self.local_key}").join(
+ self.distant_builder.select(
+ f"{distant_table}.*, {intermediate_table}.{self.local_key}"
+ ).join(
f"{intermediate_table}",
f"{intermediate_table}.{self.foreign_key}",
"=",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOne.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOne.py
index 74829d3b..22297820 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOne.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOne.py
@@ -1,7 +1,8 @@
-from fastapi_startkit.masoniteorm.models import registry
+import inflection
from ..collection import Collection
from .BaseRelationship import BaseRelationship
+from fastapi_startkit.masoniteorm.models import registry
class HasOne(BaseRelationship):
@@ -20,7 +21,9 @@ def set_keys(self, owner, attribute):
return self
def apply_query(self, foreign, owner):
- return foreign.where(self.foreign_key, owner.__attributes__[self.local_key]).first()
+ return foreign.where(
+ self.foreign_key, owner.__attributes__[self.local_key]
+ ).first()
async def get_related(self, query, relation, eagers=(), callback=None):
builder = self.get_builder().with_(eagers)
@@ -55,7 +58,9 @@ def query_has(self, current_query_builder, method="where_exists"):
return related_builder
def register_related(self, key, model, collection):
- related = collection.where(self.foreign_key, getattr(model, self.local_key)).first()
+ related = collection.where(
+ self.foreign_key, getattr(model, self.local_key)
+ ).first()
model.add_relation({key: related or None})
@@ -75,7 +80,9 @@ async def attach(self, current_model, related_record):
local_key_value = getattr(current_model, self.local_key)
if not related_record.is_created():
related_record.fill({self.foreign_key: local_key_value})
- return await related_record.create(related_record.all_attributes(), cast=True)
+ return await related_record.create(
+ related_record.all_attributes(), cast=True
+ )
return await related_record.update({self.foreign_key: local_key_value})
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOneThrough.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOneThrough.py
index caf89ca8..a14484de 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOneThrough.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/HasOneThrough.py
@@ -1,7 +1,6 @@
-from fastapi_startkit.masoniteorm.models import registry
-
from ..collection import Collection
from .BaseRelationship import BaseRelationship
+from fastapi_startkit.masoniteorm.models import registry
class HasOneThrough(BaseRelationship):
@@ -61,7 +60,9 @@ def __get__(self, instance, owner):
if self.attribute in instance._relationships:
return instance._relationships[self.attribute]
- return self.apply_relation_query(self.distant_builder, self.intermediary_builder, instance)
+ return self.apply_relation_query(
+ self.distant_builder, self.intermediary_builder, instance
+ )
def apply_relation_query(self, distant_builder, intermediary_builder, owner):
"""
@@ -83,7 +84,9 @@ def apply_relation_query(self, distant_builder, intermediary_builder, owner):
int_table = intermediary_builder.get_table_name()
return (
- distant_builder.select(f"{dist_table}.*, {int_table}.{self.local_owner_key} as {self.local_key}")
+ distant_builder.select(
+ f"{dist_table}.*, {int_table}.{self.local_owner_key} as {self.local_key}"
+ )
.join(
f"{int_table}",
f"{int_table}.{self.foreign_key}",
@@ -157,7 +160,9 @@ async def get_related(self, current_builder, relation, eagers=None, callback=Non
callback(current_builder)
(
- self.distant_builder.select(f"{dist_table}.*, {int_table}.{self.local_owner_key} as {self.local_key}").join(
+ self.distant_builder.select(
+ f"{dist_table}.*, {int_table}.{self.local_owner_key} as {self.local_key}"
+ ).join(
f"{int_table}",
f"{int_table}.{self.foreign_key}",
"=",
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphMany.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphMany.py
index 9ab18105..f7803fde 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphMany.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphMany.py
@@ -90,7 +90,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
record_type,
).where_in(
self.morph_id,
- relation.pluck(relation.first().get_primary_key(), keep_nulls=False).unique(),
+ relation.pluck(
+ relation.first().get_primary_key(), keep_nulls=False
+ ).unique(),
)
).get()
return (
@@ -100,7 +102,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
)
.where_in(
self.morph_id,
- relation.pluck(relation.first().get_primary_key(), keep_nulls=False).unique(),
+ relation.pluck(
+ relation.first().get_primary_key(), keep_nulls=False
+ ).unique(),
)
.get()
)
@@ -122,7 +126,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
def register_related(self, key, model, collection):
record_type = self.get_record_key_lookup(model)
- related = collection.where(self.morph_key, record_type).where(self.morph_id, model.get_primary_key_value())
+ related = collection.where(self.morph_key, record_type).where(
+ self.morph_id, model.get_primary_key_value()
+ )
model.add_relation({key: related})
@@ -137,6 +143,8 @@ def get_record_key_lookup(self, relation):
break
if not record_type:
- raise ValueError(f"Could not find the record type key for the {relation} class")
+ raise ValueError(
+ f"Could not find the record type key for the {relation} class"
+ )
return record_type
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphOne.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphOne.py
index 72ce6b48..219a27fb 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphOne.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphOne.py
@@ -91,7 +91,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
record_type,
).where_in(
self.morph_id,
- relation.pluck(relation.first().get_primary_key(), keep_nulls=False).unique(),
+ relation.pluck(
+ relation.first().get_primary_key(), keep_nulls=False
+ ).unique(),
)
).get()
@@ -102,7 +104,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
)
.where_in(
self.morph_id,
- relation.pluck(relation.first().get_primary_key(), keep_nulls=False).unique(),
+ relation.pluck(
+ relation.first().get_primary_key(), keep_nulls=False
+ ).unique(),
)
.get()
)
@@ -125,7 +129,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
def register_related(self, key, model, collection):
record_type = self.get_record_key_lookup(model)
related = (
- collection.where(self.morph_key, record_type).where(self.morph_id, model.get_primary_key_value()).first()
+ collection.where(self.morph_key, record_type)
+ .where(self.morph_id, model.get_primary_key_value())
+ .first()
)
model.add_relation({key: related})
@@ -141,6 +147,8 @@ def get_record_key_lookup(self, relation):
break
if not record_type:
- raise ValueError(f"Could not find the record type key for the {relation} class")
+ raise ValueError(
+ f"Could not find the record type key for the {relation} class"
+ )
return record_type
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphTo.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphTo.py
index ec7b3369..5c94a86e 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphTo.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphTo.py
@@ -1,5 +1,4 @@
from fastapi_startkit.masoniteorm.models import registry
-
from ..collection import Collection
from .BaseRelationship import BaseRelationship
@@ -84,7 +83,9 @@ async def get_related(self, query, relation, eagers=None, callback=None):
relations.merge(
await morphed_model.where_in(
f"{morphed_model.get_table_name()}.{morphed_model.get_primary_key()}",
- Collection(items).pluck(self.morph_id, keep_nulls=False).unique(),
+ Collection(items)
+ .pluck(self.morph_id, keep_nulls=False)
+ .unique(),
).get()
)
return relations
@@ -96,7 +97,9 @@ async def get_related(self, query, relation, eagers=None, callback=None):
def register_related(self, key, model, collection):
morphed_model = self.morph_map().get(getattr(model, self.morph_key))
- related = collection.where(morphed_model.get_primary_key(), getattr(model, self.morph_id)).first()
+ related = collection.where(
+ morphed_model.get_primary_key(), getattr(model, self.morph_id)
+ ).first()
model.add_relation({key: related})
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphToMany.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphToMany.py
index f647f250..afda028b 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphToMany.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/relationships/MorphToMany.py
@@ -83,7 +83,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
relations.merge(
morphed_model.where_in(
f"{morphed_model.get_table_name()}.{morphed_model.get_primary_key()}",
- Collection(items).pluck(self.morph_id, keep_nulls=False).unique(),
+ Collection(items)
+ .pluck(self.morph_id, keep_nulls=False)
+ .unique(),
).get()
)
return relations
@@ -95,7 +97,9 @@ def get_related(self, query, relation, eagers=None, callback=None):
def register_related(self, key, model, collection):
morphed_model = self.morph_map().get(getattr(model, self.morph_key))
- related = collection.where(morphed_model.get_primary_key(), getattr(model, self.morph_id))
+ related = collection.where(
+ morphed_model.get_primary_key(), getattr(model, self.morph_id)
+ )
model.add_relation({key: related})
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Blueprint.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Blueprint.py
index f2176392..36181512 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Blueprint.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Blueprint.py
@@ -37,7 +37,9 @@ def string(self, column, length=255, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "string", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "string", length=length, nullable=nullable
+ )
return self
@@ -54,7 +56,9 @@ def tiny_integer(self, column, length=1, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "tiny_integer", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "tiny_integer", length=length, nullable=nullable
+ )
return self
def small_integer(self, column, length=5, nullable=False):
@@ -70,7 +74,9 @@ def small_integer(self, column, length=5, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "small_integer", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "small_integer", length=length, nullable=nullable
+ )
return self
def medium_integer(self, column, length=7, nullable=False):
@@ -86,7 +92,9 @@ def medium_integer(self, column, length=7, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "medium_integer", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "medium_integer", length=length, nullable=nullable
+ )
return self
def integer(self, column, length=11, nullable=False):
@@ -102,7 +110,9 @@ def integer(self, column, length=11, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "integer", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "integer", length=length, nullable=nullable
+ )
return self
def big_integer(self, column, length=32, nullable=False):
@@ -118,7 +128,9 @@ def big_integer(self, column, length=32, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "big_integer", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "big_integer", length=length, nullable=nullable
+ )
return self
def unsigned_big_integer(self, column, length=32, nullable=False):
@@ -154,7 +166,9 @@ def increments(self, column, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "increments", nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "increments", nullable=nullable
+ )
self.primary(column)
return self
@@ -171,7 +185,9 @@ def tiny_increments(self, column, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "tiny_increments", nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "tiny_increments", nullable=nullable
+ )
self.primary(column)
return self
@@ -199,7 +215,9 @@ def uuid(self, column, nullable=False, length=36):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "uuid", nullable=nullable, length=length)
+ self._last_column = self.table.add_column(
+ column, "uuid", nullable=nullable, length=length
+ )
return self
def big_increments(self, column, nullable=False):
@@ -214,7 +232,9 @@ def big_increments(self, column, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "big_increments", nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "big_increments", nullable=nullable
+ )
self.primary(column)
return self
@@ -271,7 +291,9 @@ def char(self, column, length=1, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "char", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "char", length=length, nullable=nullable
+ )
return self
def date(self, column, nullable=False):
@@ -339,7 +361,9 @@ def timestamp(self, column, nullable=False, now=False):
self
"""
- self._last_column = self.table.add_column(column, "timestamp", nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "timestamp", nullable=nullable
+ )
if now:
self._last_column.use_current()
@@ -437,7 +461,9 @@ def enum(self, column, options=None, nullable=False):
for option in options:
new_options += "'{}',".format(option)
new_options = new_options.rstrip(",")
- self._last_column = self.table.add_column(column, "enum", length="255", values=options, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "enum", length="255", values=options, nullable=nullable
+ )
return self
def text(self, column, length=None, nullable=False):
@@ -453,7 +479,9 @@ def text(self, column, length=None, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "text", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "text", length=length, nullable=nullable
+ )
return self
def tiny_text(self, column, length=None, nullable=False):
@@ -469,7 +497,9 @@ def tiny_text(self, column, length=None, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "tiny_text", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "tiny_text", length=length, nullable=nullable
+ )
return self
def unsigned_decimal(self, column, length=17, precision=6, nullable=False):
@@ -507,7 +537,9 @@ def long_text(self, column, length=None, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "long_text", length=length, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "long_text", length=length, nullable=nullable
+ )
return self
def json(self, column, nullable=False):
@@ -552,7 +584,9 @@ def inet(self, column, length=255, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "inet", length=255, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "inet", length=255, nullable=nullable
+ )
return self
def cidr(self, column, length=255, nullable=False):
@@ -567,7 +601,9 @@ def cidr(self, column, length=255, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "cidr", length=255, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "cidr", length=255, nullable=nullable
+ )
return self
def macaddr(self, column, length=255, nullable=False):
@@ -582,7 +618,9 @@ def macaddr(self, column, length=255, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "macaddr", length=255, nullable=nullable)
+ self._last_column = self.table.add_column(
+ column, "macaddr", length=255, nullable=nullable
+ )
return self
def point(self, column, nullable=False):
@@ -627,7 +665,9 @@ def year(self, column, length=4, default=None, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "year", length=length, nullable=nullable, default=default)
+ self._last_column = self.table.add_column(
+ column, "year", length=length, nullable=nullable, default=default
+ )
return self
def unsigned(self, column=None, length=None, nullable=False):
@@ -647,7 +687,9 @@ def unsigned(self, column=None, length=None, nullable=False):
self._last_column.unsigned()
return self
- self._last_column = self.table.add_column(column, "unsigned", length=length, nullable=nullable).unsigned()
+ self._last_column = self.table.add_column(
+ column, "unsigned", length=length, nullable=nullable
+ ).unsigned()
return self
def unsigned_integer(self, column, nullable=False):
@@ -662,7 +704,9 @@ def unsigned_integer(self, column, nullable=False):
Returns:
self
"""
- self._last_column = self.table.add_column(column, "integer", nullable=nullable).unsigned()
+ self._last_column = self.table.add_column(
+ column, "integer", nullable=nullable
+ ).unsigned()
return self
def morphs(self, column, nullable=False, indexes=True):
@@ -678,7 +722,11 @@ def morphs(self, column, nullable=False, indexes=True):
self
"""
_columns = []
- _columns.append(self.table.add_column("{}_id".format(column), "integer", nullable=nullable).unsigned())
+ _columns.append(
+ self.table.add_column(
+ "{}_id".format(column), "integer", nullable=nullable
+ ).unsigned()
+ )
_columns.append(
self.table.add_column(
"{}_type".format(column),
@@ -708,7 +756,9 @@ def to_sql(self):
else:
if not self._dry:
# get current table schema
- table = self.platform().get_current_schema(self.connection, self.table.name, schema=self.schema)
+ table = self.platform().get_current_schema(
+ self.connection, self.table.name, schema=self.schema
+ )
self.table.from_table = table
return self.platform().compile_alter_sql(self.table)
@@ -823,7 +873,9 @@ def fulltext(self, column=None, name=None):
if not isinstance(column, list):
column = [column]
- self.table.add_constraint(name or f"{'_'.join(column)}_fulltext", "fulltext", column)
+ self.table.add_constraint(
+ name or f"{'_'.join(column)}_fulltext", "fulltext", column
+ )
return self
@@ -859,7 +911,9 @@ def add_foreign(self, columns, name=None):
columns {string} -- The name of the from_column . to_column . table
"""
if len(columns.split(".")) != 3:
- raise Exception("Wrong add_foreign argument, the struncture is from_column.to_column.table")
+ raise Exception(
+ "Wrong add_foreign argument, the struncture is from_column.to_column.table"
+ )
from_column, to_column, table = columns.split(".")
return self.foreign(from_column, name=name).references(to_column).on(table)
@@ -872,7 +926,9 @@ def foreign(self, column, name=None):
Returns:
self
"""
- self._last_foreign = self.table.add_foreign_key(column, name=name or f"{self.table.name}_{column}_foreign")
+ self._last_foreign = self.table.add_foreign_key(
+ column, name=name or f"{self.table.name}_{column}_foreign"
+ )
return self
def foreign_id(self, column):
@@ -908,7 +964,11 @@ def foreign_id_for(self, model, column=None):
"""
clm = column if column else model.get_foreign_key()
- return self.foreign_id(clm) if model.get_primary_key_type() == "int" else self.foreign_uuid(column)
+ return (
+ self.foreign_id(clm)
+ if model.get_primary_key_type() == "int"
+ else self.foreign_uuid(column)
+ )
def references(self, column):
"""Sets the other column on the foreign table that the local column will use to reference.
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Table.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Table.py
index 419eeb62..d010c92a 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Table.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/Table.py
@@ -47,7 +47,9 @@ def add_column(
return column
def add_constraint(self, name, constraint_type, columns=None):
- self.added_constraints.update({name: Constraint(name, constraint_type, columns=columns or [])})
+ self.added_constraints.update(
+ {name: Constraint(name, constraint_type, columns=columns or [])}
+ )
def add_foreign_key(self, column, table=None, foreign_column=None, name=None):
foreign_key = ForeignKeyConstraint(
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MSSQLPlatform.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MSSQLPlatform.py
index 87d822d2..a33eaebc 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MSSQLPlatform.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MSSQLPlatform.py
@@ -63,18 +63,30 @@ class MSSQLPlatform(Platform):
def compile_create_sql(self, table, if_not_exists=False):
sql = []
- table_create_format = self.create_if_not_exists_format() if if_not_exists else self.create_format()
+ table_create_format = (
+ self.create_if_not_exists_format()
+ if if_not_exists
+ else self.create_format()
+ )
sql.append(
table_create_format.format(
table=self.wrap_table(table.name),
columns=", ".join(self.columnize(table.get_added_columns())).strip(),
constraints=(
- ", " + ", ".join(self.constraintize(table.get_added_constraints(), table))
+ ", "
+ + ", ".join(
+ self.constraintize(table.get_added_constraints(), table)
+ )
if table.get_added_constraints()
else ""
),
foreign_keys=(
- ", " + ", ".join(self.foreign_key_constraintize(table.name, table.added_foreign_keys))
+ ", "
+ + ", ".join(
+ self.foreign_key_constraintize(
+ table.name, table.added_foreign_keys
+ )
+ )
if table.added_foreign_keys
else ""
),
@@ -100,7 +112,8 @@ def compile_alter_sql(self, table):
sql.append(
self.alter_format().format(
table=self.wrap_table(table.name),
- columns="ADD " + ", ".join(self.columnize(table.added_columns)).strip(),
+ columns="ADD "
+ + ", ".join(self.columnize(table.added_columns)).strip(),
)
)
@@ -108,13 +121,16 @@ def compile_alter_sql(self, table):
sql.append(
self.alter_format().format(
table=self.wrap_table(table.name),
- columns="ALTER COLUMN " + ", ".join(self.columnize(table.changed_columns)).strip(),
+ columns="ALTER COLUMN "
+ + ", ".join(self.columnize(table.changed_columns)).strip(),
)
)
if table.renamed_columns:
for name, column in table.get_renamed_columns().items():
- sql.append(self.rename_column_string(table.name, name, column.name).strip())
+ sql.append(
+ self.rename_column_string(table.name, name, column.name).strip()
+ )
if table.dropped_columns:
dropped_sql = []
@@ -136,21 +152,21 @@ def compile_alter_sql(self, table):
) in table.get_added_foreign_keys().items():
cascade = ""
if foreign_key_constraint.delete_action:
- cascade += (
- f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
- )
+ cascade += f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
if foreign_key_constraint.update_action:
- cascade += (
- f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
- )
+ cascade += f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
sql.append(
f"ALTER TABLE {self.wrap_table(table.name)} ADD "
+ self.get_foreign_key_constraint_string().format(
constraint_name=foreign_key_constraint.constraint_name,
column=self.wrap_column(column),
table=self.wrap_table(table.name),
- foreign_table=self.wrap_table(foreign_key_constraint.foreign_table),
- foreign_column=self.wrap_column(foreign_key_constraint.foreign_column),
+ foreign_table=self.wrap_table(
+ foreign_key_constraint.foreign_table
+ ),
+ foreign_column=self.wrap_column(
+ foreign_key_constraint.foreign_column
+ ),
cascade=cascade,
)
)
@@ -158,7 +174,9 @@ def compile_alter_sql(self, table):
if table.dropped_foreign_keys:
constraints = table.dropped_foreign_keys
for constraint in constraints:
- sql.append(f"ALTER TABLE {self.wrap_table(table.name)} DROP CONSTRAINT {constraint}")
+ sql.append(
+ f"ALTER TABLE {self.wrap_table(table.name)} DROP CONSTRAINT {constraint}"
+ )
if table.added_indexes:
for name, index in table.added_indexes.items():
@@ -170,12 +188,18 @@ def compile_alter_sql(self, table):
)
)
- if table.removed_indexes or table.removed_unique_indexes or table.dropped_primary_keys:
+ if (
+ table.removed_indexes
+ or table.removed_unique_indexes
+ or table.dropped_primary_keys
+ ):
constraints = table.removed_indexes
constraints += table.removed_unique_indexes
constraints += table.dropped_primary_keys
for constraint in constraints:
- sql.append(f"DROP INDEX {self.wrap_table(table.name)}.{self.wrap_table(constraint)}")
+ sql.append(
+ f"DROP INDEX {self.wrap_table(table.name)}.{self.wrap_table(constraint)}"
+ )
if table.added_constraints:
for name, constraint in table.added_constraints.items():
@@ -204,7 +228,9 @@ def columnize(self, columns):
sql = []
for name, column in columns.items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -254,7 +280,9 @@ def constraintize(self, constraints, table):
sql = []
for name, constraint in constraints.items():
sql.append(
- getattr(self, f"get_{constraint.constraint_type}_constraint_string")().format(
+ getattr(
+ self, f"get_{constraint.constraint_type}_constraint_string"
+ )().format(
columns=", ".join(constraint._columns),
name_columns="_".join(constraint._columns),
constraint_name=constraint.name,
@@ -274,15 +302,15 @@ def create_format(self):
return "CREATE TABLE {table} ({columns}{constraints}{foreign_keys})"
def create_if_not_exists_format(self):
- return "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
+ return (
+ "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
+ )
def alter_format(self):
return "ALTER TABLE {table} {columns}"
def get_foreign_key_constraint_string(self):
- return (
- "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
- )
+ return "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
def get_primary_key_constraint_string(self):
return "CONSTRAINT {constraint_name} PRIMARY KEY ({columns})"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MySQLPlatform.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MySQLPlatform.py
index 4e764039..5c8119fc 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MySQLPlatform.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/MySQLPlatform.py
@@ -63,7 +63,9 @@ def columnize(self, columns):
sql = []
for name, column in columns.items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -99,8 +101,12 @@ def columnize(self, columns):
constraint=constraint,
nullable=self.premapped_nulls.get(column.is_null) or "",
default=default,
- signed=(" " + self.signed.get(column._signed) if column._signed else ""),
- comment=("COMMENT '" + column.comment + "'" if column.comment else ""),
+ signed=(
+ " " + self.signed.get(column._signed) if column._signed else ""
+ ),
+ comment=(
+ "COMMENT '" + column.comment + "'" if column.comment else ""
+ ),
)
.strip()
)
@@ -109,18 +115,30 @@ def columnize(self, columns):
def compile_create_sql(self, table, if_not_exists=False):
sql = []
- table_create_format = self.create_if_not_exists_format() if if_not_exists else self.create_format()
+ table_create_format = (
+ self.create_if_not_exists_format()
+ if if_not_exists
+ else self.create_format()
+ )
sql.append(
table_create_format.format(
table=self.get_table_string().format(table=table.name),
columns=", ".join(self.columnize(table.get_added_columns())).strip(),
constraints=(
- ", " + ", ".join(self.constraintize(table.get_added_constraints(), table))
+ ", "
+ + ", ".join(
+ self.constraintize(table.get_added_constraints(), table)
+ )
if table.get_added_constraints()
else ""
),
foreign_keys=(
- ", " + ", ".join(self.foreign_key_constraintize(table.name, table.added_foreign_keys))
+ ", "
+ + ", ".join(
+ self.foreign_key_constraintize(
+ table.name, table.added_foreign_keys
+ )
+ )
if table.added_foreign_keys
else ""
),
@@ -148,7 +166,9 @@ def compile_alter_sql(self, table):
for name, column in table.get_added_columns().items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -179,9 +199,21 @@ def compile_alter_sql(self, table):
constraint="PRIMARY KEY" if column.primary else "",
nullable="NULL" if column.is_null else "NOT NULL",
default=default,
- signed=(" " + self.signed.get(column._signed) if column._signed else ""),
- after=((" AFTER " + self.wrap_column(column._after)) if column._after else ""),
- comment=(" COMMENT '" + column.comment + "'" if column.comment else ""),
+ signed=(
+ " " + self.signed.get(column._signed)
+ if column._signed
+ else ""
+ ),
+ after=(
+ (" AFTER " + self.wrap_column(column._after))
+ if column._after
+ else ""
+ ),
+ comment=(
+ " COMMENT '" + column.comment + "'"
+ if column.comment
+ else ""
+ ),
)
.strip()
)
@@ -199,7 +231,9 @@ def compile_alter_sql(self, table):
for name, column in table.get_renamed_columns().items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -223,7 +257,9 @@ def compile_alter_sql(self, table):
sql.append(
self.alter_format().format(
table=self.wrap_table(table.name),
- columns=", ".join(f"MODIFY {x}" for x in self.columnize(table.changed_columns)),
+ columns=", ".join(
+ f"MODIFY {x}" for x in self.columnize(table.changed_columns)
+ ),
)
)
@@ -232,7 +268,9 @@ def compile_alter_sql(self, table):
for name in table.get_dropped_columns():
dropped_sql.append(
- self.drop_column_string().format(name=self.get_column_string().format(column=name)).strip()
+ self.drop_column_string()
+ .format(name=self.get_column_string().format(column=name))
+ .strip()
)
sql.append(
@@ -249,13 +287,9 @@ def compile_alter_sql(self, table):
) in table.get_added_foreign_keys().items():
cascade = ""
if foreign_key_constraint.delete_action:
- cascade += (
- f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
- )
+ cascade += f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
if foreign_key_constraint.update_action:
- cascade += (
- f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
- )
+ cascade += f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
sql.append(
f"ALTER TABLE {self.wrap_table(table.name)} ADD "
+ self.get_foreign_key_constraint_string().format(
@@ -271,7 +305,9 @@ def compile_alter_sql(self, table):
if table.dropped_foreign_keys:
constraints = table.dropped_foreign_keys
for constraint in constraints:
- sql.append(f"ALTER TABLE {self.wrap_table(table.name)} DROP FOREIGN KEY {constraint}")
+ sql.append(
+ f"ALTER TABLE {self.wrap_table(table.name)} DROP FOREIGN KEY {constraint}"
+ )
if table.added_indexes:
for name, index in table.added_indexes.items():
@@ -298,14 +334,22 @@ def compile_alter_sql(self, table):
f"ALTER TABLE {self.wrap_table(table.name)} ADD CONSTRAINT {constraint.name} PRIMARY KEY ({','.join(constraint._columns)})"
)
- if table.removed_indexes or table.removed_unique_indexes or table.dropped_primary_keys:
+ if (
+ table.removed_indexes
+ or table.removed_unique_indexes
+ or table.dropped_primary_keys
+ ):
constraints = table.removed_indexes
constraints += table.removed_unique_indexes
constraints += table.dropped_primary_keys
for constraint in constraints:
- sql.append(f"ALTER TABLE {self.wrap_table(table.name)} DROP INDEX {constraint}")
+ sql.append(
+ f"ALTER TABLE {self.wrap_table(table.name)} DROP INDEX {constraint}"
+ )
if table.comment:
- sql.append(f"ALTER TABLE {self.wrap_table(table.name)} COMMENT '{table.comment}'")
+ sql.append(
+ f"ALTER TABLE {self.wrap_table(table.name)} COMMENT '{table.comment}'"
+ )
return sql
def add_column_string(self):
@@ -327,7 +371,9 @@ def constraintize(self, constraints, table):
sql = []
for name, constraint in constraints.items():
sql.append(
- getattr(self, f"get_{constraint.constraint_type}_constraint_string")().format(
+ getattr(
+ self, f"get_{constraint.constraint_type}_constraint_string"
+ )().format(
columns=", ".join(constraint._columns),
name_columns="_".join(constraint._columns),
table=table.name,
@@ -353,9 +399,7 @@ def alter_format(self):
return "ALTER TABLE {table} {columns}"
def get_foreign_key_constraint_string(self):
- return (
- "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
- )
+ return "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
def get_primary_key_constraint_string(self):
return "CONSTRAINT {constraint_name} PRIMARY KEY ({columns})"
@@ -386,9 +430,7 @@ def compile_drop_table(self, table):
return f"DROP TABLE {self.wrap_table(table)}"
def compile_column_exists(self, table, column):
- return (
- f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
- )
+ return f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
def compile_get_all_tables(self, database, schema=None):
return f"SELECT table_name FROM information_schema.tables WHERE table_schema = '{database}'"
@@ -400,7 +442,9 @@ def get_current_schema(self, connection, table_name, schema=None):
reversed_type_map = {v: k for k, v in self.type_map.items()}
for column in result:
- column_type = self.get_column_type(reversed_type_map, column["Type"].upper())
+ column_type = self.get_column_type(
+ reversed_type_map, column["Type"].upper()
+ )
length = self.get_column_length(column["Type"])
default = column.get("Default")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/Platform.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/Platform.py
index 7b0cde9f..4b3ae2b7 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/Platform.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/Platform.py
@@ -2,6 +2,7 @@ class Platform:
foreign_key_actions = {
"cascade": "CASCADE",
"set null": "SET NULL",
+ "cascade": "CASCADE",
"restrict": "RESTRICT",
"no action": "NO ACTION",
"default": "SET DEFAULT",
@@ -13,7 +14,9 @@ def columnize(self, columns):
sql = []
for name, column in columns.items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -76,9 +79,9 @@ def constraintize(self, constraints):
sql = []
for name, constraint in constraints.items():
sql.append(
- getattr(self, f"get_{constraint.constraint_type}_constraint_string")().format(
- columns=", ".join(constraint._columns)
- )
+ getattr(
+ self, f"get_{constraint.constraint_type}_constraint_string"
+ )().format(columns=", ".join(constraint._columns))
)
return sql
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/PostgresPlatform.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/PostgresPlatform.py
index 9e3972e9..1c3e3b04 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/PostgresPlatform.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/PostgresPlatform.py
@@ -75,18 +75,30 @@ class PostgresPlatform(Platform):
def compile_create_sql(self, table, if_not_exists=False):
sql = []
- table_create_format = self.create_if_not_exists_format() if if_not_exists else self.create_format()
+ table_create_format = (
+ self.create_if_not_exists_format()
+ if if_not_exists
+ else self.create_format()
+ )
sql.append(
table_create_format.format(
table=self.wrap_table(table.name),
columns=", ".join(self.columnize(table.get_added_columns())).strip(),
constraints=(
- ", " + ", ".join(self.constraintize(table.get_added_constraints(), table))
+ ", "
+ + ", ".join(
+ self.constraintize(table.get_added_constraints(), table)
+ )
if table.get_added_constraints()
else ""
),
foreign_keys=(
- ", " + ", ".join(self.foreign_key_constraintize(table.name, table.added_foreign_keys))
+ ", "
+ + ", ".join(
+ self.foreign_key_constraintize(
+ table.name, table.added_foreign_keys
+ )
+ )
if table.added_foreign_keys
else ""
),
@@ -105,7 +117,9 @@ def compile_create_sql(self, table, if_not_exists=False):
for name, column in table.get_added_columns().items():
if column.comment:
- sql.append(f"""COMMENT ON COLUMN "{table.name}"."{name}" is '{column.comment}'""")
+ sql.append(
+ f"""COMMENT ON COLUMN "{table.name}"."{name}" is '{column.comment}'"""
+ )
if table.comment:
sql.append(f"""COMMENT ON TABLE "{table.name}" is '{table.comment}'""")
@@ -116,7 +130,9 @@ def columnize(self, columns):
sql = []
for name, column in columns.items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -167,7 +183,9 @@ def compile_alter_sql(self, table):
for name, column in table.get_added_columns().items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -222,7 +240,9 @@ def compile_alter_sql(self, table):
for name, column in table.get_renamed_columns().items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -246,7 +266,11 @@ def compile_alter_sql(self, table):
dropped_sql = []
for name in table.get_dropped_columns():
- dropped_sql.append(self.drop_column_string().format(name=self.wrap_column(name)).strip())
+ dropped_sql.append(
+ self.drop_column_string()
+ .format(name=self.wrap_column(name))
+ .strip()
+ )
sql.append(
self.alter_format().format(
@@ -281,12 +305,18 @@ def compile_alter_sql(self, table):
)
if column.is_null:
- changed_sql.append(f"ALTER COLUMN {self.wrap_column(name)} DROP NOT NULL")
+ changed_sql.append(
+ f"ALTER COLUMN {self.wrap_column(name)} DROP NOT NULL"
+ )
else:
- changed_sql.append(f"ALTER COLUMN {self.wrap_column(name)} SET NOT NULL")
+ changed_sql.append(
+ f"ALTER COLUMN {self.wrap_column(name)} SET NOT NULL"
+ )
if column.default is not None:
- changed_sql.append(f"ALTER COLUMN {self.wrap_column(name)} SET DEFAULT {column.default}")
+ changed_sql.append(
+ f"ALTER COLUMN {self.wrap_column(name)} SET DEFAULT {column.default}"
+ )
sql.append(
self.alter_format().format(
@@ -301,21 +331,21 @@ def compile_alter_sql(self, table):
) in table.get_added_foreign_keys().items():
cascade = ""
if foreign_key_constraint.delete_action:
- cascade += (
- f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
- )
+ cascade += f" ON DELETE {self.foreign_key_actions.get(foreign_key_constraint.delete_action.lower())}"
if foreign_key_constraint.update_action:
- cascade += (
- f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
- )
+ cascade += f" ON UPDATE {self.foreign_key_actions.get(foreign_key_constraint.update_action.lower())}"
sql.append(
f"ALTER TABLE {self.wrap_table(table.name)} ADD "
+ self.get_foreign_key_constraint_string().format(
column=self.wrap_column(column),
constraint_name=foreign_key_constraint.constraint_name,
table=self.wrap_table(table.name),
- foreign_table=self.wrap_table(foreign_key_constraint.foreign_table),
- foreign_column=self.wrap_column(foreign_key_constraint.foreign_column),
+ foreign_table=self.wrap_table(
+ foreign_key_constraint.foreign_table
+ ),
+ foreign_column=self.wrap_column(
+ foreign_key_constraint.foreign_column
+ ),
cascade=cascade,
)
)
@@ -325,12 +355,18 @@ def compile_alter_sql(self, table):
for constraint in constraints:
sql.append(f"DROP INDEX {constraint}")
- if table.dropped_foreign_keys or table.removed_unique_indexes or table.dropped_primary_keys:
+ if (
+ table.dropped_foreign_keys
+ or table.removed_unique_indexes
+ or table.dropped_primary_keys
+ ):
constraints = table.dropped_foreign_keys
constraints += table.removed_unique_indexes
constraints += table.dropped_primary_keys
for constraint in constraints:
- sql.append(f"ALTER TABLE {self.wrap_table(table.name)} DROP CONSTRAINT {constraint}")
+ sql.append(
+ f"ALTER TABLE {self.wrap_table(table.name)} DROP CONSTRAINT {constraint}"
+ )
if table.added_indexes:
for name, index in table.added_indexes.items():
@@ -360,7 +396,9 @@ def compile_alter_sql(self, table):
)
if table.comment:
- sql.append(f"""COMMENT ON TABLE {self.wrap_table(table.name)} is '{table.comment}'""")
+ sql.append(
+ f"""COMMENT ON TABLE {self.wrap_table(table.name)} is '{table.comment}'"""
+ )
return sql
@@ -389,7 +427,9 @@ def constraintize(self, constraints, table):
sql = []
for name, constraint in constraints.items():
sql.append(
- getattr(self, f"get_{constraint.constraint_type}_constraint_string")().format(
+ getattr(
+ self, f"get_{constraint.constraint_type}_constraint_string"
+ )().format(
columns=", ".join(constraint._columns),
name_columns="_".join(constraint._columns),
constraint_name=constraint.name,
@@ -402,13 +442,13 @@ def create_format(self):
return "CREATE TABLE {table} ({columns}{constraints}{foreign_keys})"
def create_if_not_exists_format(self):
- return "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
-
- def get_foreign_key_constraint_string(self):
return (
- "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
+ "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
)
+ def get_foreign_key_constraint_string(self):
+ return "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
+
def get_primary_key_constraint_string(self):
return "CONSTRAINT {constraint_name} PRIMARY KEY ({columns})"
@@ -447,15 +487,15 @@ def compile_drop_table(self, table):
return f"DROP TABLE {self.wrap_table(table)} CASCADE"
def compile_column_exists(self, table, column):
- return (
- f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
- )
+ return f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
def compile_get_all_tables(self, database=None, schema=None):
return f"SELECT table_name FROM information_schema.tables WHERE table_schema = '{schema or 'public'}' AND table_catalog = '{database}' AND table_type = 'BASE TABLE'"
def get_current_schema(self, connection, table_name, schema=None):
- sql = self.table_information_string().format(table=table_name, schema=schema or "public")
+ sql = self.table_information_string().format(
+ table=table_name, schema=schema or "public"
+ )
reversed_type_map = {v: k for k, v in self.type_map.items()}
reversed_type_map.update(self.table_info_map)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/SQLitePlatform.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/SQLitePlatform.py
index e1b26445..190c0c03 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/SQLitePlatform.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/platforms/SQLitePlatform.py
@@ -65,7 +65,11 @@ class SQLitePlatform(Platform):
def compile_create_sql(self, table, if_not_exists=False):
sql = []
- table_create_format = self.create_if_not_exists_format() if if_not_exists else self.create_format()
+ table_create_format = (
+ self.create_if_not_exists_format()
+ if if_not_exists
+ else self.create_format()
+ )
sql.append(
table_create_format.format(
table=self.get_table_string().format(table=table.name).strip(),
@@ -76,7 +80,12 @@ def compile_create_sql(self, table, if_not_exists=False):
else ""
),
foreign_keys=(
- ", " + ", ".join(self.foreign_key_constraintize(table.name, table.added_foreign_keys))
+ ", "
+ + ", ".join(
+ self.foreign_key_constraintize(
+ table.name, table.added_foreign_keys
+ )
+ )
if table.added_foreign_keys
else ""
),
@@ -85,7 +94,9 @@ def compile_create_sql(self, table, if_not_exists=False):
if table.added_indexes:
for name, index in table.added_indexes.items():
- sql.append(f"CREATE INDEX {index.name} ON {self.wrap_table(table.name)}({','.join(index.column)})")
+ sql.append(
+ f"CREATE INDEX {index.name} ON {self.wrap_table(table.name)}({','.join(index.column)})"
+ )
return sql
@@ -93,7 +104,9 @@ def columnize(self, columns):
sql = []
for name, column in columns.items():
if column.length:
- length = self.create_column_length(column.column_type).format(length=column.length)
+ length = self.create_column_length(column.column_type).format(
+ length=column.length
+ )
else:
length = ""
@@ -129,7 +142,8 @@ def columnize(self, columns):
length=length,
signed=(
" " + self.signed.get(column._signed)
- if column.column_type not in self.types_without_signs and column._signed
+ if column.column_type not in self.types_without_signs
+ and column._signed
else ""
),
constraint=constraint,
@@ -183,14 +197,20 @@ def compile_alter_sql(self, diff):
default=default,
signed=(
" " + self.signed.get(column._signed)
- if column.column_type not in self.types_without_signs and column._signed
+ if column.column_type not in self.types_without_signs
+ and column._signed
else ""
),
constraint=constraint,
)
.strip()
)
- if diff.renamed_columns or diff.dropped_columns or diff.changed_columns or diff.added_foreign_keys:
+ if (
+ diff.renamed_columns
+ or diff.dropped_columns
+ or diff.changed_columns
+ or diff.added_foreign_keys
+ ):
original_columns = diff.from_table.added_columns
# pop off the dropped columns. No need for them here
for column in diff.dropped_columns:
@@ -199,7 +219,9 @@ def compile_alter_sql(self, diff):
sql.append(
"CREATE TEMPORARY TABLE __temp__{table} AS SELECT {original_column_names} FROM {table}".format(
table=diff.name,
- original_column_names=", ".join(diff.from_table.added_columns.keys()),
+ original_column_names=", ".join(
+ diff.from_table.added_columns.keys()
+ ),
)
)
@@ -216,12 +238,18 @@ def compile_alter_sql(self, diff):
table=self.get_table_string().format(table=diff.name).strip(),
columns=", ".join(self.columnize(columns)).strip(),
constraints=(
- ", " + ", ".join(self.constraintize(diff.get_added_constraints()))
+ ", "
+ + ", ".join(self.constraintize(diff.get_added_constraints()))
if diff.get_added_constraints()
else ""
),
foreign_keys=(
- ", " + ", ".join(self.foreign_key_constraintize(diff.name, diff.added_foreign_keys))
+ ", "
+ + ", ".join(
+ self.foreign_key_constraintize(
+ diff.name, diff.added_foreign_keys
+ )
+ )
if diff.added_foreign_keys
else ""
),
@@ -236,7 +264,9 @@ def compile_alter_sql(self, diff):
quoted_table=self.wrap_table(diff.name),
table=diff.name,
new_columns=", ".join(self.columnize_names(columns)),
- original_column_names=", ".join(diff.from_table.added_columns.keys()),
+ original_column_names=", ".join(
+ diff.from_table.added_columns.keys()
+ ),
)
)
sql.append("DROP TABLE __temp__{table}".format(table=diff.name))
@@ -251,7 +281,9 @@ def compile_alter_sql(self, diff):
if diff.added_indexes:
for name, index in diff.added_indexes.items():
- sql.append(f"CREATE INDEX {index.name} ON {self.wrap_table(diff.name)}({','.join(index.column)})")
+ sql.append(
+ f"CREATE INDEX {index.name} ON {self.wrap_table(diff.name)}({','.join(index.column)})"
+ )
if diff.added_constraints:
for name, constraint in diff.added_constraints.items():
if constraint.constraint_type == "unique":
@@ -269,7 +301,9 @@ def create_format(self):
return "CREATE TABLE {table} ({columns}{constraints}{foreign_keys})"
def create_if_not_exists_format(self):
- return "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
+ return (
+ "CREATE TABLE IF NOT EXISTS {table} ({columns}{constraints}{foreign_keys})"
+ )
def get_table_string(self):
return '"{table}"'
@@ -292,9 +326,7 @@ def get_unique_constraint_string(self):
return "UNIQUE({columns})"
def get_foreign_key_constraint_string(self):
- return (
- "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
- )
+ return "CONSTRAINT {constraint_name} FOREIGN KEY ({column}) REFERENCES {foreign_table}({foreign_column}){cascade}"
def get_primary_key_constraint_string(self):
return "CONSTRAINT {constraint_name} PRIMARY KEY ({columns})"
@@ -303,7 +335,9 @@ def constraintize(self, constraints):
sql = []
for name, constraint in constraints.items():
sql.append(
- getattr(self, f"get_{constraint.constraint_type}_constraint_string")().format(
+ getattr(
+ self, f"get_{constraint.constraint_type}_constraint_string"
+ )().format(
columns=", ".join(constraint.columns),
constraint_name=constraint.name,
)
@@ -345,7 +379,9 @@ def get_current_schema(self, connection, table_name, schema=None):
result = connection.query(sql, ())
for column in result:
- column_type = self.get_column_type(reversed_type_map, column["type"].upper())
+ column_type = self.get_column_type(
+ reversed_type_map, column["type"].upper()
+ )
length = self.get_column_length(column["type"])
# find default
@@ -397,9 +433,7 @@ def compile_table_exists(self, table, database=None, schema=None):
return f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table}'"
def compile_column_exists(self, table, column):
- return (
- f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
- )
+ return f"SELECT column_name FROM information_schema.columns WHERE table_name='{table}' and column_name='{column}'"
def compile_get_all_tables(self, database, schema=None):
return "SELECT name FROM sqlite_master WHERE type='table'"
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/schema.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/schema.py
index 87143e8c..ef0f5678 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/schema.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/schema/schema.py
@@ -70,7 +70,9 @@ async def drop_table_if_exists(self, table: str) -> None:
if self._connection is None:
self._connection = self._manager.connection(None)
- sql = self._connection.get_default_platform()().compile_drop_table_if_exists(table)
+ sql = self._connection.get_default_platform()().compile_drop_table_if_exists(
+ table
+ )
await self._connection.statement(sql, ())
async def has_table(self, table: str) -> bool:
@@ -85,7 +87,9 @@ async def rename(self, table: str, new_name: str) -> None:
if self._connection is None:
self._connection = self._manager.connection(None)
- sql = self._connection.get_default_platform()().compile_rename_table(table, new_name)
+ sql = self._connection.get_default_platform()().compile_rename_table(
+ table, new_name
+ )
await self._connection.run(sql, ())
async def get_all_tables(self):
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/seeds/Seeder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/seeds/Seeder.py
index a555850c..338544b6 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/seeds/Seeder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/seeds/Seeder.py
@@ -14,10 +14,14 @@ async def call(self, *seeder_classes):
await seeder_class(connection=self.connection).run()
async def run_database_seed(self):
- database_seeder = pydoc.locate(f"{self.seed_module}.database_seeder.DatabaseSeeder")
+ database_seeder = pydoc.locate(
+ f"{self.seed_module}.database_seeder.DatabaseSeeder"
+ )
if not database_seeder:
- raise ValueError(f"Could not find the DatabaseSeeder class in {self.seed_module}.database_seeder")
+ raise ValueError(
+ f"Could not find the DatabaseSeeder class in {self.seed_module}.database_seeder"
+ )
self.ran_seeds.append(database_seeder)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/factory.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/factory.py
index 8f88f782..d5841d72 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/factory.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/factory.py
@@ -1,5 +1,6 @@
-from fastapi_startkit.orm.factory.factory import Factory
+import faker
+from fastapi_startkit.orm.factory.factory import Factory
from .model import User
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/model.py
index cc10d45a..cb93c244 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/model.py
@@ -1,9 +1,13 @@
-from fastapi_startkit.orm.models.model import Model
-
from fastapi_startkit.carbon.carbon import Carbon
from fastapi_startkit.masoniteorm import Field
from fastapi_startkit.masoniteorm.models.fields import DateTimeField
-from fastapi_startkit.masoniteorm.relationships import BelongsTo, BelongsToMany, HasMany, HasOne
+from fastapi_startkit.masoniteorm.relationships import (
+ HasOne,
+ BelongsTo,
+ HasMany,
+ BelongsToMany,
+)
+from fastapi_startkit.orm.models.model import Model
class User(Model):
@@ -41,8 +45,12 @@ class Articles(Model):
class Store(Model):
- products: "Product" = BelongsToMany("Product", "store_id", "product_id", "id", "id", with_timestamps=True)
- products_table: "Product" = BelongsToMany("Product", "store_id", "product_id", "id", "id", table="product_table")
+ products: "Product" = BelongsToMany(
+ "Product", "store_id", "product_id", "id", "id", with_timestamps=True
+ )
+ products_table: "Product" = BelongsToMany(
+ "Product", "store_id", "product_id", "id", "id", table="product_table"
+ )
store_products: "Product" = BelongsToMany("Product")
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/seeder.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/seeder.py
index 6344108c..f0a87c42 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/seeder.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/fixtures/seeder.py
@@ -1,10 +1,18 @@
-from .model import Articles, Logo, Profile, User
+from .model import User, Profile, Articles, Logo
async def seeder():
- user = await User.query().create({"email": "admin@admin.com", "name": "Joe", "is_admin": True})
+ user = await User.query().create(
+ {"email": "admin@admin.com", "name": "Joe", "is_admin": True}
+ )
await Profile.create({"name": "Joe Profile", "user_id": user.id})
article = await Articles.create(
- {"title": "Masonite ORM", "user_id": user.id, "published_date": "2020-01-01 00:00:00"}
+ {
+ "title": "Masonite ORM",
+ "user_id": user.id,
+ "published_date": "2020-01-01 00:00:00",
+ }
+ )
+ await Logo.create(
+ {"article_id": article.id, "published_date": "2020-01-01 00:00:00"}
)
- await Logo.create({"article_id": article.id, "published_date": "2020-01-01 00:00:00"})
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model.py
index 7b61ca5c..cb65e20f 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model.py
@@ -1,10 +1,10 @@
import pytest
-from fastapi_startkit.orm.connections.factory import ConnectionFactory
-from fastapi_startkit.orm.connections.manager import DatabaseManager
-from fastapi_startkit.orm.models.model import Model
from fastapi_startkit.carbon import Carbon
from fastapi_startkit.masoniteorm.models.fields import DateTimeField
+from fastapi_startkit.orm.connections.factory import ConnectionFactory
+from fastapi_startkit.orm.connections.manager import DatabaseManager
+from fastapi_startkit.orm.models.model import Model
# ---------------------------------------------------------------------------
# Shared fixtures
@@ -112,7 +112,10 @@ async def test_save_with_datetime_field(self, UserModel, users_table):
saved = await user.save()
assert saved is True
- assert user.email_verified_at.format("YYYY-MM-DD HH:mm:ss") == "2026-10-01 12:12:12"
+ assert (
+ user.email_verified_at.format("YYYY-MM-DD HH:mm:ss")
+ == "2026-10-01 12:12:12"
+ )
# ---------------------------------------------------------------------------
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_attributes.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_attributes.py
index ea9d5ea2..23a40420 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_attributes.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_attributes.py
@@ -1,13 +1,13 @@
-from unittest.mock import MagicMock, patch
-
import pendulum
import pytest
+from unittest.mock import MagicMock, patch
+
+from fastapi_startkit.carbon import Carbon
+from fastapi_startkit.masoniteorm.models.fields import DateTimeField
from fastapi_startkit.orm.connections.factory import ConnectionFactory
from fastapi_startkit.orm.connections.manager import DatabaseManager
from fastapi_startkit.orm.models.model import Model
-from fastapi_startkit.carbon import Carbon
-from fastapi_startkit.masoniteorm.models.fields import DateTimeField
# ---------------------------------------------------------------------------
# Shared fixtures
@@ -46,7 +46,9 @@ class User(Model):
class TestConnectionFactory:
def test_build_url_uses_explicit_url(self):
- url = ConnectionFactory.build_url({"driver": "sqlite", "url": "sqlite+aiosqlite:///test.db"})
+ url = ConnectionFactory.build_url(
+ {"driver": "sqlite", "url": "sqlite+aiosqlite:///test.db"}
+ )
assert url == "sqlite+aiosqlite:///test.db"
def test_build_url_constructs_from_parts(self):
@@ -146,7 +148,10 @@ def test_email_verified_at_format(self, UserModel):
email="alex@gmail.com",
email_verified_at="2026-10-01 12:12:12",
)
- assert user.email_verified_at.format("YYYY-MM-DD HH:mm:ss") == "2026-10-01 12:12:12"
+ assert (
+ user.email_verified_at.format("YYYY-MM-DD HH:mm:ss")
+ == "2026-10-01 12:12:12"
+ )
def test_email_verified_at_none_when_not_set(self, UserModel):
user = UserModel(name="Alex", email="alex@gmail.com")
@@ -189,6 +194,8 @@ def test_query_returns_query_builder(self, UserModel):
assert isinstance(builder, QueryBuilder)
def test_query_builder_has_model_set(self, UserModel):
+ from fastapi_startkit.orm.models.builder import QueryBuilder
+
builder = UserModel.query()
assert builder._model is not None
assert isinstance(builder._model, UserModel)
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_query.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_query.py
index 5f4d63a5..45815137 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_query.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/models/test_model_query.py
@@ -106,7 +106,9 @@ async def test_where_dict(self, UserModel, seeded_users):
results = await UserModel.where({"name": "Alice", "is_admin": True}).get()
assert len(results) == 1
- async def test_where_returns_empty_collection_when_no_match(self, UserModel, seeded_users):
+ async def test_where_returns_empty_collection_when_no_match(
+ self, UserModel, seeded_users
+ ):
results = await UserModel.where("name", "Nobody").get()
assert len(results) == 0
@@ -123,12 +125,18 @@ async def test_or_where_matches_either_condition(self, UserModel, seeded_users):
assert names == {"Alice", "Bob"}
async def test_or_where_no_match_returns_empty(self, UserModel, seeded_users):
- results = await UserModel.where("name", "Nobody").or_where("name", "Ghost").get()
+ results = (
+ await UserModel.where("name", "Nobody").or_where("name", "Ghost").get()
+ )
assert len(results) == 0
async def test_or_where_like(self, UserModel, seeded_users):
# Match names starting with 'A' OR ending with 'e'
- results = await UserModel.where("name", "like", "A%").or_where("name", "like", "%e").get()
+ results = (
+ await UserModel.where("name", "like", "A%")
+ .or_where("name", "like", "%e")
+ .get()
+ )
names = {u.name for u in results}
# "Alice" matches both; "Charlie" matches '%e'
assert "Alice" in names
@@ -322,5 +330,10 @@ async def test_where_and_select(self, UserModel, seeded_users):
assert results.first().name == "Alice"
async def test_or_where_and_limit(self, UserModel, seeded_users):
- results = await UserModel.where("name", "Alice").or_where("name", "Charlie").limit(1).get()
+ results = (
+ await UserModel.where("name", "Alice")
+ .or_where("name", "Charlie")
+ .limit(1)
+ .get()
+ )
assert len(results) == 1
diff --git a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/sqlite/relationships/test_sqlite_relationships.py b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/sqlite/relationships/test_sqlite_relationships.py
index 221c4715..01b48f24 100644
--- a/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/sqlite/relationships/test_sqlite_relationships.py
+++ b/fastapi_startkit/src/fastapi_startkit/masoniteorm/tests/sqlite/relationships/test_sqlite_relationships.py
@@ -1,4 +1,5 @@
-from fastapi_startkit.orm.tests.fixtures.model import Profile, User
+from fastapi_startkit.orm.tests.fixtures.model import Profile
+from fastapi_startkit.orm.tests.fixtures.model import User
from fastapi_startkit.orm.tests.sqlite.test_case import TestCase
diff --git a/fastapi_startkit/src/fastapi_startkit/providers/Provider.py b/fastapi_startkit/src/fastapi_startkit/providers/Provider.py
index e7c2e3d3..f03982c5 100644
--- a/fastapi_startkit/src/fastapi_startkit/providers/Provider.py
+++ b/fastapi_startkit/src/fastapi_startkit/providers/Provider.py
@@ -1,8 +1,10 @@
-from typing import TYPE_CHECKING
+import dataclasses
+from typing import TYPE_CHECKING, Any
-from fastapi_startkit.helpers.dataclass import Dataclass
from fastapi_startkit.helpers.string import Str
+from fastapi_startkit.helpers.dataclass import Dataclass
+
if TYPE_CHECKING:
from ..application import Application
@@ -15,7 +17,12 @@ def __init__(self, application: "Application", config: dict = None):
self.config = config or {}
if self.provider_key is None:
- self.provider_key = str(Str.of(self.__class__.__name__).trim("ServiceProvider").trim("Provider").slugify())
+ self.provider_key = str(
+ Str.of(self.__class__.__name__)
+ .trim("ServiceProvider")
+ .trim("Provider")
+ .slugify()
+ )
def register(self) -> None:
pass
diff --git a/fastapi_startkit/src/fastapi_startkit/tests/configurations/test_config_merge.py b/fastapi_startkit/src/fastapi_startkit/tests/configurations/test_config_merge.py
index dd1efff8..67772763 100644
--- a/fastapi_startkit/src/fastapi_startkit/tests/configurations/test_config_merge.py
+++ b/fastapi_startkit/src/fastapi_startkit/tests/configurations/test_config_merge.py
@@ -1,6 +1,6 @@
from unittest.mock import MagicMock, patch
-
from fastapi_startkits.configuration import Configuration
+from fastapi_startkits.loader import Loader
class TestConfiguration:
@@ -35,9 +35,14 @@ def test_merge_with_file_path(self):
config.set("testkey", {"existing": "orig"})
# Mock Loader to return params from file
- with patch("fastapi_startkit.configuration.Configuration.Loader") as MockLoaderClass:
+ with patch(
+ "fastapi_startkit.configuration.Configuration.Loader"
+ ) as MockLoaderClass:
mock_loader = MockLoaderClass.return_value
- mock_loader.get_parameters.return_value = {"New": "from_file", "Existing": "default_from_file"}
+ mock_loader.get_parameters.return_value = {
+ "New": "from_file",
+ "Existing": "default_from_file",
+ }
# Act
config.merge_with("testkey", "/path/to/config.py")
diff --git a/fastapi_startkit/src/fastapi_startkit/tests/test_case.py b/fastapi_startkit/src/fastapi_startkit/tests/test_case.py
index 2edabdd2..04432b91 100644
--- a/fastapi_startkit/src/fastapi_startkit/tests/test_case.py
+++ b/fastapi_startkit/src/fastapi_startkit/tests/test_case.py
@@ -3,9 +3,8 @@
class TestCase(unittest.TestCase):
def setUp(self):
- from fastapi.testclient import TestClient
-
from fastapi_startkit.application import app
+ from fastapi.testclient import TestClient
self.client = TestClient(app())
diff --git a/fastapi_startkit/src/fastapi_startkit/utils/collections.py b/fastapi_startkit/src/fastapi_startkit/utils/collections.py
index be56db12..441f552f 100644
--- a/fastapi_startkit/src/fastapi_startkit/utils/collections.py
+++ b/fastapi_startkit/src/fastapi_startkit/utils/collections.py
@@ -1,8 +1,7 @@
import json
-import operator
import random
+import operator
from functools import reduce
-
from dotty_dict import Dotty
from .structures import data_get
@@ -251,7 +250,9 @@ def pluck(self, value, key=None):
for k, v in iterable:
if k == value:
if key:
- attributes[self._data_get(item, key)] = self._data_get(item, value)
+ attributes[self._data_get(item, key)] = self._data_get(
+ item, value
+ )
else:
attributes.append(v)
diff --git a/fastapi_startkit/src/fastapi_startkit/utils/filesystem.py b/fastapi_startkit/src/fastapi_startkit/utils/filesystem.py
index 625c93e1..b433fd7f 100644
--- a/fastapi_startkit/src/fastapi_startkit/utils/filesystem.py
+++ b/fastapi_startkit/src/fastapi_startkit/utils/filesystem.py
@@ -1,7 +1,7 @@
-import mimetypes
import os
-import pathlib
import platform
+import pathlib
+import mimetypes
def make_directory(directory):
diff --git a/fastapi_startkit/src/fastapi_startkit/utils/location.py b/fastapi_startkit/src/fastapi_startkit/utils/location.py
index 6fff2907..326475ab 100644
--- a/fastapi_startkit/src/fastapi_startkit/utils/location.py
+++ b/fastapi_startkit/src/fastapi_startkit/utils/location.py
@@ -1,7 +1,7 @@
"""Helpers to resolve absolute paths to the different app resources using a configured
location."""
-from os.path import abspath, join
+from os.path import join, abspath
from .str import as_filepath
diff --git a/fastapi_startkit/src/fastapi_startkit/utils/str.py b/fastapi_startkit/src/fastapi_startkit/utils/str.py
index 6e494d77..e6c3db32 100644
--- a/fastapi_startkit/src/fastapi_startkit/utils/str.py
+++ b/fastapi_startkit/src/fastapi_startkit/utils/str.py
@@ -2,8 +2,8 @@
import random
import string
-from typing import Any
from urllib import parse
+from typing import Any
def random_string(length=4):
@@ -15,7 +15,9 @@ def random_string(length=4):
Returns:
string
"""
- return "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))
+ return "".join(
+ random.choice(string.ascii_uppercase + string.digits) for _ in range(length)
+ )
def modularize(file_path, suffix=".py"):
@@ -79,7 +81,9 @@ def add_query_params(url: str, query_params: dict) -> str:
"""Add query params dict to a given url (which can already contain some query parameters)."""
path_result = parse.urlsplit(url)
- base_url = f"{path_result.scheme}://{path_result.hostname}" if path_result.hostname else ""
+ base_url = (
+ f"{path_result.scheme}://{path_result.hostname}" if path_result.hostname else ""
+ )
base_path = path_result.path
# parse existing query parameters if any
diff --git a/fastapi_startkit/src/fastapi_startkit/utils/structures.py b/fastapi_startkit/src/fastapi_startkit/utils/structures.py
index 5192e344..1fc1b0ab 100644
--- a/fastapi_startkit/src/fastapi_startkit/utils/structures.py
+++ b/fastapi_startkit/src/fastapi_startkit/utils/structures.py
@@ -1,11 +1,13 @@
"""Helpers for multiple data structures"""
import importlib
-
+from importlib.abc import Loader
from dotty_dict import dotty
from ..exceptions.exceptions import LoaderNotFound
+from .str import modularize
+
def load(path, object_name=None, default=None, raise_exception=False):
"""Load the given object from a Python module located at path and returns a default
@@ -19,7 +21,11 @@ def load(path, object_name=None, default=None, raise_exception=False):
{object} -- The value (or default) read in the module or the module if no object name
"""
try:
- name = path.split("/")[-1].replace(".py", "") if "/" in path else path.replace(".py", "")
+ name = (
+ path.split("/")[-1].replace(".py", "")
+ if "/" in path
+ else path.replace(".py", "")
+ )
spec = importlib.util.spec_from_file_location(name, path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
diff --git a/fastapi_startkit/src/fastapi_startkit/vite/__init__.py b/fastapi_startkit/src/fastapi_startkit/vite/__init__.py
index 8acf44ee..c6c8cf31 100644
--- a/fastapi_startkit/src/fastapi_startkit/vite/__init__.py
+++ b/fastapi_startkit/src/fastapi_startkit/vite/__init__.py
@@ -1,6 +1,6 @@
-from .exceptions import ViteException, ViteManifestNotFoundException
-from .providers.provider import ViteProvider
from .vite import Vite
+from .providers.provider import ViteProvider
+from .exceptions import ViteException, ViteManifestNotFoundException
__all__ = [
"Vite",
diff --git a/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py b/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py
index 36a6f9c9..5b39cb74 100644
--- a/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py
+++ b/fastapi_startkit/src/fastapi_startkit/vite/providers/provider.py
@@ -1,11 +1,10 @@
import os
-from pathlib import Path
-from starlette.templating import Jinja2Templates
+from dumpdie import dd
from fastapi_startkit.providers import Provider
-
from ..config.vite import ViteConfig
+
from ..vite import Vite
@@ -18,11 +17,6 @@ def register(self) -> None:
config = self.resolve_config(ViteConfig)
self.merge_config_from(config, self.provider_key)
- # Bind Jinja2Templates so ViteProvider can inject vite() globals into it.
- templates_dir = Path(self.app.base_path) / "templates"
- templates = Jinja2Templates(directory=str(templates_dir))
- self.app.bind("templates", templates)
-
config = ViteConfig(**config)
vite = Vite(
@@ -43,7 +37,9 @@ def boot(self) -> None:
self.mount_static_file_if_require(config)
self.register_jinja_directives(vite)
- source = os.path.abspath(str(os.path.join(str(os.path.dirname(__file__)), "../config/vite.py")))
+ source = os.path.abspath(
+ str(os.path.join(str(os.path.dirname(__file__)), "../config/vite.py"))
+ )
self.publishes({source: "config/vite.py"})
def mount_static_file_if_require(self, config: ViteConfig):
@@ -74,4 +70,6 @@ def register_jinja_directives(self, vite: Vite):
templates.env.globals["vite"] = lambda *a, **kw: Markup(vite(*a, **kw))
templates.env.globals["vite_asset"] = vite.asset
- templates.env.globals["vite_react_refresh"] = lambda: Markup(vite.react_refresh())
+ templates.env.globals["vite_react_refresh"] = lambda: Markup(
+ vite.react_refresh()
+ )
diff --git a/fastapi_startkit/src/fastapi_startkit/vite/vite.py b/fastapi_startkit/src/fastapi_startkit/vite/vite.py
index 5232e240..ebcedb02 100644
--- a/fastapi_startkit/src/fastapi_startkit/vite/vite.py
+++ b/fastapi_startkit/src/fastapi_startkit/vite/vite.py
@@ -5,6 +5,8 @@
import secrets
from typing import Callable, Optional
+from dumpdie import dd
+
from .exceptions import ViteException, ViteManifestNotFoundException
@@ -76,7 +78,9 @@ def with_entry_points(self, entry_points: list[str]) -> "Vite":
self._entry_points = entry_points
return self
- def create_asset_paths_using(self, resolver: Optional[Callable[[str], str]]) -> "Vite":
+ def create_asset_paths_using(
+ self, resolver: Optional[Callable[[str], str]]
+ ) -> "Vite":
"""Override the default asset URL builder with a custom callable."""
self._asset_path_resolver = resolver
return self
@@ -116,9 +120,15 @@ def __call__(
if self.is_running_hot():
hot_origin = self._read_hot_origin()
- tags = [self._make_tag_for_chunk("@vite/client", f"{hot_origin}/@vite/client", None, None)]
+ tags = [
+ self._make_tag_for_chunk(
+ "@vite/client", f"{hot_origin}/@vite/client", None, None
+ )
+ ]
for ep in entrypoints:
- tags.append(self._make_tag_for_chunk(ep, f"{hot_origin}/{ep}", None, None))
+ tags.append(
+ self._make_tag_for_chunk(ep, f"{hot_origin}/{ep}", None, None)
+ )
return "".join(tags)
manifest = self._manifest(build_directory)
@@ -275,7 +285,9 @@ def _manifest(self, build_directory: str) -> dict:
path = self._manifest_path(build_directory)
if path not in Vite._manifests:
if not os.path.isfile(path):
- raise ViteManifestNotFoundException(f"Vite manifest not found at: {path}")
+ raise ViteManifestNotFoundException(
+ f"Vite manifest not found at: {path}"
+ )
with open(path) as f:
Vite._manifests[path] = json.load(f)
return Vite._manifests[path]
@@ -310,7 +322,9 @@ def _resolve_imports(
seen[import_key] = True
imports.append(import_key)
if import_key in manifest:
- imports.extend(self._resolve_imports(manifest, manifest[import_key], seen))
+ imports.extend(
+ self._resolve_imports(manifest, manifest[import_key], seen)
+ )
return imports
def _make_tag_for_chunk(
@@ -341,7 +355,9 @@ def _make_preload_tag_for_chunk(
if attributes is False:
return ""
- self._preloaded_assets[url] = self._parse_attributes({k: v for k, v in attributes.items() if k != "href"})
+ self._preloaded_assets[url] = self._parse_attributes(
+ {k: v for k, v in attributes.items() if k != "href"}
+ )
return f""
def _resolve_script_tag_attributes(self, src, url, chunk, manifest) -> dict:
@@ -367,16 +383,18 @@ def _resolve_preload_tag_attributes(self, src, url, chunk, manifest) -> dict | b
"as": "style",
"href": url,
"nonce": self._nonce or False,
- "crossorigin": self._resolve_stylesheet_tag_attributes(src, url, chunk, manifest).get(
- "crossorigin", False
- ),
+ "crossorigin": self._resolve_stylesheet_tag_attributes(
+ src, url, chunk, manifest
+ ).get("crossorigin", False),
}
else:
attrs = {
"rel": "modulepreload",
"href": url,
"nonce": self._nonce or False,
- "crossorigin": self._resolve_script_tag_attributes(src, url, chunk, manifest).get("crossorigin", False),
+ "crossorigin": self._resolve_script_tag_attributes(
+ src, url, chunk, manifest
+ ).get("crossorigin", False),
}
if self._integrity_key is not False:
diff --git a/fastapi_startkit/uv.lock b/fastapi_startkit/uv.lock
index 6dbf874d..4a56be09 100644
--- a/fastapi_startkit/uv.lock
+++ b/fastapi_startkit/uv.lock
@@ -443,7 +443,7 @@ wheels = [
[[package]]
name = "fastapi-startkit"
-version = "0.13.7"
+version = "0.13.6"
source = { editable = "." }
dependencies = [
{ name = "cleo" },
@@ -481,7 +481,6 @@ dev = [
{ name = "dumpdie" },
{ name = "pytest" },
{ name = "pytest-asyncio" },
- { name = "ruff" },
{ name = "twine" },
]
@@ -509,7 +508,6 @@ dev = [
{ name = "dumpdie", specifier = ">=1.5.0" },
{ name = "pytest", specifier = ">=9.0.3" },
{ name = "pytest-asyncio", specifier = ">=1.3.0" },
- { name = "ruff", specifier = ">=0.15.12" },
{ name = "twine", specifier = ">=6.2.0" },
]
@@ -1440,31 +1438,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/79/62/b88e5879512c55b8ee979c666ee6902adc4ed05007226de266410ae27965/rignore-0.7.6-cp314-cp314t-win_arm64.whl", hash = "sha256:b83adabeb3e8cf662cabe1931b83e165b88c526fa6af6b3aa90429686e474896", size = 656035, upload-time = "2025-11-05T21:41:31.13Z" },
]
-[[package]]
-name = "ruff"
-version = "0.15.12"
-source = { registry = "https://pypi.org/simple" }
-sdist = { url = "https://files.pythonhosted.org/packages/99/43/3291f1cc9106f4c63bdce7a8d0df5047fe8422a75b091c16b5e9355e0b11/ruff-0.15.12.tar.gz", hash = "sha256:ecea26adb26b4232c0c2ca19ccbc0083a68344180bba2a600605538ce51a40a6", size = 4643852, upload-time = "2026-04-24T18:17:14.305Z" }
-wheels = [
- { url = "https://files.pythonhosted.org/packages/c3/6e/e78ffb61d4686f3d96ba3df2c801161843746dcbcbb17a1e927d4829312b/ruff-0.15.12-py3-none-linux_armv6l.whl", hash = "sha256:f86f176e188e94d6bdbc09f09bfd9dc729059ad93d0e7390b5a73efe19f8861c", size = 10640713, upload-time = "2026-04-24T18:17:22.841Z" },
- { url = "https://files.pythonhosted.org/packages/ae/08/a317bc231fb9e7b93e4ef3089501e51922ff88d6936ce5cf870c4fe55419/ruff-0.15.12-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:e3bcd123364c3770b8e1b7baaf343cc99a35f197c5c6e8af79015c666c423a6c", size = 11069267, upload-time = "2026-04-24T18:17:30.105Z" },
- { url = "https://files.pythonhosted.org/packages/aa/a4/f828e9718d3dce1f5f11c39c4f65afd32783c8b2aebb2e3d259e492c47bd/ruff-0.15.12-py3-none-macosx_11_0_arm64.whl", hash = "sha256:fe87510d000220aa1ed530d4448a7c696a0cae1213e5ec30e5874287b66557b5", size = 10397182, upload-time = "2026-04-24T18:17:07.177Z" },
- { url = "https://files.pythonhosted.org/packages/71/e0/3310fc6d1b5e1fdea22bf3b1b807c7e187b581021b0d7d4514cccdb5fb71/ruff-0.15.12-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:84a1630093121375a3e2a95b4a6dc7b59e2b4ee76216e32d81aae550a832d002", size = 10758012, upload-time = "2026-04-24T18:16:55.759Z" },
- { url = "https://files.pythonhosted.org/packages/11/c1/a606911aee04c324ddaa883ae418f3569792fd3c4a10c50e0dd0a2311e1e/ruff-0.15.12-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:fb129f40f114f089ebe0ca56c0d251cf2061b17651d464bb6478dc01e69f11f5", size = 10447479, upload-time = "2026-04-24T18:16:51.677Z" },
- { url = "https://files.pythonhosted.org/packages/9d/68/4201e8444f0894f21ab4aeeaee68aa4f10b51613514a20d80bd628d57e88/ruff-0.15.12-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b0c862b172d695db7598426b8af465e7e9ac00a3ea2a3630ee67eb82e366aaa6", size = 11234040, upload-time = "2026-04-24T18:17:16.529Z" },
- { url = "https://files.pythonhosted.org/packages/34/ff/8a6d6cf4ccc23fd67060874e832c18919d1557a0611ebef03fdb01fff11e/ruff-0.15.12-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2849ea9f3484c3aca43a82f484210370319e7170df4dfe4843395ddf6c57bc33", size = 12087377, upload-time = "2026-04-24T18:17:04.944Z" },
- { url = "https://files.pythonhosted.org/packages/85/f6/c669cf73f5152f623d34e69866a46d5e6185816b19fcd5b6dd8a2d299922/ruff-0.15.12-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9e77c7e51c07fe396826d5969a5b846d9cd4c402535835fb6e21ce8b28fef847", size = 11367784, upload-time = "2026-04-24T18:17:25.409Z" },
- { url = "https://files.pythonhosted.org/packages/e8/39/c61d193b8a1daaa8977f7dea9e8d8ba866e02ea7b65d32f6861693aa4c12/ruff-0.15.12-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:83b2f4f2f3b1026b5fb449b467d9264bf22067b600f7b6f41fc5958909f449d0", size = 11344088, upload-time = "2026-04-24T18:17:12.258Z" },
- { url = "https://files.pythonhosted.org/packages/c2/8d/49afab3645e31e12c590acb6d3b5b69d7aab5b81926dbaf7461f9441f37a/ruff-0.15.12-py3-none-manylinux_2_31_riscv64.whl", hash = "sha256:9ba3b8f1afd7e2e43d8943e55f249e13f9682fde09711644a6e7290eb4f3e339", size = 11271770, upload-time = "2026-04-24T18:17:02.457Z" },
- { url = "https://files.pythonhosted.org/packages/46/06/33f41fe94403e2b755481cdfb9b7ef3e4e0ed031c4581124658d935d52b4/ruff-0.15.12-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:e852ba9fdc890655e1d78f2df1499efbe0e54126bd405362154a75e2bde159c5", size = 10719355, upload-time = "2026-04-24T18:17:27.648Z" },
- { url = "https://files.pythonhosted.org/packages/0d/59/18aa4e014debbf559670e4048e39260a85c7fcee84acfd761ac01e7b8d35/ruff-0.15.12-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dd8aed930da53780d22fc70bdf84452c843cf64f8cb4eb38984319c24c5cd5fd", size = 10462758, upload-time = "2026-04-24T18:17:32.347Z" },
- { url = "https://files.pythonhosted.org/packages/25/e7/cc9f16fd0f3b5fddcbd7ec3d6ae30c8f3fde1047f32a4093a98d633c6570/ruff-0.15.12-py3-none-musllinux_1_2_i686.whl", hash = "sha256:01da3988d225628b709493d7dc67c3b9b12c0210016b08690ef9bd27970b262b", size = 10953498, upload-time = "2026-04-24T18:17:20.674Z" },
- { url = "https://files.pythonhosted.org/packages/72/7a/a9ba7f98c7a575978698f4230c5e8cc54bbc761af34f560818f933dafa0c/ruff-0.15.12-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:9cae0f92bd5700d1213188b31cd3bdd2b315361296d10b96b8e2337d3d11f53e", size = 11447765, upload-time = "2026-04-24T18:17:09.755Z" },
- { url = "https://files.pythonhosted.org/packages/ea/f9/0ae446942c846b8266059ad8a30702a35afae55f5cdc54c5adf8d7afdc27/ruff-0.15.12-py3-none-win32.whl", hash = "sha256:d0185894e038d7043ba8fd6aee7499ece6462dc0ea9f1e260c7451807c714c20", size = 10657277, upload-time = "2026-04-24T18:17:18.591Z" },
- { url = "https://files.pythonhosted.org/packages/33/f1/9614e03e1cdcbf9437570b5400ced8a720b5db22b28d8e0f1bda429f660d/ruff-0.15.12-py3-none-win_amd64.whl", hash = "sha256:c87a162d61ab3adca47c03f7f717c68672edec7d1b5499e652331780fe74950d", size = 11837758, upload-time = "2026-04-24T18:17:00.113Z" },
- { url = "https://files.pythonhosted.org/packages/c0/98/6beb4b351e472e5f4c4613f7c35a5290b8be2497e183825310c4c3a3984b/ruff-0.15.12-py3-none-win_arm64.whl", hash = "sha256:a538f7a82d061cee7be55542aca1d86d1393d55d81d4fcc314370f4340930d4f", size = 11120821, upload-time = "2026-04-24T18:16:57.979Z" },
-]
-
[[package]]
name = "secretstorage"
version = "3.5.0"