<commit_before>require 'spec_helper'

RSpec.describe 'TableInheritance' do
  let(:connection) { ActiveRecord::Base.connection }

  context 'on migration' do
    mock_create_table

    it 'does not affect some basic forms of table creation' do
      sql = connection.create_table('schema_migrations', id: false) do |t|
        t.string :version, connection.internal_string_options_for_primary_key
      end

      result = 'CREATE TABLE "schema_migrations"'
      result << ' \("version" character varying (NOT NULL)? PRIMARY KEY\)'
      expect(sql).to match(/#{result}/)
    end

    it 'does not affect simple table creation' do
      sql = connection.create_table(:activities) do |t|
        t.string :title
        t.boolean :active
        t.timestamps
      end

      result = 'CREATE TABLE "activities" \('
      result << '"id" (big)?serial primary key'
      result << ', "title" character varying'
      result << ', "active" boolean'
      result << ', "created_at" timestamp NOT NULL'
      result << ', "updated_at" timestamp NOT NULL'
      result << '\)'
      expect(sql).to match(/#{result}/)
    end<commit_msg>Fix query test for table inheritance<commit_after>require 'spec_helper'

RSpec.describe 'TableInheritance' do
  let(:connection) { ActiveRecord::Base.connection }

  context 'on migration' do
    mock_create_table

    it 'does not affect some basic forms of table creation' do
      sql = connection.create_table('schema_migrations', id: false) do |t|
        t.string :version, connection.internal_string_options_for_primary_key
      end

      result = 'CREATE TABLE "schema_migrations"'
      result << ' \("version" character varying( NOT NULL)? PRIMARY KEY\)'
      expect(sql).to match(/#{result}/)
    end

    it 'does not affect simple table creation' do
      sql = connection.create_table(:activities) do |t|
        t.string :title
        t.boolean :active
        t.timestamps
      end

      result = 'CREATE TABLE "activities" \('
      result << '"id" (big)?serial primary key'
      result << ', "title" character varying'
      result << ', "active" boolean'
      result << ', "created_at" timestamp NOT NULL'
      result << ', "updated_at" timestamp NOT NULL'
      result << '\)'
      expect(sql).to match(/#{result}/)
    end
{'fraction_non_alphanumeric': 0.11914148050810337, 'fraction_numerical': 0.0, 'mean_word_length': 2.9515570934256057, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6629416', 'n_tokens_mistral': 661, 'n_tokens_neox': 649, 'n_words': 196}