From 8b6e32145c1a6fb45c4983f3d63605ca8d94c8dd Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 30 Nov 2024 16:06:37 -0600 Subject: [PATCH] fix: let caller set data type for `uuid_column()` and `uuid_fk_column()` and rattail now sets the data type, so we should be more free to experiment with UUID data type --- src/wuttjamaican/db/util.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wuttjamaican/db/util.py b/src/wuttjamaican/db/util.py index 88362c4..30f9f82 100644 --- a/src/wuttjamaican/db/util.py +++ b/src/wuttjamaican/db/util.py @@ -61,10 +61,12 @@ def uuid_column(*args, **kwargs): """ Returns a UUID column for use as a table's primary key. """ + if not args: + args = (sa.String(length=32),) kwargs.setdefault('primary_key', True) kwargs.setdefault('nullable', False) kwargs.setdefault('default', make_uuid) - return sa.Column(sa.String(length=32), *args, **kwargs) + return sa.Column(*args, **kwargs) def uuid_fk_column(target_column, *args, **kwargs): @@ -74,4 +76,6 @@ def uuid_fk_column(target_column, *args, **kwargs): :param target_column: Name of the table column on the remote side, e.g. ``'user.uuid'``. """ - return sa.Column(sa.String(length=32), sa.ForeignKey(target_column), *args, **kwargs) + if not args: + args = (sa.String(length=32), sa.ForeignKey(target_column)) + return sa.Column(*args, **kwargs)