internal.queries.seller_issue_reports

  1# Code generated by sqlc. DO NOT EDIT.
  2# versions:
  3#   sqlc v1.30.0
  4# source: seller_issue_reports.sql
  5import pydantic
  6from typing import AsyncIterator, Optional
  7
  8import sqlalchemy
  9import sqlalchemy.ext.asyncio
 10
 11from internal.queries import models
 12
 13
 14CREATE_SELLER_ISSUE_REPORT = """-- name: create_seller_issue_report \\:one
 15INSERT INTO seller_issue_reports (reservation_id, issue_type, description)
 16VALUES (:p1, :p2, :p3)
 17RETURNING report_id, reservation_id, issue_type, description, created_at, status
 18"""
 19
 20
 21class CreateSellerIssueReportParams(pydantic.BaseModel):
 22    reservation_id: int
 23    issue_type: models.SellerIssueType
 24    description: str
 25
 26
 27DELETE_SELLER_ISSUE_REPORT = """-- name: delete_seller_issue_report \\:one
 28DELETE FROM seller_issue_reports
 29WHERE report_id = :p1
 30RETURNING report_id, reservation_id, issue_type, description, created_at, status
 31"""
 32
 33
 34GET_SELLER_ISSUE_REPORTS = """-- name: get_seller_issue_reports \\:many
 35SELECT report_id, reservation_id, issue_type, description, created_at, status FROM seller_issue_reports
 36"""
 37
 38
 39GET_SELLER_ISSUE_REPORTS_BY_USER = """-- name: get_seller_issue_reports_by_user \\:many
 40SELECT r.report_id, r.reservation_id, r.issue_type, r.description, r.created_at, r.status FROM seller_issue_reports r
 41JOIN reservations res ON r.reservation_id = res.reservation_id
 42WHERE res.consumer_id = :p1
 43"""
 44
 45
 46UPDATE_SELLER_ISSUE_REPORT_STATUS = """-- name: update_seller_issue_report_status \\:one
 47UPDATE seller_issue_reports
 48SET status = :p2
 49WHERE report_id = :p1
 50RETURNING report_id, reservation_id, issue_type, description, created_at, status
 51"""
 52
 53
 54class UpdateSellerIssueReportStatusParams(pydantic.BaseModel):
 55    report_id: int
 56    status: models.IssueStatus
 57
 58
 59class AsyncQuerier:
 60    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
 61        self._conn = conn
 62
 63    async def create_seller_issue_report(self, arg: CreateSellerIssueReportParams) -> Optional[models.SellerIssueReport]:
 64        row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER_ISSUE_REPORT), {"p1": arg.reservation_id, "p2": arg.issue_type, "p3": arg.description})).first()
 65        if row is None:
 66            return None
 67        return models.SellerIssueReport(
 68            report_id=row[0],
 69            reservation_id=row[1],
 70            issue_type=row[2],
 71            description=row[3],
 72            created_at=row[4],
 73            status=row[5],
 74        )
 75
 76    async def delete_seller_issue_report(self, *, report_id: int) -> Optional[models.SellerIssueReport]:
 77        row = (await self._conn.execute(sqlalchemy.text(DELETE_SELLER_ISSUE_REPORT), {"p1": report_id})).first()
 78        if row is None:
 79            return None
 80        return models.SellerIssueReport(
 81            report_id=row[0],
 82            reservation_id=row[1],
 83            issue_type=row[2],
 84            description=row[3],
 85            created_at=row[4],
 86            status=row[5],
 87        )
 88
 89    async def get_seller_issue_reports(self) -> AsyncIterator[models.SellerIssueReport]:
 90        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS))
 91        async for row in result:
 92            yield models.SellerIssueReport(
 93                report_id=row[0],
 94                reservation_id=row[1],
 95                issue_type=row[2],
 96                description=row[3],
 97                created_at=row[4],
 98                status=row[5],
 99            )
100
101    async def get_seller_issue_reports_by_user(self, *, consumer_id: int) -> AsyncIterator[models.SellerIssueReport]:
102        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS_BY_USER), {"p1": consumer_id})
103        async for row in result:
104            yield models.SellerIssueReport(
105                report_id=row[0],
106                reservation_id=row[1],
107                issue_type=row[2],
108                description=row[3],
109                created_at=row[4],
110                status=row[5],
111            )
112
113    async def update_seller_issue_report_status(self, arg: UpdateSellerIssueReportStatusParams) -> Optional[models.SellerIssueReport]:
114        row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER_ISSUE_REPORT_STATUS), {"p1": arg.report_id, "p2": arg.status})).first()
115        if row is None:
116            return None
117        return models.SellerIssueReport(
118            report_id=row[0],
119            reservation_id=row[1],
120            issue_type=row[2],
121            description=row[3],
122            created_at=row[4],
123            status=row[5],
124        )
CREATE_SELLER_ISSUE_REPORT = '-- name: create_seller_issue_report \\:one\nINSERT INTO seller_issue_reports (reservation_id, issue_type, description)\nVALUES (:p1, :p2, :p3)\nRETURNING report_id, reservation_id, issue_type, description, created_at, status\n'
class CreateSellerIssueReportParams(pydantic.main.BaseModel):
22class CreateSellerIssueReportParams(pydantic.BaseModel):
23    reservation_id: int
24    issue_type: models.SellerIssueType
25    description: str

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
reservation_id: int = PydanticUndefined
issue_type: internal.queries.models.SellerIssueType = PydanticUndefined
description: str = PydanticUndefined
DELETE_SELLER_ISSUE_REPORT = '-- name: delete_seller_issue_report \\:one\nDELETE FROM seller_issue_reports\nWHERE report_id = :p1\nRETURNING report_id, reservation_id, issue_type, description, created_at, status\n'
GET_SELLER_ISSUE_REPORTS = '-- name: get_seller_issue_reports \\:many\nSELECT report_id, reservation_id, issue_type, description, created_at, status FROM seller_issue_reports\n'
GET_SELLER_ISSUE_REPORTS_BY_USER = '-- name: get_seller_issue_reports_by_user \\:many\nSELECT r.report_id, r.reservation_id, r.issue_type, r.description, r.created_at, r.status FROM seller_issue_reports r\nJOIN reservations res ON r.reservation_id = res.reservation_id\nWHERE res.consumer_id = :p1\n'
UPDATE_SELLER_ISSUE_REPORT_STATUS = '-- name: update_seller_issue_report_status \\:one\nUPDATE seller_issue_reports\nSET status = :p2\nWHERE report_id = :p1\nRETURNING report_id, reservation_id, issue_type, description, created_at, status\n'
class UpdateSellerIssueReportStatusParams(pydantic.main.BaseModel):
55class UpdateSellerIssueReportStatusParams(pydantic.BaseModel):
56    report_id: int
57    status: models.IssueStatus

!!! abstract "Usage Documentation" Models

A base class for creating Pydantic models.

Attributes:
  • __class_vars__: The names of the class variables defined on the model.
  • __private_attributes__: Metadata about the private attributes of the model.
  • __signature__: The synthesized __init__ [Signature][inspect.Signature] of the model.
  • __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
  • __pydantic_core_schema__: The core schema of the model.
  • __pydantic_custom_init__: Whether the model has a custom __init__ function.
  • __pydantic_decorators__: Metadata containing the decorators defined on the model. This replaces Model.__validators__ and Model.__root_validators__ from Pydantic V1.
  • __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
  • __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
  • __pydantic_post_init__: The name of the post-init method for the model, if defined.
  • __pydantic_root_model__: Whether the model is a [RootModel][pydantic.root_model.RootModel].
  • __pydantic_serializer__: The pydantic-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used to validate instances of the model.
  • __pydantic_fields__: A dictionary of field names and their corresponding [FieldInfo][pydantic.fields.FieldInfo] objects.
  • __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects.
  • __pydantic_extra__: A dictionary containing extra values, if [extra][pydantic.config.ConfigDict.extra] is set to 'allow'.
  • __pydantic_fields_set__: The names of fields explicitly set during instantiation.
  • __pydantic_private__: Values of private attributes set on the model instance.
report_id: int = PydanticUndefined
status: internal.queries.models.IssueStatus = PydanticUndefined
class AsyncQuerier:
 60class AsyncQuerier:
 61    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
 62        self._conn = conn
 63
 64    async def create_seller_issue_report(self, arg: CreateSellerIssueReportParams) -> Optional[models.SellerIssueReport]:
 65        row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER_ISSUE_REPORT), {"p1": arg.reservation_id, "p2": arg.issue_type, "p3": arg.description})).first()
 66        if row is None:
 67            return None
 68        return models.SellerIssueReport(
 69            report_id=row[0],
 70            reservation_id=row[1],
 71            issue_type=row[2],
 72            description=row[3],
 73            created_at=row[4],
 74            status=row[5],
 75        )
 76
 77    async def delete_seller_issue_report(self, *, report_id: int) -> Optional[models.SellerIssueReport]:
 78        row = (await self._conn.execute(sqlalchemy.text(DELETE_SELLER_ISSUE_REPORT), {"p1": report_id})).first()
 79        if row is None:
 80            return None
 81        return models.SellerIssueReport(
 82            report_id=row[0],
 83            reservation_id=row[1],
 84            issue_type=row[2],
 85            description=row[3],
 86            created_at=row[4],
 87            status=row[5],
 88        )
 89
 90    async def get_seller_issue_reports(self) -> AsyncIterator[models.SellerIssueReport]:
 91        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS))
 92        async for row in result:
 93            yield models.SellerIssueReport(
 94                report_id=row[0],
 95                reservation_id=row[1],
 96                issue_type=row[2],
 97                description=row[3],
 98                created_at=row[4],
 99                status=row[5],
100            )
101
102    async def get_seller_issue_reports_by_user(self, *, consumer_id: int) -> AsyncIterator[models.SellerIssueReport]:
103        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS_BY_USER), {"p1": consumer_id})
104        async for row in result:
105            yield models.SellerIssueReport(
106                report_id=row[0],
107                reservation_id=row[1],
108                issue_type=row[2],
109                description=row[3],
110                created_at=row[4],
111                status=row[5],
112            )
113
114    async def update_seller_issue_report_status(self, arg: UpdateSellerIssueReportStatusParams) -> Optional[models.SellerIssueReport]:
115        row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER_ISSUE_REPORT_STATUS), {"p1": arg.report_id, "p2": arg.status})).first()
116        if row is None:
117            return None
118        return models.SellerIssueReport(
119            report_id=row[0],
120            reservation_id=row[1],
121            issue_type=row[2],
122            description=row[3],
123            created_at=row[4],
124            status=row[5],
125        )
AsyncQuerier(conn: sqlalchemy.ext.asyncio.engine.AsyncConnection)
61    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
62        self._conn = conn
async def create_seller_issue_report( self, arg: CreateSellerIssueReportParams) -> internal.queries.models.SellerIssueReport | None:
64    async def create_seller_issue_report(self, arg: CreateSellerIssueReportParams) -> Optional[models.SellerIssueReport]:
65        row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER_ISSUE_REPORT), {"p1": arg.reservation_id, "p2": arg.issue_type, "p3": arg.description})).first()
66        if row is None:
67            return None
68        return models.SellerIssueReport(
69            report_id=row[0],
70            reservation_id=row[1],
71            issue_type=row[2],
72            description=row[3],
73            created_at=row[4],
74            status=row[5],
75        )
async def delete_seller_issue_report( self, *, report_id: int) -> internal.queries.models.SellerIssueReport | None:
77    async def delete_seller_issue_report(self, *, report_id: int) -> Optional[models.SellerIssueReport]:
78        row = (await self._conn.execute(sqlalchemy.text(DELETE_SELLER_ISSUE_REPORT), {"p1": report_id})).first()
79        if row is None:
80            return None
81        return models.SellerIssueReport(
82            report_id=row[0],
83            reservation_id=row[1],
84            issue_type=row[2],
85            description=row[3],
86            created_at=row[4],
87            status=row[5],
88        )
async def get_seller_issue_reports(self) -> AsyncIterator[internal.queries.models.SellerIssueReport]:
 90    async def get_seller_issue_reports(self) -> AsyncIterator[models.SellerIssueReport]:
 91        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS))
 92        async for row in result:
 93            yield models.SellerIssueReport(
 94                report_id=row[0],
 95                reservation_id=row[1],
 96                issue_type=row[2],
 97                description=row[3],
 98                created_at=row[4],
 99                status=row[5],
100            )
async def get_seller_issue_reports_by_user( self, *, consumer_id: int) -> AsyncIterator[internal.queries.models.SellerIssueReport]:
102    async def get_seller_issue_reports_by_user(self, *, consumer_id: int) -> AsyncIterator[models.SellerIssueReport]:
103        result = await self._conn.stream(sqlalchemy.text(GET_SELLER_ISSUE_REPORTS_BY_USER), {"p1": consumer_id})
104        async for row in result:
105            yield models.SellerIssueReport(
106                report_id=row[0],
107                reservation_id=row[1],
108                issue_type=row[2],
109                description=row[3],
110                created_at=row[4],
111                status=row[5],
112            )
async def update_seller_issue_report_status( self, arg: UpdateSellerIssueReportStatusParams) -> internal.queries.models.SellerIssueReport | None:
114    async def update_seller_issue_report_status(self, arg: UpdateSellerIssueReportStatusParams) -> Optional[models.SellerIssueReport]:
115        row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER_ISSUE_REPORT_STATUS), {"p1": arg.report_id, "p2": arg.status})).first()
116        if row is None:
117            return None
118        return models.SellerIssueReport(
119            report_id=row[0],
120            reservation_id=row[1],
121            issue_type=row[2],
122            description=row[3],
123            created_at=row[4],
124            status=row[5],
125        )