aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb14
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