Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47425 from adrianna-chang-shopify/ac-fix-no-autoi…
…ncrement-sqlite Ensure `AUTOINCREMENT` declaration is preserved when altering SQLite tables
- Loading branch information
Showing
5 changed files
with
93 additions
and
8 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
activerecord/lib/active_record/connection_adapters/sqlite3/column.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord | ||
module ConnectionAdapters | ||
module SQLite3 | ||
class Column < ConnectionAdapters::Column # :nodoc: | ||
def initialize(*, auto_increment: nil, **) | ||
super | ||
@auto_increment = auto_increment | ||
end | ||
|
||
def auto_increment? | ||
@auto_increment | ||
end | ||
|
||
def init_with(coder) | ||
@auto_increment = coder["auto_increment"] | ||
super | ||
end | ||
|
||
def encode_with(coder) | ||
coder["auto_increment"] = @auto_increment | ||
super | ||
end | ||
|
||
def ==(other) | ||
other.is_a?(Column) && | ||
super && | ||
auto_increment? == other.auto_increment? | ||
end | ||
alias :eql? :== | ||
|
||
def hash | ||
Column.hash ^ | ||
super.hash ^ | ||
auto_increment?.hash | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters