aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/adapters/postgresql/utils_test.rb
blob: 9e7b08ef34fca6aea76781eb29fdc0c4123c8767 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
require 'cases/helper'

class PostgreSQLUtilsTest < ActiveSupport::TestCase
  include ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::Utils

  def test_extract_schema_and_table
    {
      %(table_name)            => [nil,'table_name'],
      %("table.name")          => [nil,'table.name'],
      %(schema.table_name)     => %w{schema table_name},
      %("schema".table_name)   => %w{schema table_name},
      %(schema."table_name")   => %w{schema table_name},
      %("schema"."table_name") => %w{schema table_name},
      %("even spaces".table)   => ['even spaces','table'],
      %(schema."table.name")   => ['schema', 'table.name']
    }.each do |given, expect|
      assert_equal expect, extract_schema_and_table(given)
    end
  end
end