lib/swift/db.rb in swift-0.13.0 vs lib/swift/db.rb in swift-0.14.0
- old
+ new
@@ -18,10 +18,14 @@
case attribute
when Type::Integer then attribute.serial ? 'integer auto_increment' : 'integer'
else super
end
end
+
+ def tables
+ execute("show tables").map(&:values).flatten
+ end
end # Mysql
class Sqlite3 < Adapter::Sql
def initialize options = {}
super options.update(driver: 'sqlite3')
@@ -45,17 +49,22 @@
case attribute
when Type::String then 'text'
when Type::Integer then attribute.serial ? 'integer primary key' : 'integer'
when Type::Float then 'float'
when Type::BigDecimal then 'numeric'
- when Type::Time then 'timestamp'
+ when Type::Time then 'timestamp' # deprecated
+ when Type::DateTime then 'timestamp'
when Type::Date then 'date'
when Type::Boolean then 'boolean'
when Type::IO then 'blob'
else 'text'
end
end
+
+ def tables
+ execute('select name from sqlite_master where type = ?', 'table').map(&:values).flatten
+ end
end # Sqlite3
class Postgres < Adapter::Sql
def initialize options = {}
super options.update(driver: 'postgresql')
@@ -68,9 +77,13 @@
def field_type attribute
case attribute
when Type::IO then 'bytea'
else super
end
+ end
+
+ def tables
+ execute('select tablename from pg_tables where schemaname = current_schema').map(&:values).flatten
end
end # Postgres
end # DB
end # Swift