Jason Libbey
2016-07-30 01:45:01 UTC
Hi, this is my first post, so if it does not adhere by your guidelines,
please let me know and I'll fix it ASAP.
I'm using the sqlalchemy_utils.UUIDType as per backend-agnostic-guid-type
<http://docs.sqlalchemy.org/en/latest/core/custom_types.html#backend-agnostic-guid-type>
.
from sqlalchemy_utils import UUIDType
class ApplicationStore(Base, Timestamp):
__tablename__ = 'applications'
id = Column(UUIDType(binary=False), primary_key=True, default=uuid.uuid4)
user_uuid = Column(UUIDType(binary=False), unique=True, index=True, nullable=False)
Since I am using a mysql db, the UUIDType is correctly falling back to the
CHAR32 representation. However, the value that gets written to the db is
the uuid with no dashes.
application = application_service.create(user_uuid=uuid.uuid4())
The string representation of the uuid shows it with dashes, but the
database char is saved without dashes. So my questions are:
1. Am I using this correctly?
2. Is this the expected behavior?
3. How can I force it to save as uuid with dashes, while still using the
backend agnostic guid type?
Python version: 2.7.10
SQLAlchemy version: 1.0.12
please let me know and I'll fix it ASAP.
I'm using the sqlalchemy_utils.UUIDType as per backend-agnostic-guid-type
<http://docs.sqlalchemy.org/en/latest/core/custom_types.html#backend-agnostic-guid-type>
.
from sqlalchemy_utils import UUIDType
class ApplicationStore(Base, Timestamp):
__tablename__ = 'applications'
id = Column(UUIDType(binary=False), primary_key=True, default=uuid.uuid4)
user_uuid = Column(UUIDType(binary=False), unique=True, index=True, nullable=False)
Since I am using a mysql db, the UUIDType is correctly falling back to the
CHAR32 representation. However, the value that gets written to the db is
the uuid with no dashes.
application = application_service.create(user_uuid=uuid.uuid4())
The string representation of the uuid shows it with dashes, but the
database char is saved without dashes. So my questions are:
1. Am I using this correctly?
2. Is this the expected behavior?
3. How can I force it to save as uuid with dashes, while still using the
backend agnostic guid type?
Python version: 2.7.10
SQLAlchemy version: 1.0.12
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.