0
@@ -18,11 +18,11 @@ module ActiveRecord
0
# +name+ is the column's name, as in <tt><b>supplier_id</b> int(11)</tt>.
0
# +default+ is the type-casted default value, such as <tt>sales_stage varchar(20) default <b>'new'</b></tt>.
0
- # +sql_type+ is only used to extract the column's length, if necessary.
For example, <tt>company_name varchar(<b>60</b>)</tt>.
0
+ # +sql_type+ is only used to extract the column's length, if necessary.
For example, <tt>company_name varchar(<b>60</b>)</tt>.
0
# +null+ determines if this column allows +NULL+ values.
0
def initialize(name, default, sql_type = nil, null = true)
0
@name, @sql_type, @null = name, sql_type, null
0
- @limit, @precision, @scale
= extract_limit(sql_type), extract_precision(sql_type), extract_scale(sql_type) 0
+ @limit, @precision, @scale
= extract_limit(sql_type), extract_precision(sql_type), extract_scale(sql_type)0
@type = simplified_type(sql_type)
0
@default = extract_default(default)
0
@@ -172,7 +172,7 @@ module ActiveRecord
0
def new_time(year, mon, mday, hour, min, sec, microsec)
0
# Treat 0000-00-00 00:00:00 as nil.
0
return nil if year.nil? || year == 0
0
Time.time_with_datetime_fallback(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil
0
@@ -250,11 +250,11 @@ module ActiveRecord
0
class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :precision, :scale, :default, :null) #:nodoc:
0
base.type_to_sql(type.to_sym, limit, precision, scale) rescue type
0
column_sql = "#{base.quote_column_name(name)} #{sql_type}"
0
add_column_options!(column_sql, :null => null, :default => default) unless type.to_sym == :primary_key
0
@@ -309,39 +309,39 @@ module ActiveRecord
0
# * <tt>:default</tt> -
0
# The column's default value. Use nil for NULL.
0
- # Allows or disallows +NULL+ values in the column.
This option could
0
+ # Allows or disallows +NULL+ values in the column.
This option could
0
# have been named <tt>:null_allowed</tt>.
0
# * <tt>:precision</tt> -
0
- # Specifies the precision for a <tt>:decimal</tt> column.
0
+ # Specifies the precision for a <tt>:decimal</tt> column.
0
- # Specifies the scale for a <tt>:decimal</tt> column.
0
+ # Specifies the scale for a <tt>:decimal</tt> column.
0
# Please be aware of different RDBMS implementations behavior with
0
# <tt>:decimal</tt> columns:
0
# * The SQL standard says the default scale should be 0, <tt>:scale</tt> <=
0
# <tt>:precision</tt>, and makes no comments about the requirements of
0
- # * MySQL: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..30].
0
+ # * MySQL: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..30].
0
- # * PostgreSQL: <tt>:precision</tt> [1..infinity],
0
+ # * PostgreSQL: <tt>:precision</tt> [1..infinity],
0
# <tt>:scale</tt> [0..infinity]. No default.
0
- # * SQLite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used.
0
+ # * SQLite2: Any <tt>:precision</tt> and <tt>:scale</tt> may be used.
0
# Internal storage as strings. No default.
0
# * SQLite3: No restrictions on <tt>:precision</tt> and <tt>:scale</tt>,
0
# but the maximum supported <tt>:precision</tt> is 16. No default.
0
- # * Oracle: <tt>:precision</tt> [1..38], <tt>:scale</tt> [-84..127].
0
+ # * Oracle: <tt>:precision</tt> [1..38], <tt>:scale</tt> [-84..127].
0
- # * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62].
0
+ # * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62].
0
- # * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18].
0
+ # * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18].
0
# Default (9,0). Internal types NUMERIC and DECIMAL have different
0
# storage rules, decimal being better.
0
- # * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
+ # * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
# Default (38,0). WARNING Max <tt>:precision</tt>/<tt>:scale</tt> for
0
# NUMERIC is 19, and DECIMAL is 38.
0
- # * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
+ # * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
- # * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
+ # * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
0
# * OpenBase?: Documentation unclear. Claims storage in <tt>double</tt>.
0
@@ -394,7 +394,7 @@ module ActiveRecord
0
- # There's a short-hand method for each of the type values declared at the top. And then there's
0
+ # There's a short-hand method for each of the type values declared at the top. And then there's
0
# TableDefinition#timestamps that'll add created_at and updated_at as datetimes.
0
# TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type
0
@@ -434,13 +434,13 @@ module ActiveRecord
0
def #{column_type}(*args)
0
options = args.extract_options!
0
column_names.each { |name| column(name, '#{column_type}', options) }
0
- # Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and
0
+ # Appends <tt>:datetime</tt> columns <tt>:created_at</tt> and
0
# <tt>:updated_at</tt> to the table.
0
column(:created_at, :datetime)
0
@@ -458,7 +458,7 @@ module ActiveRecord
0
alias :belongs_to :references
0
# Returns a String whose contents are the column definitions
0
- # concatenated together.
This string can then be prepended and appended to
0
+ # concatenated together.
This string can then be prepended and appended to
0
# to generate the final SQL to create the table.
0
@@ -510,15 +510,15 @@ module ActiveRecord
0
# Adds a new column to the named table.
0
# See TableDefinition#column for details of the options you can use.
0
- # ====== Creating a simple columns
0
+ # ====== Creating a simple column
0
# t.column(:name, :string)
0
def column(column_name, type, options = {})
0
@base.add_column(@table_name, column_name, type, options)
0
- # Adds a new index to the table. +column_name+ can be a single Symbol, or
0
- # an Array of Symbols. See SchemaStatements#add_index
0
+ # Adds a new index to the table. +column_name+ can be a single Symbol, or
0
+ # an Array of Symbols. See SchemaStatements#add_index
0
# ====== Creating a simple index
0
@@ -531,8 +531,8 @@ module ActiveRecord
0
@base.add_index(@table_name, column_name, options)
0
- # Adds timestamps (created_at and updated_at) columns to the table. See SchemaStatements#timestamps
0
+ # Adds timestamps (created_at and updated_at) columns to the table. See SchemaStatements#add_timestamps
0
@base.add_timestamps(@table_name)
0
@@ -547,7 +547,7 @@ module ActiveRecord
0
@base.change_column(@table_name, column_name, type, options)
0
- # Sets a new default value for a column.
See0
+ # Sets a new default value for a column.
See SchemaStatements#change_column_default0
# t.change_default(:qualification, 'new')
0
# t.change_default(:authorized, 1)
0
@@ -559,27 +559,27 @@ module ActiveRecord
0
# t.remove(:qualification)
0
# t.remove(:qualification, :experience)
0
- # t.removes(:qualification, :experience)
0
def remove(*column_names)
0
@base.remove_column(@table_name, column_names)
0
- # Remove
the given index from the table.
0
+ # Remove
s the given index from the table.
0
- # Remove the suppliers_name_index in the suppliers table.
0
+ # ====== Remove the suppliers_name_index in the suppliers table
0
- #
Remove the index named accounts_branch_id_index in the accounts table.0
+ #
====== Remove the index named accounts_branch_id_index in the accounts table0
# t.remove_index :column => :branch_id
0
- #
Remove the index named accounts_branch_id_party_id_index in the accounts table.0
+ #
====== Remove the index named accounts_branch_id_party_id_index in the accounts table0
# t.remove_index :column => [:branch_id, :party_id]
0
- #
Remove the index named by_branch_party in the accounts table.0
+ #
====== Remove the index named by_branch_party in the accounts table0
# t.remove_index :name => :by_branch_party
0
def remove_index(options = {})
0
@base.remove_index(@table_name, options)
0
# Removes the timestamp columns (created_at and updated_at) from the table.
0
@base.remove_timestamps(@table_name)
0
@@ -592,12 +592,11 @@ module ActiveRecord
0
@base.rename_column(@table_name, column_name, new_column_name)
0
- # Adds a reference. Optionally adds a +type+ column. <tt>reference</tt>,
0
- # <tt>references</tt> and <tt>belongs_to</tt> are all acceptable
0
+ # Adds a reference. Optionally adds a +type+ column.
0
+ # <tt>references</tt> and <tt>belongs_to</tt> are acceptable.
0
# t.references(:goat, :polymorphic => true)
0
options = args.extract_options!
0
@@ -609,12 +608,11 @@ module ActiveRecord
0
alias :belongs_to :references
0
- # Adds a reference. Optionally removes a +type+ column. <tt>remove_reference</tt>,
0
- # <tt>remove_references</tt> and <tt>remove_belongs_to</tt> are all acceptable
0
- # t.remove_reference(:goat)
0
- # t.remove_reference(:goat, :polymorphic => true)
0
+ # Removes a reference. Optionally removes a +type+ column.
0
+ # <tt>remove_references</tt> and <tt>remove_belongs_to</tt> are acceptable.
0
# t.remove_references(:goat)
0
+ # t.remove_references(:goat, :polymorphic => true)
0
# t.remove_belongs_to(:goat)
0
def remove_references(*args)
0
options = args.extract_options!
0
@@ -627,7 +625,7 @@ module ActiveRecord
0
alias :remove_belongs_to :remove_references
0
# Adds a column or columns of a specified type
0
# t.string(:goat, :sheep)
0
%w( string text integer float decimal datetime timestamp time date binary boolean ).each do |column_type|
Comments
No one has commented yet.