cms icon indicating copy to clipboard operation
cms copied to clipboard

Default value in Column definition doesn't work when function

Open stefano-maggiolo opened this issue 7 years ago • 0 comments

For example, in User.password:

s = Session()
s.add(User(username="k", first_name="'", last_name="p"))
s.commit()

ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'function' [SQL: 'INSERT INTO users (first_name, last_name, username, password, email, timezone, preferred_languages) VALUES (%(first_name)s, %(last_name)s, %(username)s, %(password)s, %(email)s, %(timezone)s, %(preferred_languages)s) RETURNING users.id'] [parameters: {'first_name': "'", 'last_name': 'p', 'username': 'k', 'password': <function User. at 0x7f7812a0d378>, 'email': None, 'timezone': None, 'preferred_languages': []}]

stefano-maggiolo avatar Feb 28 '18 15:02 stefano-maggiolo