-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support setting table and column comments to NULL
#345
Conversation
uhm, I think the need for quotes is quite unexpected as a user. Wouldn't be enough to pass a |
Passing
In the case of comments, the only two values allowed are literal strings or We have some options:
|
After some more experimentation, allowing It requires an upstream change to go-jsonschema in order to emit the This would mean users could specify either:
or
without having to enclose |
a86846d
to
068252d
Compare
I like this one! Wondering if we could do the same for others. roping @eemmiillyy @SferaDev for thoughts on the json schema |
schema.json
Outdated
"type": "string", | ||
"goJSONSchema": { | ||
"imports": ["github.com/oapi-codegen/nullable"], | ||
"nillable": true, | ||
"type": "nullable.Nullable[string]" | ||
} |
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.
The problem with using type: ["string", "null"]
is that it generates the Go type:
Comment *string `json:"name"
which doesn't allow us to distinguish between the case where the 'alter column' comment
field is specified and set to null
, vs left unspecified.
See #345 (comment)
Using nullable.Nullable
allows us to distinguish the 'set to null' and the 'unspecified' cases.
schema.json
Outdated
@@ -159,7 +159,12 @@ | |||
}, | |||
"comment": { | |||
"description": "New comment on the column", | |||
"type": "string" | |||
"type": "string", |
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.
"type": "string", | |
"type": ["string", "null"], |
0dfcd2a
to
9f74b91
Compare
I think this is ready now. The upstream change to I've updated the PR description: Build on #344 to allow removing column comments by setting them to Make use of omissis/go-jsonschema#220 and use the nullable package so that it's possible to distingush between a missing With omissis/go-jsonschema#220 not being part of a release yet, use a custom build of Without this change it becomes impossible to remove a comment from a column using the 'set comment' 'alter column' sub-operation (#344). |
What do you mean by this @exekias? I don't think the same approach makes sense for setting It makes sense for |
We also need to approve the PR on which this one is based: #344 |
Ensure that leaving the comment unspecified in an alter column statement does not change the comment.
Allow unrecognized properties in the schema definition. This allows the `goJSONSchema` extension keyword. See: https://ajv.js.org/strict-mode.html#prohibit-ignored-keywords
9f74b91
to
b16c7c6
Compare
Build on #344 to allow removing column comments by setting them to
null
.Make use of omissis/go-jsonschema#220 and use the nullable package so that it's possible to distingush between a missing
comment
field and one that is explicitly set tonull
.With omissis/go-jsonschema#220 not being part of a release yet, use a custom build of
go-jsonschema
. It should be possible to switch back to the official release images once omissis/go-jsonschema#220 is part of a release.Without this change it becomes impossible to remove a comment from a column using the 'set comment' 'alter column' sub-operation (#344).