user-defined function from int to string gives ValueError when printed
Peewee looks at the field type when converting values coming back from the DB. What version of Peewee are you using, by chance? In more recent versions, the conversion logic was made a little bit more forgiving, allowing fallback to the original value.

This works, for ex:

```python
db = SqliteDatabase(':memory:')

class Num(Model):
    val = IntegerField()
    class Meta:
        database = db

@db.func()
def to_s(n):
    return {
        0: 'zero',
        1: 'one',
        2: 'two'}.get(n, 'too many')

Num.create_table()
Num.insert_many([(i,) for i in range(4)]).execute()

query = (Num
         .select(fn.to_s(Num.val).alias('val'))
         .order_by(Num.val))
for row in query:
    print(row.val)
# zero
# one
# two
# too many
```

For older versions, you can try:

```python
fn.to_dna(Base.abase, coerce=False)
``` > Then I tried casting as blob but I get zeros. query2() gives [{'abase") AS NONE)': 0},...

You might note that the key of the dict is all messed up. Sqlite does not give very helpful column names when you are selecting a function or something and do not provide an alias. You probably want to do:

```python
fn.to_dna(Base.abase).alias('dna')
```

So you can access it using a nice name. > I basically want to save space by storing an int instead of a char but then be able to print it back easily. Any advice? Thank you.

An integer takes up 8 bytes (sqlite uses 64-bit integers). A char takes up a single byte. So you might rethink that as well...because your decision is 8x more wasteful. Oh dear! thanks a lot for the advice.
Setup:

    from enum import Enum
    from peewee import *
    from playhouse.sqlite_ext import SqliteExtDatabase
    DNA = Enum('DNA', {"N":-1, "A":1, "T":2, "C":3, "G":4})
    db = Proxy()

    def toDNA(n):
        return DNA(n).name.upper()

    class Base(Model):
        abase = IntegerField(default=-1) # DNA
        class Meta:
            database = db

    def setupDB():
        dbs = SqliteExtDatabase("foo")
        db.initialize(dbs)
        db.connect(reuse_if_open=True)
        db.create_tables([Base], safe=True)
        db.register_function(toDNA, "to_dna", 1)
        # add dummy data
        Base.create(abase="-1")
        Base.create(abase="4")

    def query():
        return list(Base.select(fn.to_dna(Base.abase)).dicts())

    def query2():
        return list(Base.select(fn.to_dna(Base.abase).cast('NONE')).dicts())

If I run `query()` I get `invalid literal for int() with base 10: 'N'`
Then I tried casting as blob but I get zeros. `query2()` gives `[{'abase") AS NONE)': 0},`...

I basically want to save space by storing an int instead of a char but then be able to print it back easily. Any advice? Thank you.
