[Sqlalchemy-tickets] Issue #3971: Unicode Comparison Warning (zzzeek/sqlalchemy)
Brought to you by:
zzzeek
From: Lukas S. <iss...@bi...> - 2017-04-25 00:51:11
|
New issue 3971: Unicode Comparison Warning https://bitbucket.org/zzzeek/sqlalchemy/issues/3971/unicode-comparison-warning Lukas Siemon: Getting a warning ```shell .../env/local/lib/python2.7/site-packages/sqlalchemy/sql/type_api.py:359: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal return x == y ``` Unfortunately we treat warnings as exceptions, so I'm kind of stuck here. This seems like a problem with SQLAlchemy? Any advice what best to do here? Test Case: ```python # coding=utf-8 import unittest from sqlalchemy import Column, String, text, inspect from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.ext.declarative import declarative_base from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = ( 'postgres://postgres:password@localhost:5432/tmp') app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True db = SQLAlchemy(app) Base = declarative_base() class Test(db.Model): __tablename__ = 'test' id = Column(UUID, primary_key=True, nullable=False, server_default=text('uuid_generate_v4()')) name = Column(String, nullable=False) db.create_all() class TestClass(unittest.TestCase): def test_function(self): test = Test(name="♥ This") db.session.add(test) db.session.commit() db.session.expire_all() test = Test.query.filter_by(name="♥ This").first() test.name = "Still ♥ This!" inspected = inspect(test) assert getattr(inspected.attrs, 'name').history.has_changes() ``` |