diff --git a/.gitignore b/.gitignore
index 6e0d4e46..b348417c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ playhouse/_speedups.so
 playhouse/tests/peewee_test.db
 .idea/
 MANIFEST
+peewee_test.db
diff --git a/peewee.py b/peewee.py
index 827d0896..c910682d 100644
--- a/peewee.py
+++ b/peewee.py
@@ -1038,7 +1038,12 @@ class UUIDField(Field):
     db_field = 'uuid'
 
     def db_value(self, value):
-        return None if value is None else str(value)
+        if isinstance(value, uuid.UUID):
+            return value.hex
+        try:
+            return uuid.UUID(value).hex
+        except:
+            return value
 
     def python_value(self, value):
         return None if value is None else uuid.UUID(value)
@@ -3751,6 +3756,7 @@ class MySQLDatabase(Database):
         'float': 'FLOAT',
         'primary_key': 'INTEGER AUTO_INCREMENT',
         'text': 'LONGTEXT',
+        'uuid': 'LONGTEXT'
     }
     for_update = True
     interpolation = '%s'

Better support for UUIDField
As an extension from #780, databases which don't support UUID natively may encounter consistency problems. 

Postgres will correctly handle multiple input variants [\[1\]][1], such as
`a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11` and `a0eebc999c0b4ef8bb6d6bb9bd380a11`.

However SQLite, which now uses `TEXT` since #780, does not support multiple input types properly, and will end up with different variants being stored in the backend, rather than being normalised. Other databases, such as MySQL, are not supported at all as they don't have the necessary `field_overrides`.

The most viable fix I can see for this would be;

```py
class UUIDField(Field):
    ...
    def db_value(self, value):
        if isinstance(value, uuid.UUID):
            return value.hex
        try:
            return uuid.UUID(value).hex
        except:
            return value
```

The above would ensure that the UUID output is always consistent, whilst also allowing non confirming values to be used with `filter()`, e.g. `0f0f0f0f-` 

I'd also like to propose that we add a `field_override` for `MySQLDatabase`, much the same as `SqliteDatabase`.

If you're happy with the above solution, I'll throw up a PR, let me know


[1]: http://www.postgresql.org/docs/9.1/static/datatype-uuid.html
diff --git a/playhouse/tests/test_fields.py b/playhouse/tests/test_fields.py
index a9cfbcaf..1af7ee50 100644
--- a/playhouse/tests/test_fields.py
+++ b/playhouse/tests/test_fields.py
@@ -726,7 +726,6 @@ class TestServerDefaults(ModelTestCase):
         self.assertEqual(sd2_db.timestamp, datetime.datetime(2015, 1, 2, 3, 4))
 
 
-@skip_if(lambda: isinstance(test_db, MySQLDatabase))
 class TestUUIDField(ModelTestCase):
     requires = [
         TestingID,
@@ -745,6 +744,29 @@ class TestUUIDField(ModelTestCase):
         t2 = TestingID.get(TestingID.uniq == uuid_obj)
         self.assertEqual(t1, t2)
 
+    def test_uuid_casting(self):
+        uuid_obj = uuid.UUID('a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11')
+        uuid_str = uuid_obj.hex
+        uuid_str_short = uuid_str.replace("-", "")
+
+        t1 = TestingID.create(uniq=uuid_obj)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str_short)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+
+        t1 = TestingID.create(uniq=uuid_str)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str_short)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+
+        t1 = TestingID.create(uniq=uuid_str_short)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+        t1_db = TestingID.get(TestingID.uniq == uuid_str_short)
+        self.assertEqual(t1_db.uniq, uuid_obj)
+
     def test_uuid_foreign_keys(self):
         data_a = UUIDData.create(id=uuid.uuid4(), data='a')
         data_b = UUIDData.create(id=uuid.uuid4(), data='b')

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest Cython
apt-get update apt-get install -y gcc
3.9
requirements/base.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
Cython==3.0.12
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
-e git+https://github.com/coleifer/peewee.git@f424cd64352ecc799c3c2d60aafe17dbb30f58ef#egg=peewee
pluggy==1.5.0
pytest==8.3.5
tomli==2.2.1

name: peewee
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - cython==3.0.12
      - exceptiongroup==1.2.2
      - iniconfig==2.1.0
      - packaging==24.2
      - pluggy==1.5.0
      - pytest==8.3.5
      - tomli==2.2.1
prefix: /opt/conda/envs/peewee

playhouse/tests/test_fields.py::TestFieldTypes::test_null_query playhouse/tests/test_fields.py::TestFieldTypes::test_regexp playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_date playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_date_where playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_datetime playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_datetime_where playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_time playhouse/tests/test_fields.py::TestDateTimeExtract::test_extract_time_where playhouse/tests/test_fields.py::TestUniqueColumnConstraint::test_multi_index playhouse/tests/test_fields.py::TestUniqueColumnConstraint::test_unique playhouse/tests/test_fields.py::TestNonIntegerPrimaryKey::test_non_int_fk playhouse/tests/test_fields.py::TestNonIntegerPrimaryKey::test_non_int_pk playhouse/tests/test_fields.py::TestPrimaryKeyIsForeignKey::test_pk_fk_relations playhouse/tests/test_fields.py::TestPrimaryKeyIsForeignKey::test_primary_foreign_key playhouse/tests/test_fields.py::TestFieldDatabaseColumn::test_db_column playhouse/tests/test_fields.py::TestFieldDatabaseColumn::test_select playhouse/tests/test_fields.py::TestUUIDField::test_uuid_casting
playhouse/tests/test_fields.py::TestFieldTypes::test_between playhouse/tests/test_fields.py::TestFieldTypes::test_endswith playhouse/tests/test_fields.py::TestFieldTypes::test_in_ playhouse/tests/test_fields.py::TestFieldTypes::test_startswith playhouse/tests/test_fields.py::TestFieldTypes::test_blob_field playhouse/tests/test_fields.py::TestFieldTypes::test_contains playhouse/tests/test_fields.py::TestFieldTypes::test_date_and_time_fields playhouse/tests/test_fields.py::TestFieldTypes::test_date_as_string playhouse/tests/test_fields.py::TestFieldTypes::test_field_types playhouse/tests/test_fields.py::TestFieldTypes::test_fixed_charfield playhouse/tests/test_fields.py::TestFieldTypes::test_floatfield playhouse/tests/test_fields.py::TestFieldTypes::test_intfield playhouse/tests/test_fields.py::TestFieldTypes::test_time_field_python_value playhouse/tests/test_fields.py::TestFieldTypes::test_various_formats playhouse/tests/test_fields.py::TestSQLiteDatePart::test_sqlite_date_part
playhouse/tests/test_fields.py::TestFieldTypes::test_concat playhouse/tests/test_fields.py::TestFieldTypes::test_decimalfield playhouse/tests/test_fields.py::TestSQLiteDateTrunc::test_sqlite_date_trunc playhouse/tests/test_fields.py::TestCheckConstraints::test_check_constraint playhouse/tests/test_fields.py::TestServerDefaults::test_server_default playhouse/tests/test_fields.py::TestUUIDField::test_prefetch_regression playhouse/tests/test_fields.py::TestUUIDField::test_uuid playhouse/tests/test_fields.py::TestUUIDField::test_uuid_foreign_keys
.gitignore peewee.py
.gitignore peewee.py