Flask-sqlalchemy database limits field length, why is it intercepted?

problem description

when inserting data, username I pass 11 digits, such as 12345678901, the database only stores 1234567890, the first ten digits are intercepted by default,
my String (10) is set to 10

the environmental background of the problems and what methods you have tried

I can"t think of any good method for the time being

related codes

/ / Please paste the code text below (do not replace the code with pictures)

from port import db
class User (db.Model):

__tablename__ = "b_user"
id = db.Column(db.Integer,primary_key=True )
username = db.Column(db.String(10),unique=True,index=True, nullable=False)
password = db.Column(db.String(16))

def __init__(self,username,password):
    self.username  = username
    self.password = password
def __repr__(self):
    return "<User %r>" % self.username
def __json__(self):
    return ["id", "username", "password"]

what result do you expect? What is the error message actually seen?

I expect that the insertion string is too long, need to report an exception, can not be inserted into the database, ask the bosses to give a solution! Thank you very much

Mar.30,2021
The problem of

is not the problem of flask-sqlalchemy , but the problem of database configuration
mysql configuration has a strict mode called strict mode , which is used to check whether the data type and data length match, and so on.
after you turn it on, if the length is too long, it will report an error instead of intercepting input.
but there is a problem, you should be careful when opening this online, because you are not sure whether it is unreasonable to pass parameters in other code blocks.
so either at the beginning of the project, both the development environment and the production environment open strict mode ~

Menu