Skip to content
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

[nexus] Make 'update_and_check' CTE explicitly request columns #4572

Merged
merged 2 commits into from
Nov 29, 2023
Merged

Conversation

smklein
Copy link
Collaborator

@smklein smklein commented Nov 29, 2023

Related to #4570 , but not a direct fix for it

This PR removes a usage of ".*" from a SQL query. Using ".*" in sql queries is somewhat risky -- it makes an implicit dependency on order, and can make backwards compatibility difficult in certain circumstances.

Instead, this PR provides a ColumnWalker, for converting a tuple of columns to an iterator, and requests the expected columns explicitly.

Comment on lines 33 to 35
// TODO: don't convert to vec? You'll need to figure
// out how to state the type of IntoIter.
[$($column::NAME,)+].to_vec().into_iter()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to turn this into the following

Suggested change
// TODO: don't convert to vec? You'll need to figure
// out how to state the type of IntoIter.
[$($column::NAME,)+].to_vec().into_iter()
[$($column::NAME,)+].into_iter()

... but this would require changing:

type IntoIter = std::vec::IntoIter<Self::Item>;

Into:

type IntoIter = std::array::IntoIter<Self::Item, N>;

I don't know how to specify the type of "N" here, even though it should be knowable -- it's the length of $column.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either of the first two options in https://danielkeep.github.io/tlborm/book/blk-counting.html would be fine. A better approach would be rust-lang/rust#83527 which isn't stable yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually in this case you can just pass in the length as an argument to impl_column_walker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call, I'll pass the length explicitly.

@smklein smklein requested a review from sunshowers November 29, 2023 02:12
Copy link
Contributor

@sunshowers sunshowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@smklein smklein enabled auto-merge (squash) November 29, 2023 19:09
@smklein smklein merged commit a4e1216 into main Nov 29, 2023
19 of 20 checks passed
@smklein smklein deleted the no-star branch November 29, 2023 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants