Every data type class (see Datatype) is derived from this class.

Public Class methods
new( row = nil )

Creates a new instance of the special data type, setting not_null and default according to the values from Information Schema.

# File lib/momomoto/datatype/base.rb, line 30
      def initialize( row = nil )
        @not_null = row.respond_to?(:is_nullable) && row.is_nullable == "NO" ? true : false
        @default = row.respond_to?(:column_default) ? row.column_default : nil
operator_sign( op )

These are operators supported by all data types. In your select statement use something like:

  one_day_ago = Time.now - (3600*24)
  Feeds.select( :date => {:ge => one_day_ago.to_s} )

This will select all rows from Feeds that are newer than 24 hours. Same with Momomoto‘s TimeInterval:

  one_day_ago = Time.now + TimeInterval.new({:hour => -24})
  Feeds.select( :date => {:ge => one_day_ago.to_s} )

In case of data type Text also +:like+ and +:ilike+ are supported. For +:like+ and +:ilike+ operators you may use _ as placeholder for a single character or % as placeholder for multiple characters.

  # Selects all posts having "surveillance" in their content field
  # while ignoring case.
  Posts.select( :content => {:ilike => 'surveillance'} )
# File lib/momomoto/datatype/base.rb, line 110
      def self.operator_sign( op )
        case op
          when :le then '<='
          when :lt then '<'
          when :ge then '>='
          when :gt then '>'
          when :eq then '='
          when :ne then '<>'
            raise CriticalError, "unsupported operator"
Public Instance methods

Gets the default value for this column or returns nil if none exists.

# File lib/momomoto/datatype/base.rb, line 19
      def default
equal( a, b )

Compares two values and return true if equal or false otherwise. It is used to check if a row field has been changed so that only changed fields are written to database.

# File lib/momomoto/datatype/base.rb, line 45
      def equal( a, b )
        a == b
escape( input )

Escapes input to be saved in database. If input equals nil, NULL is returned, otherwise Database#escape_string is called. This method is overwritten to get data type-specific escaping rules.

# File lib/momomoto/datatype/base.rb, line 53
      def escape( input )
        input.nil? ? "NULL" : "'" + Database.escape_string( input.to_s ) + "'"

Returns true if this column can be NULL otherwise false.

# File lib/momomoto/datatype/base.rb, line 24
      def not_null?