diff options
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 10 | ||||
-rw-r--r-- | activerecord/test/schema_dumper_test.rb | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 72fc8b23cc..bf344d2668 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* SQLite: use AUTOINCREMENT primary key in >= 3.1.0. #6588 [careo] + * Cache inheritance_column. #6592 [Stefan Kaes] * Firebird: decimal/numeric support. #6408 [macrnic] diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 43d513e293..38e6d853d6 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -108,7 +108,7 @@ module ActiveRecord def native_database_types #:nodoc: { - :primary_key => "INTEGER PRIMARY KEY NOT NULL", + :primary_key => default_primary_key_type, :string => { :name => "varchar", :limit => 255 }, :text => { :name => "text" }, :integer => { :name => "integer" }, @@ -351,6 +351,14 @@ module ActiveRecord def sqlite_version @sqlite_version ||= select_value('select sqlite_version(*)') end + + def default_primary_key_type + if sqlite_version >= '3.1.0' + 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze + else + 'INTEGER PRIMARY KEY NOT NULL'.freeze + end + end end class SQLite2Adapter < SQLiteAdapter # :nodoc: diff --git a/activerecord/test/schema_dumper_test.rb b/activerecord/test/schema_dumper_test.rb index 330a4b16f8..3ca6febb89 100644 --- a/activerecord/test/schema_dumper_test.rb +++ b/activerecord/test/schema_dumper_test.rb @@ -8,6 +8,7 @@ if ActiveRecord::Base.connection.respond_to?(:tables) def standard_dump stream = StringIO.new ActiveRecord::SchemaDumper.ignore_tables = [] + ActiveRecord::SchemaDumper.ignore_tables << /^sqlite_/ if current_adapter?(:SQLiteAdapter) ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, stream) stream.string end |