First Check
Commit to Help
Example Code
from sqlalchemy import BigInteger
from typing import Optional
from sqlmodel import Field, Session, SQLModel, create_engine
class Hero(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
#case A
normhash: Optional[int] = Field(default=None, index=True)
#case B
#normhash: Optional[BigInteger] = Field(default=None, index=True)
hero_1 = Hero(normhash=1559512409891417611)
engine = create_engine("postgresql://app:newbpw@somehost:5400/some_db)
SQLModel.metadata.create_all(engine)
with Session(engine) as session:
session.add(hero_1)
session.commit()
# in case A: DataError: (psycopg2.errors.NumericValueOutOfRange) integer out of range
# (case B the code won't even finish coming up - no validator error)
session.refresh(hero_1)
print(hero_1)
Description
Using your default Hero example.
Replace the fields with a hash field.
Using postgres, I'm unable to set up the field for big integers. Case A: using standard int results in NumericValueOutOfRange at the psycopg2 level.
So, case B: trying to force a postgres BIGINT, using sqlalchemy BigInteger, I get:
File "pydantic/validators.py", line 715, in find_validators
RuntimeError: no validator found for <class 'sqlalchemy.sql.sqltypes.BigInteger'>, see arbitrary_types_allowed in Config
I know it involves all the different levels, but it seems like a model of use problem (and I had validator problems before that ended up being a change in the way I use sqlmodel.)
Thanks for your creation of sqlmodel - so far I've really enjoyed it along with fastapi!
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.8.12
Additional Context
No response
First Check
Commit to Help
Example Code
Description
Using your default Hero example.
Replace the fields with a hash field.
Using postgres, I'm unable to set up the field for big integers. Case A: using standard int results in NumericValueOutOfRange at the psycopg2 level.
So, case B: trying to force a postgres BIGINT, using sqlalchemy BigInteger, I get:
File "pydantic/validators.py", line 715, in find_validators
RuntimeError: no validator found for <class 'sqlalchemy.sql.sqltypes.BigInteger'>, see
arbitrary_types_allowedin ConfigI know it involves all the different levels, but it seems like a model of use problem (and I had validator problems before that ended up being a change in the way I use sqlmodel.)
Thanks for your creation of sqlmodel - so far I've really enjoyed it along with fastapi!
Operating System
Linux
Operating System Details
No response
SQLModel Version
0.0.4
Python Version
3.8.12
Additional Context
No response