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

Remove unused table pair impls #5362

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dullbananas
Copy link
Collaborator

The allow_tables_to_appear_in_same_query macro implements traits for all possible pairs of tables. I made an update_table_pairs script that only implements traits for a pair of tables if both appear in the same function. This made lemmy_db_views compile around 5 times faster. The difference will likely be bigger when I remove implementations of traits other than TableNotEqual.

@dessalines
Copy link
Member

Nice. It might be worth looking into adding something like this directly into diesel, since all projects could benefit from it.


for f in crates/**/**.rs src/**/**.rs
do
python3 -c "import re; import itertools; print(''.join(set('a!({}, {});'.format(min(pair), max(pair)) for fn_chunk in open('$f').read().split('fn ') for pair in itertools.combinations(re.findall('[^A-Z]([a-z_]+)::table[^!]', fn_chunk) + re.findall('[^A-Z]([a-z_]+_actions)::', fn_chunk), 2) if pair[0] != 'pg_namespace' and pair[1] != 'pg_namespace' and pair[0] != pair[1])), end = '')" >> $OUT
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer if we dont have to depend on another language for development, only for this small script. Besides the code is not readable like this.

@Nutomic
Copy link
Member

Nutomic commented Jan 29, 2025

Like dessalines said it would be very good if you could contribute these kind of changes upstream to diesel. That way other projects can also benefit, and it will be less maintenance work for us. In this case I could imagine something like diesel print-schema --check-usage {path}.

Similarly, the replaceable schema for functions/migrations could be added directly to diesel_cli. Of course it would take some time to get these things merged and published upstream, so we could use your dev version of diesel_cli in the meantime.

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.

3 participants