Sha256: 986e8e69566a3bd7f42f374a62d758ddf44efd2eca510f9e034c53b171ee2c7b
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
# frozen_string_literal: true require 'spec_helper' describe SchemaPlus::Core::SqlStruct do describe SchemaPlus::Core::SqlStruct::Table do Given(:struct) { described_class.new } When { struct.parse! sql } Invariant { expect(struct.assemble).to eq sql } context "with options (mysql syntax)" do Given(:sql) { %q<CREATE TABLE `things` (`id` int(11) auto_increment PRIMARY KEY, `column` int(11), INDEX `index_things_on_column` (`column`) ) ENGINE=InnoDB> } Then { expect(struct.command).to eq "CREATE TABLE" } Then { expect(struct.name).to eq "things" } Then { expect(struct.options).to eq "ENGINE=InnoDB" } end context "with options (postgresql syntax)" do Given(:sql) { %q<CREATE TABLE `things` (`id` int(11) auto_increment PRIMARY KEY, `column` int(11), INDEX `index_things_on_column` (`column`) ) INHERITS (parent_first, parent_second)> } Then { expect(struct.command).to eq "CREATE TABLE" } Then { expect(struct.name).to eq "things" } Then { expect(struct.inheritance).to eq "INHERITS (parent_first, parent_second)" } end context "temporary table (sqlite3 syntax)" do Given(:sql) { %q<CREATE TEMPORARY TABLE "athings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "column1" integer)> } Then { expect(struct.command).to eq "CREATE TEMPORARY TABLE" } Then { expect(struct.name).to eq "athings" } Then { expect(struct.options).to be_blank } end context "a table with quoted newline" do Given(:sql) { %q<CREATE TABLE "things" ("id" serial primary key, "name" character varying DEFAULT 'hey\nhey')>} Then { expect(struct.command).to eq "CREATE TABLE" } Then { expect(struct.name).to eq "things" } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
schema_plus_core-3.1.0 | spec/sql_struct_spec.rb |
schema_plus_core-3.1.0.beta.3 | spec/sql_struct_spec.rb |
schema_plus_core-3.0.0 | spec/sql_struct_spec.rb |