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

Ensure all table names originate from Lhm::TableName #49

Merged
merged 2 commits into from
Aug 28, 2018

Conversation

bbuchalter
Copy link

As you can see, the logic for describing table names is all over the place.
Trying to change the interfaces for these classes is beyond the scope of
the PR, as these interfaces are sadly coupled to the test suite.

However, we can at least have these classes delegate the logic for these
table names to something is well tested and centralized. This eliminates
the tests currently running on migration_spec.

Closes #47

Brian Buchalter added 2 commits August 27, 2018 12:54
Because the table name behavior was distributed all over the system,
it was not under test. This commit consolidates this behavior and
puts it under test.
As you can see, the logic for describing table names is all over the place.
Trying to change the interfaces for these classes is beyond the scope of the
PR, as these interfaces are sadly coupled to the test suite.

However, we can at least have these classes delegate the logic for these table
names to something is well tested and centralized. This eliminates the tests
currently running on migration_spec.
@bbuchalter
Copy link
Author

This solves our primary problem. It doesn't change the length of the timestamp, because #50, but at this point, we shouldn't care about that.

end

def archive_name
"lhma_#{ startstamp }_#{ @origin.name }"[0...64]

Choose a reason for hiding this comment

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

That‘s 65, not 64 bytes, I think?


attr_reader :original

def archived

Choose a reason for hiding this comment

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

Not sure whether you end up with 65 instead of 64 bytes in all of these cases?

Choose a reason for hiding this comment

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

but if that's the case, how does the test pass? I'm confused.

Copy link

Choose a reason for hiding this comment

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

@berlincount With three dots, ranges in Ruby are not inclusive:

irb(main):013:0> 'asdasdasdasdasdasdasdasdasdasdasdasdasdasdadasdasdasdasdasdasdasdasdasdadasd'[0...64].length
=> 64

With two dots they are. It's not my favourite syntax 😁

Choose a reason for hiding this comment

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

what. the. beep.

Ruby magic strikes again.

@bbuchalter bbuchalter merged commit d2296ff into master Aug 28, 2018
@bbuchalter bbuchalter deleted the safe_table_names branch August 28, 2018 13:33
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.

4 participants