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
New function check_cardinality()
#15
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.
Good idea.
-
Do we need an
is_cardinality...()
for eachcheck_cardinality()
, would that remove the need for averbose
argument? -
What would be a return value that works for both humans and machines? A number with a string-valued attribute perhaps?
ct <- enquo(child_table) | ||
fkc <- enexpr(fk_column) | ||
|
||
check_key(!!pt, !!pkc) |
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.
Does this abort the function if not a primary key?
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.
Yes, but this is intended (parent table has to have a primary key; this needs to be adapted as soon as compound keys are supported)
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.
Before moving on, let's investigate (in a new branch) if is_cardinality_...()
functions will make the implementation easier.
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.
Alright, but would you like to generally avoid the verbose
argument, also in check_if_subset()
and check_set_equality()
? In this case we might need a more basic version of these two functions, which would be called by their counterparts, right? We could then use those basic functions for is_cardinality...()
.
Is that how you intended this?
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.
Yes, the verbose
argument won't be necessary then.
I'm not sure why we settled for exceptions, but with the new check_cardinality()
function it seems like we really should go for functions that check without throwing exceptions. I'd like to play with that code myself first.
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 refactored and removed the verbose
-argument
Co-Authored-By: Kirill Müller <krlmlr@users.noreply.github.com>
315d11a
to
57650f2
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.
Looks good, thanks!
parent_table$pk_col
andchild_table$fk_col