def sql2py(converter, val):
     if not isinstance(val, buffer):
         try: val = buffer(val)
         except: pass
     elif PY2 and converter.attr is not None and converter.attr.is_part_of_unique_index:
         try: hash(val)
         except TypeError:
             val = buffer(val)
     return val
Example #2
0
 def sql2py(converter, val):
     if not isinstance(val, buffer):
         try:
             val = buffer(val)
         except:
             pass
     return val
Example #3
0
 def sql2py(converter, val):
     if not isinstance(val, buffer) or \
             (PY2 and converter.attr.pk_offset is not None and 'read-write' in repr(val)):  # Issue 355
         try:
             val = buffer(val)
         except:
             pass
     return val
    def test_1(self):
        db = orm.Database('sqlite', ':memory:')

        class Buf(db.Entity):
            pk = orm.PrimaryKey(buffer)

        db.generate_mapping(create_tables=True)

        x = buffer(b'123')

        with orm.db_session:
            Buf(pk=x)
            orm.commit()

        with orm.db_session:
            t = Buf[x]
 def py2sql(converter, val):
     return buffer(val.bytes)
 def validate(converter, val, obj=None):
     if isinstance(val, buffer): return val
     if isinstance(val, str): return buffer(val)
     throw(TypeError, "Attribute %r: expected type is 'buffer'. Got: %r" % (converter.attr, type(val)))
Example #7
0
 def sql2py(converter, val):
     return buffer(val.read())
 def sql2py(converter, val):
     if not isinstance(val, buffer): val = buffer(val)
     return val
 def sql2py(converter, val):
     return buffer(val.read())
 def py2sql(converter, val):
     return buffer(val.bytes)
 def sql2py(converter, val):
     if not isinstance(val, buffer): val = buffer(val)
     return val
 def validate(converter, val):
     if isinstance(val, buffer): return val
     if isinstance(val, str): return buffer(val)
     throw(TypeError, "Attribute %r: expected type is 'buffer'. Got: %r" % (converter.attr, type(val)))