diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-14 03:32:16 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-11-14 03:32:16 +0000 |
commit | 50ee332c4aa97aa797e814d3ab6ae63a0f8351e2 (patch) | |
tree | 7db87a169801a47875bfb8b7e6046df74ef9df92 /activerecord/lib | |
parent | fda4330ce9be60c4bd7434ea613543a1c378852b (diff) | |
download | rails-50ee332c4aa97aa797e814d3ab6ae63a0f8351e2.tar.gz rails-50ee332c4aa97aa797e814d3ab6ae63a0f8351e2.tar.bz2 rails-50ee332c4aa97aa797e814d3ab6ae63a0f8351e2.zip |
Cleanup SQLite AUTOINCREMENT: exclude sqlite_sequence table, factor out feature availability check.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5520 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 38e6d853d6..b0c86f51a5 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -106,6 +106,10 @@ module ActiveRecord sqlite_version >= '3.2.6' end + def supports_autoincrement? #:nodoc: + sqlite_version >= '3.1.0' + end + def native_database_types #:nodoc: { :primary_key => default_primary_key_type, @@ -197,7 +201,13 @@ module ActiveRecord # SCHEMA STATEMENTS ======================================== def tables(name = nil) #:nodoc: - execute("SELECT name FROM sqlite_master WHERE type = 'table'", name).map do |row| + sql = <<-SQL + SELECT name + FROM sqlite_master + WHERE type = 'table' AND NOT name = 'sqlite_sequence' + SQL + + execute(sql, name).map do |row| row[0] end end @@ -353,7 +363,7 @@ module ActiveRecord end def default_primary_key_type - if sqlite_version >= '3.1.0' + if supports_autoincrement? 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze else 'INTEGER PRIMARY KEY NOT NULL'.freeze |