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

feat: rails 7.1 support #300

Merged
merged 1 commit into from
Jan 25, 2024
Merged

feat: rails 7.1 support #300

merged 1 commit into from
Jan 25, 2024

Conversation

BuonOmo
Copy link
Collaborator

@BuonOmo BuonOmo commented Jan 7, 2024

Remove deprecated configure_connection method override. It is now unnecessary as CockroachDB supports SET TIMEZONE <...>. This fixes the unset type_map bug

Fix changes induced by rails/rails@896d359

@BuonOmo BuonOmo force-pushed the rails-7.1-support branch 9 times, most recently from 87dad13 to 3d13eb6 Compare January 15, 2024 15:34
Comment on lines 84 to 85
# TODO: It seems like in CRDB this tests won't create the index at all.
# It is created in PG with `valid: false` set. Is this correct?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So here there is a behaviour difference between CRDB and PG:

PG creates the index anyway, but invalid. CRDB doesn't create it. Should I dig into it to see if this is a CRDB bug, or something we want ?

Copy link
Contributor

Choose a reason for hiding this comment

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

this is an area where CRDB diverges from PG. see: cockroachdb/cockroach#65929

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I should modify the test to look for a constraint then ? And add a comment referencing this issue maybe

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

FYI @rafiss I've looked at what is generated and I see neither and index nor a constraint

Copy link
Contributor

Choose a reason for hiding this comment

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

ah i see; i read the test more closely now. yes, that's another difference in CRDB. if you try to add the unique index but it fails, then neither the index nor constraint will exist.

Comment on lines +106 to +121
%i(
test_adding_indexes
test_removing_index
test_adding_multiple_columns
test_changing_index
).each do |method_name|
file, line = ::BulkAlterTableMigrationsTest.instance_method(method_name).source_location
iter = File.foreach(file)
(line - 1).times { iter.next }
indent = iter.next[/\A\s*/]
content = +""
content << iter.next until iter.peek == indent + "end\n"
content['"PostgreSQLAdapter" =>'] = '"CockroachDBAdapter" =>'
eval(<<-RUBY, binding, __FILE__, __LINE__ + 1)
def #{method_name}
#{content}
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 think we should go more in that direction to avoid having micro changes in the tests making our test suite fail. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't quite understand this change, could you explain more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah definitely sorry. Basically I'm advocating for a bit of meta-programmation in tests.

now

We currently are copying failing tests, and the related private methods. And then changing the bits we want to change.

the change

I'd say that if the change is trivial, we can take advantage of ruby's meta-programmation tools to just change the parts we want. This would be way more resilient to little changes in the tests.

the benefit and cost

This would make following rails updates so much easier, and even between minors or patches there are these kind of changes. It would reduce my workload. But it would make these local versions way harder to understand, as one would have to rely on understanding the meta change. But I think with good comment and viewing the original method, this should be ok

the plan

I would make these changes progressively : with newly introduced tests, or with the one that are currently ignored and that we should stop ignoring anyway. Once there are a few examples I could refactor the meta-prog tools used (such as search and replace in the original function) to make the changes clearer and the footprint smaller

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for explaining. i think the approach sounds good! i'd definitely like to make your maintenance burden easier.

@BuonOmo BuonOmo marked this pull request as ready for review January 18, 2024 19:24
@BuonOmo
Copy link
Collaborator Author

BuonOmo commented Jan 18, 2024

@rafiss I think you can already start reviewing. The majority of failing tests were already present in previous versions, others are documented, the only ones bothering me are the context dependent ones that do not trigger every time. I think we can still go on with this version as those were also present sometimes in previous versions...

Copy link
Contributor

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice work!

looks like we are at:

8808 runs, 29847 assertions, 7 failures, 9 errors, 66 skips

are we going to address those last few failures now, or handle them separately?

also, do you think we should squash this all when merging?

@BuonOmo
Copy link
Collaborator Author

BuonOmo commented Jan 24, 2024

are we going to address those last few failures now, or handle them separately?

Those failures were here before already. I definitely plan on handling them but I didn't want this to be in the scope of the PR

also, do you think we should squash this all when merging?

Cleaning up now !

@BuonOmo BuonOmo force-pushed the rails-7.1-support branch 3 times, most recently from 2ceb9ec to 0003518 Compare January 24, 2024 17:57
This PR includes loads of small changes that won't be
mentionned here to adapt to the new Rails code.

Loads of tests ignored tests have been added back as
they were not error prone anymore. There are likely
more of these.

We removed the deprecated `configure_connection` method
override. It is now unnecessary as CockroachDB supports
`SET TIMEZONE <...>`.

We dropped support for CockroachDB version before 22.X.X.

We removed a lot of copy-pasted code in the test thanks to
new file separation in Rails 7.1 test configuration.

Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>
@rafiss rafiss merged commit 2e06103 into master Jan 25, 2024
0 of 2 checks passed
@rafiss rafiss deleted the rails-7.1-support branch January 25, 2024 20:52
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