-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Feat/plugins schemas to new db #3778
Conversation
64bb88b
to
6675897
Compare
aedbf57
to
aa8742b
Compare
13954de
to
6db701c
Compare
Reviewing commit by commit! Leaving a note here since there is no "general comment on commit": please rename |
kong/db/schema/init.lua
Outdated
@@ -270,6 +270,9 @@ Schema.validators = { | |||
end, | |||
|
|||
uuid = function(value) | |||
if value == "" then | |||
return true | |||
end |
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 does look odd, and the commit says "Check if this is needed"... which plugin test needs this to pass?
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.
Looks like this is related to config.anonymous
. I see you added is_present
in the plugins to support both ""
and ngx.null
, I guess to avoid a migration (always a good goal!).
I wonder if we could get rid of these empty strings via process_auto_fields
instead. Perhaps with a legacy
annotation?
-- in process_auto_fields (for field.auto == false case only)
if field.legacy and field.uuid and output[key] == "" then
output[key] == ngx.null
end
This would always clean up the data once it comes from the DB (it's a bit of a "migration transformation"). The plugins wouldn't need the is_present
tests and this change to the uuid
validator wouldn't be necessary (ie, we'd avoid messing up all UUID fields because of anonymous
). What do you think?
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.
I like that! It didn't occur to me to do it that way.
kong/db/schema/init.lua
Outdated
output[key] = utils.random_string() | ||
end | ||
end | ||
|
||
if context == "update" then | ||
output[key] = adjust_field_for_update(field, output[key], nulls) | ||
|
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.
minor: the style guide says this is not necessary for one-liner if/then/else blocks
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.
ok removed that one
fields = { | ||
{ whitelist = { | ||
type = "array", | ||
elements = { type = "string", is_regex = true, match = ".*" }, |
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.
I understand this match
rule was already present in the old schema, but it does nothing useful ("match zero or more of any character"), right?
The "pr" build of Travis seems to be failing over and over in the C*2 integration job with a weird error in the datadog test suite. Currently the are conflicts with |
d0f00b4
to
a6880cd
Compare
a6880cd
to
4cb6341
Compare
4cb6341
to
131a8f1
Compare
131a8f1
to
23169b5
Compare
23169b5
to
9f7bc77
Compare
9f7bc77
to
df89f46
Compare
4fac07c
to
eb91de2
Compare
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.
All set, but waiting for master
to be merged into next
so we can remove the tests(helpers)
workaround on this
Entities already had non-nullable records by default since 30789e7. However, plugin subschemas did not go through the same preprocessing. This adds a new function `Entity.new_subschema` that performs that same preprocessing.
We cannot use `between' because sometimes the condition is non-inclusive (`gt = 0` does not include 0)
This calls `handle_missing_value` when propagating defaults for records so that non-nullable records (as in Entities) get their sub-tables created. Also refactors both adjustment functions into one (the original version of this patch missed the other function, so this avoids it happening again). Co-authored-by: Enrique García Cota <[email protected]>
UUIDs created with the old schema stored an empty string to mean "value not present". We now use an explicit `null` for that. This `legacy` annotation allows the schema library to transform existing rows stored in the old format to use the new format transparently. Co-authored-by: Hisham Muhammad <[email protected]>
eb91de2
to
9e0d1c4
Compare
Merged with a merge commit, as we do for major changes |
No description provided.