lib/arjdbc/sqlite3/adapter.rb
# DIFFERENCE: Some common constant names to reduce differences in rest of this module from AR5 version
Some common constant names to reduce differences in rest of this module from AR5 version
Some common constant names to reduce differences in rest of this module from AR5 version
def table_structure_with_collation(table_name, basic_structure)
      collation_hash = {}
      sql            = "SELECT sql FROM
                              (SELECT * FROM sqlite_master UNION ALL
                               SELECT * FROM sqlite_temp_master)
                            WHERE type='table' and name='#{ table_name }' \;"
      result = exec_query(sql, 'SCHEMA').first
      if result
        columns_string = result["sql"].split('(').last
        columns_string.split(',').each do |column_string|
          collation_hash[$1] = $2 if (COLLATE_REGEX =~ column_string)
        end
        basic_structure.map! do |column|
          column_name = column['name']
          if collation_hash.has_key? column_name
            column['collation'] = collation_hash[column_name]
          end
          column
        end
      else
        basic_structure.to_hash
      end
    end
def table_structure_with_collation ( table_name , basic_structure ) collation_hash = { } sql = "SELECT sql FROM
                              (SELECT * FROM sqlite_master UNION ALL
                               SELECT * FROM sqlite_temp_master)
                            WHERE type='table' and name='#{ table_name }' \;" result = exec_query ( sql , 'SCHEMA' ) . first if result columns_string = result [ "sql" ] . split ( '(' ) . last columns_string . split ( ',' ) . each do | column_string | collation_hash [ $1 ] = $2 if ( COLLATE_REGEX =~ column_string ) end basic_structure . map! do | column | column_name = column [ 'name' ] if collation_hash . has_key? column_name column [ 'collation' ] = collation_hash [ column_name ] end column end else basic_structure . to_hash end end
DIFFERENCE: Some common constant names to reduce differences in rest of this module from AR5 version
DIFFERENCE : Some common constant names to reduce differences in rest of this module from AR5 version
# Result will have following sample string # CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, #                       "password_digest" varchar COLLATE "NOCASE"); # Splitting with left parentheses and picking up last will return all # columns separated with comma(,). # This regex will match the column name and collation type and will save # the value in $1 and $2 respectively.
table_name
<not_specific>
basic_structure
<not_specific>