Skip to content

Commit

Permalink
fix update api: require of field should follow the table schema
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisLuii committed Jan 7, 2024
1 parent 533599f commit 63db955
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions src/fastapi_quickcrud_codegen/utils/schema_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def update_one(self) -> Tuple:
if i['column_name'] not in [self.primary_key_str]:
request_body_fields.append((i['column_name'],
i['column_type'],
f"Body(None, description={i['column_description']})"))
f"Body({i['column_default']}, description={i['column_description']})"))

request_query_fields = []
for i in query_param:
Expand Down Expand Up @@ -682,7 +682,7 @@ def update_many(self) -> Tuple:
if i['column_name'] not in [self.primary_key_str]:
request_body_fields.append((i['column_name'],
i['column_type'],
f"Body(None, description={i['column_description']})"))
f"Body({i['column_default']}, description={i['column_description']})"))

request_query_fields = []
for i in query_param:
Expand Down
12 changes: 6 additions & 6 deletions test/special_case/test_memory_db_async_default_crud_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down Expand Up @@ -1272,10 +1272,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down
12 changes: 6 additions & 6 deletions test/special_case/test_no_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down Expand Up @@ -1271,10 +1271,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,10 +1112,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down Expand Up @@ -1273,10 +1273,10 @@ def __post_init__(self):
@dataclass
class TestUuidPrimaryUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
int8_value: int = Body(None, description=None)
Expand Down
14 changes: 7 additions & 7 deletions test/test_memory_db_async_update_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateManyResponseItemModel(BaseModel):
Expand Down Expand Up @@ -365,14 +365,14 @@ def __post_init__(self):
@dataclass
class SampleTableUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int8_value: int = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(10.1, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(99, description=None)
text_value: str = Body(None, description=None)
time_value: time = Body(None, description=None)
timestamp_value: datetime = Body(None, description=None)
Expand Down
14 changes: 7 additions & 7 deletions test/test_memory_db_async_update_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateOneResponseModel(BaseModel):
Expand Down Expand Up @@ -346,14 +346,14 @@ def __post_init__(self):
@dataclass
class SampleTableUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int8_value: int = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(10.1, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(99, description=None)
text_value: str = Body(None, description=None)
time_value: time = Body(None, description=None)
timestamp_value: datetime = Body(None, description=None)
Expand Down
14 changes: 7 additions & 7 deletions test/test_memory_db_sync_update_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateManyResponseItemModel(BaseModel):
Expand Down Expand Up @@ -362,14 +362,14 @@ def __post_init__(self):
@dataclass
class SampleTableUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int8_value: int = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(10.1, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(99, description=None)
text_value: str = Body(None, description=None)
time_value: time = Body(None, description=None)
timestamp_value: datetime = Body(None, description=None)
Expand Down
14 changes: 7 additions & 7 deletions test/test_memory_db_sync_update_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateOneResponseModel(BaseModel):
Expand Down Expand Up @@ -343,14 +343,14 @@ def __post_init__(self):
@dataclass
class SampleTableUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int8_value: int = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(10.1, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(99, description=None)
text_value: str = Body(None, description=None)
time_value: time = Body(None, description=None)
timestamp_value: datetime = Body(None, description=None)
Expand Down
8 changes: 4 additions & 4 deletions test/test_postgresql_db_async_update_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateManyResponseItemModel(BaseModel):
Expand Down Expand Up @@ -391,10 +391,10 @@ class SampleTableUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(None, description=None)
interval_value: timedelta = Body(None, description=None)
json_value: dict = Body(None, description=None)
Expand Down
8 changes: 4 additions & 4 deletions test/test_postgresql_db_async_update_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateOneResponseModel(BaseModel):
Expand Down Expand Up @@ -372,10 +372,10 @@ class SampleTableUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(None, description=None)
interval_value: timedelta = Body(None, description=None)
json_value: dict = Body(None, description=None)
Expand Down
8 changes: 4 additions & 4 deletions test/test_postgresql_db_sync_update_many.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateManyResponseItemModel(BaseModel):
Expand Down Expand Up @@ -394,10 +394,10 @@ class SampleTableUpdateManyRequestBodyModel:
bool_value: bool = Body(None, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(None, description=None)
interval_value: timedelta = Body(None, description=None)
json_value: dict = Body(None, description=None)
Expand Down
8 changes: 4 additions & 4 deletions test/test_postgresql_db_sync_update_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def __post_init__(self):
@dataclass
class SampleTableTwoUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
bool_value: bool = Body(False, description=None)
class SampleTableTwoUpdateOneResponseModel(BaseModel):
Expand Down Expand Up @@ -375,10 +375,10 @@ class SampleTableUpdateOneRequestBodyModel:
bool_value: bool = Body(None, description=None)
char_value: str = Body(None, description=None)
date_value: date = Body(None, description=None)
float4_value: float = Body(None, description=None)
float4_value: float = Body(..., description=None)
float8_value: float = Body(None, description=None)
int2_value: int = Body(None, description=None)
int4_value: int = Body(None, description=None)
int2_value: int = Body(..., description=None)
int4_value: int = Body(..., description=None)
int8_value: int = Body(None, description=None)
interval_value: timedelta = Body(None, description=None)
json_value: dict = Body(None, description=None)
Expand Down

0 comments on commit 63db955

Please sign in to comment.