Method: Sequel::Database#column_definition_sql
- Defined in:
- lib/sequel/database/schema_sql.rb
#column_definition_sql(column) ⇒ Object
SQL DDL fragment containing the column creation SQL for the given column.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sequel/database/schema_sql.rb', line 67 def column_definition_sql(column) return constraint_definition_sql(column) if column[:type] == :check sql = "#{quote_identifier(column[:name])} #{type_literal(column)}" sql << UNIQUE if column[:unique] sql << NOT_NULL if column[:null] == false sql << NULL if column[:null] == true sql << " DEFAULT #{literal(column[:default])}" if column.include?(:default) sql << PRIMARY_KEY if column[:primary_key] sql << " #{auto_increment_sql}" if column[:auto_increment] sql << column_references_sql(column) if column[:table] sql end |