Skip to content

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

Merged
bbuchalter merged 2 commits into
masterfrom
safe_table_names
Aug 28, 2018
Merged

Ensure all table names originate from Lhm::TableName#49
bbuchalter merged 2 commits into
masterfrom
safe_table_names

Conversation

@bbuchalter

Copy link
Copy Markdown

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
Copy Markdown
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.

Comment thread lib/lhm/migration.rb
end

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

Copy link
Copy Markdown

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?

Comment thread lib/lhm/table_name.rb

attr_reader :original

def archived

Copy link
Copy Markdown

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?

Copy link
Copy Markdown

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
Copy Markdown

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 😁

Copy link
Copy Markdown

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