Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

current MySQL driver fails to fetch PK name when the PK has USING option #5900

Merged
merged 1 commit into from Apr 19, 2012

Conversation

Projects
None yet
3 participants
Member

amatsuda commented Apr 19, 2012

Given the following MySQL table (you know we sometimes should unfortunately work on some legacy DB or non-Rails DB like this):

SQL
CREATE TABLE btree_pk_tables (
id int(11) NOT NULL auto_increment,
PRIMARY KEY USING BTREE (id)
)


`BtreePkTable.primary_key` becomes `nil` because of Regexp bug.
Attached a patch with test cases. Tested on MySQL 5.1, Ruby 1.9.3.

Because this bug happens on current stable version of AR, I hope this to be backported to 3-2-stable branch. I confirmed that the Regexp works either on Ruby 1.9 and Ruby 1.8.7, so it should work.

This pull request fails (merged 851b816 into 66ea296).

jeremy added a commit that referenced this pull request Apr 19, 2012

Merge pull request #5900 from amatsuda/ar_mysql_pk_with_using_option
current MySQL driver fails to fetch PK name when the PK has USING option

@jeremy jeremy merged commit 99eae3f into rails:master Apr 19, 2012

jeremy added a commit that referenced this pull request Apr 19, 2012

Be sure to correctly fetch PK name from MySQL even if the PK has some…
… custom option

Backports #5900

Conflicts:

	activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
	activerecord/test/cases/adapters/mysql/mysql_adapter_test.rb

@amatsuda amatsuda deleted the amatsuda:ar_mysql_pk_with_using_option branch Jun 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment