allow uuid_format add more tests and update docs
This commit is contained in:
@ -251,11 +251,21 @@ You can use either `length` and `precision` parameters or `max_digits` and `deci
|
||||
|
||||
### UUID
|
||||
|
||||
`UUID()` has no required parameters.
|
||||
`UUID(uuid_format: str = 'hex')` has no required parameters.
|
||||
|
||||
* Sqlalchemy column: `ormar.UUID` based on `sqlalchemy.CHAR` field
|
||||
* Sqlalchemy column: `ormar.UUID` based on `sqlalchemy.CHAR(36)` or `sqlalchemy.CHAR(32)` field (for string or hex format respectively)
|
||||
* Type (used for pydantic): `uuid.UUID`
|
||||
|
||||
`uuid_format` parameters allow 'hex'(default) or 'string' values.
|
||||
|
||||
Depending on the format either 32 or 36 char is used in the database.
|
||||
|
||||
Sample:
|
||||
* 'hex' format value = "c616ab438cce49dbbf4380d109251dce" (CHAR(32))
|
||||
* 'string' value = "c616ab43-8cce-49db-bf43-80d109251dce" (CHAR(36))
|
||||
|
||||
When loaded it's always python UUID so you can compare it and compare two formats values between each other.
|
||||
|
||||
[relations]: ./relations.md
|
||||
[queries]: ./queries.md
|
||||
[pydantic]: https://pydantic-docs.helpmanual.io/usage/types/#constrained-types
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
# 0.6.0
|
||||
# 0.5.4
|
||||
|
||||
* **Breaking** Changed `UUID` field that was trimmed to 32 chars (without dashes) instead of 36 (with dashes)
|
||||
to more in line with other libraries.
|
||||
* Allow to pass `uuid_format` (allowed 'hex'(default) or 'string') to `UUID` field to change the format in which it's saved.
|
||||
By default field is saved in hex format (trimmed to 32 chars (without dashes)), but you can pass
|
||||
format='string' to use 36 (with dashes) instead to adjust to existing db or other libraries.
|
||||
Sample:
|
||||
hex value = c616ab438cce49dbbf4380d109251dce
|
||||
string value = c616ab43-8cce-49db-bf43-80d109251dce
|
||||
|
||||
# 0.5.3
|
||||
|
||||
|
||||
Reference in New Issue
Block a user