Class: DataMapper::Adapters::Sqlite3Adapter::Queries::CreateTableStatement
- Inherits:
-
Object
- Object
- DataMapper::Adapters::Sqlite3Adapter::Queries::CreateTableStatement
- Defined in:
- lib/data_mapper/adapters/sqlite3_adapter.rb
Overview
class TableExistsStatement
Instance Method Summary collapse
Instance Method Details
#column_long_form(column) ⇒ Object
167 168 169 170 171 172 173 174 175 |
# File 'lib/data_mapper/adapters/sqlite3_adapter.rb', line 167 def column_long_form(column) long_form = "#{column.to_sql} #{@database.adapter.class::TYPES[column.type] || column.type}" long_form << " NOT NULL" unless column.nullable? long_form << " PRIMARY KEY" if column.key? long_form << " default #{column.[:default]}" if column..has_key?(:default) return long_form end |
#to_sql ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/data_mapper/adapters/sqlite3_adapter.rb', line 155 def to_sql table = @database[@klass] sql = "CREATE TABLE " << table.to_sql sql << " (" << table.columns.map do |column| column_long_form(column) end.join(', ') << ")" return sql end |