Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

MySQL: Support:size option to change text and blob size#35071

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kamipo merged 1 commit intorails:masterfromkamipo:text_without_limit
Jan 29, 2019

Conversation

@kamipo
Copy link
Member

@kamipokamipo commentedJan 28, 2019
edited
Loading

In MySQL, the text column size is 65,535 bytes by default (1 GiB in
PostgreSQL). It is sometimes too short when people want to use a text
column, so they sometimes change the text size to mediumtext (16 MiB) or
longtext (4 GiB) by giving thelimit option.

Unlike MySQL, PostgreSQL doesn't allow thelimit option for a text
column (raises ERROR: type modifier is not allowed for type "text").
Solimit: 4294967295 (longtext) couldn't be used in Action Text.

I've allowed changing text and blob size without giving thelimit
option, it prevents that migration failure on PostgreSQL.

matsumura-taichi and onk reacted with thumbs up emojiy-yagi reacted with heart emoji
Copy link
Member

@jeremyjeremy left a comment

Choose a reason for hiding this comment

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

Nice feature for Active Record migrations! And great to expand Action Text support to PostgreSQL. Changelog entries for both, too?

@kamipo
Copy link
MemberAuthor

hm... I've realized thatlimit: 16777215 is ignored on PostgreSQL adapter, so Action Text originally work on PostgreSQL.

when"text"
# PostgreSQL doesn't support limits on text columns.
# The hard limit is 1GB, according to section 8.3 in the manual.
caselimit
whennil,0..0x3fffffff;super(type)
elseraise(ActiveRecordError,"The limit on text can be at most 1GB - 1byte.")

I think that usinglimit: 16777215 (mediumtext 16 MiB) notlimit: 4294967295 (longtext 4 GiB) is to ignore thelimit option on PostgreSQL adapter.
So how about changing mediumtext to longtext for MySQL? 16 MiB is still too shorter than PostgreSQL's limit (1 GiB).

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Changed from mediumtext (16 MiB) to longtext (4 GiB).

jeremy reacted with thumbs up emoji
@kamipokamipo changed the titleAllow using Action Text on PostgreSQLMySQL: Support:size option to change text and blob sizeJan 28, 2019
In MySQL, the text column size is 65,535 bytes by default (1 GiB inPostgreSQL). It is sometimes too short when people want to use a textcolumn, so they sometimes change the text size to mediumtext (16 MiB) orlongtext (4 GiB) by giving the `limit` option.Unlike MySQL, PostgreSQL doesn't allow the `limit` option for a textcolumn (raises ERROR: type modifier is not allowed for type "text").So `limit: 4294967295` (longtext) couldn't be used in Action Text.I've allowed changing text and blob size without giving the `limit`option, it prevents that migration failure on PostgreSQL.
@kamipokamipo merged commit8309cd2 intorails:masterJan 29, 2019
@kamipokamipo deleted the text_without_limit branchJanuary 29, 2019 08:02
kamipo added a commit to kamipo/rails that referenced this pull requestApr 7, 2019
…ther optionsWhen I've added new `:size` option inrails#35071, I've found that invalid`:limit` and `:precision` raises `ActiveRecordError` unlike otherinvalid options.I think that is hard to distinguish argument errors and statementinvalid errors since the `StatementInvalid` is a subclass of the`ActiveRecordError`.https://github.com/rails/rails/blob/c9e4c848eeeb8999b778fa1ae52185ca5537fffe/activerecord/lib/active_record/errors.rb#L103```rubybegin  # execute any migrationrescue ActiveRecord::StatementInvalid  # statement invalidrescue ActiveRecord::ActiveRecordError, ArgumentError  # `ActiveRecordError` except `StatementInvalid` is maybe an argument errorend```I'd say this is the inconsistency worth fixing.Before:```rubyadd_column :items, :attr1, :binary,   size: 10      # => ArgumentErroradd_column :items, :attr2, :decimal,  scale: 10     # => ArgumentErroradd_column :items, :attr3, :integer,  limit: 10     # => ActiveRecordErroradd_column :items, :attr4, :datetime, precision: 10 # => ActiveRecordError```After:```rubyadd_column :items, :attr1, :binary,   size: 10      # => ArgumentErroradd_column :items, :attr2, :decimal,  scale: 10     # => ArgumentErroradd_column :items, :attr3, :integer,  limit: 10     # => ArgumentErroradd_column :items, :attr4, :datetime, precision: 10 # => ArgumentError```
suketa added a commit to suketa/rails_sandbox that referenced this pull requestJul 27, 2019
MySQL: Support `:size` option to change text and blob sizerails/rails#35071
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jeremyjeremyjeremy left review comments

@rafaelfrancarafaelfrancarafaelfranca approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@kamipo@jeremy@rafaelfranca

[8]ページ先頭

©2009-2025 Movatter.jp