schema_plus_core 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4d26e275c50fcd2af36c17ffa242169a5cf4c1c
4
- data.tar.gz: e905b78be6d0cb9daaebafbe16690784dcc04afb
3
+ metadata.gz: 5d71c54452ec75e70a08f2147dee0399dd7d5254
4
+ data.tar.gz: 894a9d00c4de01e2e2d6a4b0c9f023ebd8c6fd0b
5
5
  SHA512:
6
- metadata.gz: a1fd98fec6ad3e8c10401bf423603480ede2df2b5ead66e7f5512d8fab6386df50110238a2249aaa6868e1ad11abc22711c47be7267590eba91367c4b9ea95d2
7
- data.tar.gz: f9cfd2ba60a8c25d10c2215f0f4c8db1f710e77ba330e0266af840a087a08ea83c342a71b860855ecae836b8734af341c99b3b5afd148978436b26f60c4f0bc1
6
+ metadata.gz: 6fdffd10cc18ba2031dba7b03aaccd6db5ad2744c24ae17caf8bd474196f68dc4d1a33fe1e7912085c8913f01c4cb19b6ffd5dad7d60f3915e0e742bdd4bc60e
7
+ data.tar.gz: 8d8dbcb1d7bee92a34e4e65156f56d25f2004ce8819235d368c5f22c8e3a29ce7f4375cadd80ca02bd81ce4bff9f3135190a7fc5c504ea7df0f625f1640d0902
data/README.md CHANGED
@@ -450,6 +450,7 @@ SchemaPlus::Core provides a state object and of callbacks to various phases of t
450
450
  The base method appends the collection of SchemaDump::Table::Index objects to `env.table.indexes`
451
451
 
452
452
  ## History
453
+ * 0.6.2 Bug fix: don't choke on INHERITANCE in table definition (#7). Thanks to [@ADone](https://github.com/ADone).
453
454
  * 0.6.1 Make sure to require pathname (#5)
454
455
  * 0.6.0 Added `table.alt` to dumper; Bug fix: Don't crash when AR fails to dump a table. Thanks to [@stenver](https://github.com/stenver) for tracking it down
455
456
  * 0.5.1 Bug fix: Don't choke on a quoted newline in a `CREATE TABLE` statement ([#3](https://github.com/SchemaPlus/schema_plus_core/pull/3)). Thanks to [@mikeauclair](https://github.com/mikeauclair)
@@ -3,26 +3,33 @@ module SchemaPlus
3
3
  module SqlStruct
4
4
  IndexComponents = KeyStruct[:name, :type, :columns, :options, :algorithm, :using]
5
5
 
6
- class Table < KeyStruct[:command, :name, :body, :options, :quotechar]
6
+ class Table < KeyStruct[:command, :name, :body, :options, :quotechar, :inheritance]
7
+
8
+ INHERITANCE_REGEX = %r{ \s* (?<inheritance>INHERITS \s* \( [^)]* \)) }mxi
9
+
7
10
  def parse!(sql)
8
11
  m = sql.strip.match %r{
9
- ^
12
+ \A
10
13
  (?<command>.*\bTABLE\b) \s*
11
14
  (?<quote>['"`])(?<name>\S+)\k<quote> \s*
12
15
  \( \s*
13
16
  (?<body>.*) \s*
14
17
  \) \s*
18
+ # can't use optional ? for inheritance because it would be greedily grabbed into body;
19
+ # ideally this would use an actual parser rather than regex
20
+ #{INHERITANCE_REGEX if sql.match INHERITANCE_REGEX}
15
21
  (?<options> \S.*)?
16
- $
22
+ \Z
17
23
  }mxi
18
24
  self.command = m[:command]
19
25
  self.quotechar = m[:quote]
20
26
  self.name = m[:name]
21
27
  self.body = m[:body]
22
28
  self.options = m[:options]
29
+ self.inheritance = m[:inheritance] rescue nil
23
30
  end
24
31
  def assemble
25
- ["#{command} #{quotechar}#{name}#{quotechar} (#{body})", options].reject(&:blank?).join(" ")
32
+ ["#{command} #{quotechar}#{name}#{quotechar} (#{body})", inheritance, options].reject(&:blank?).join(" ")
26
33
  end
27
34
  end
28
35
  end
@@ -1,5 +1,5 @@
1
1
  module SchemaPlus
2
2
  module Core
3
- VERSION = "0.6.1"
3
+ VERSION = "0.6.2"
4
4
  end
5
5
  end
@@ -17,6 +17,13 @@ describe SchemaPlus::Core::SqlStruct do
17
17
  Then { expect(struct.options).to eq "ENGINE=InnoDB" }
18
18
  end
19
19
 
20
+ context "with options (postgresql syntax)" do
21
+ 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)> }
22
+ Then { expect(struct.command).to eq "CREATE TABLE" }
23
+ Then { expect(struct.name).to eq "things" }
24
+ Then { expect(struct.inheritance).to eq "INHERITS (parent_first, parent_second)" }
25
+ end
26
+
20
27
  context "temporary table (sqlite3 syntax)" do
21
28
  Given(:sql) { %q<CREATE TEMPORARY TABLE "athings" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "column1" integer)> }
22
29
  Then { expect(struct.command).to eq "CREATE TEMPORARY TABLE" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schema_plus_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ronen barzel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2016-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord