-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add uuid and enum support to malli schema generator #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙇🏻
@@ -9,7 +10,8 @@ | |||
:clob 'string? | |||
:text 'string? | |||
:varchar 'string? | |||
:timestamp 'inst?}) | |||
:timestamp 'inst? | |||
:uuid 'uuid?}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one-liner for uuid
support
(and (= :integer column-type) primary-key?) | ||
(:integer-pk column-types) | ||
|
||
;; :enum type definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main change for enum
support:
I'm assuming here that types will always be identifyable by the pattern [schema].[name]
which might not be 100% accurate? I think it will for for our case in PSQL but I'm not sure about other databases. Not sure if we can really upstream this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this doesn't seem like the best way to identify enums, but I currently don't have any better ideas either. Maybe add a comment here to make it clear that we are saying any column type with a .
is an enum.
(and (= :integer column-type) primary-key?) | ||
(:integer-pk column-types) | ||
|
||
;; :enum type definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this doesn't seem like the best way to identify enums, but I currently don't have any better ideas either. Maybe add a comment here to make it clear that we are saying any column type with a .
is an enum.
add a generator for datapotato schema
With this patch
malli-schema
will generate correct entries foruuid
columns and produce correctenum
definitions for custom types under the condition that you have to pass in your type definitions.It would be great if we could have the
xray
extract all the present type definitions for the database like it does with the table information. I tried that by adding something like:and have the results saved within the
xray
besides:tables
as:types
, but when invokedgetSuperTypes
says it is not implemented. Might have used the wrong Java function, but that one looked to be the best fit.So for the enums you would have to do something like this:
Interface could be prettier, but for a first version it does the trick.