-
-
Notifications
You must be signed in to change notification settings - Fork 821
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the SQLModel documentation, with the integrated search.
- I already searched in Google "How to X in SQLModel" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to SQLModel but to Pydantic.
- I already checked if it is not related to SQLModel but to SQLAlchemy.
Commit to Help
- I commit to help with one of those options 👆
Example Code
from typing import Any, Callable, Optional, Union
import orjson
from sqlalchemy.types import Unicode
from sqlmodel import Field, SQLModel
__all__ = (
"create",
"read",
"update",
"data",
)
def orjson_dumps(value: Any, *, default: Callable[[Any], Union[Any, None]]) -> str:
return orjson.dumps(value, default=default).decode()
class basemodel(SQLModel):
class Config(SQLModel.Config):
json_loads = orjson.loads
json_dumps = orjson_dumps
class base(basemodel):
name: str = Field(
..., index=False, nullable=False, sa_column_kwargs={"type_": Unicode}
)
json_data: str = Field(
..., index=False, nullable=False, sa_column_kwargs={"type_": Unicode}
)
class create(base):
pass
class update(base):
pass
class read(base):
pass
class data(base, table=True):
id: Optional[int] = Field(default=None, primary_key=True)Description
In mssql, the names and json_data columns are made of varchar.
Since I want an nvarchar column, I specified type_ separately in the sa_column_kwargs option.
However, I confirmed that an error occurred in sqlalchemy.
This error seems to occur when the positional argumet and keyword argumet for type_ overlap.
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/schema.py", line 1586, in __init__
raise exc.ArgumentError(
sqlalchemy.exc.ArgumentError: May not pass type_ positionally and as a keyword.
In this case, I would appreciate it if you could tell me what to do.
Operating System
Linux
Operating System Details
in docker,
image: python:3.9-buster
SQLModel Version
0.0.4
Python Version
3.9.8
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested