activerecord-virgodb-adapter 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0390e08c3ff3f57f95bce4609600461132e9af55122f1d9be076bd59171bc37d'
4
- data.tar.gz: 216fb2576dd924f68d9e0e635824a825b0bc6863db6f3694438943343a630df3
3
+ metadata.gz: d70a70ab0e46de3acd4d283c69e7c385873c7bb9ec817423f62ff09dbc601350
4
+ data.tar.gz: 1f7b6259306a3d61f2e3d05fb345373a5d350b2742309804be1d91ac096886a1
5
5
  SHA512:
6
- metadata.gz: d3bfd3b9cdad22f0385a1f9d13a84483aa26c89cc3c16f38d231f8c8885b2af9a1beac0ef7d53ee6237b87092c074026fab6370fab4b605230342a81a8c574b5
7
- data.tar.gz: 52c0f3df23b6a21a97a6322f58d59aa2c75511c998a21ce4e3eb54d8049f674c97d1b61061f377fcd1e028832669b7573033d2a6409804ffc241749cf91492bf
6
+ metadata.gz: 64c5716aa1f9d1ea110aacd562ad131acb5d8d76bbd4e8d0ed459a2191530d7b27c6c1f924b59a70840defed6f285c668e6fc9a56f97b134719bd2033ed42b6f
7
+ data.tar.gz: 9f2de20a524c86e2bafc0a43b6f49b8d86bdf127a54b8a5276972f75b10e937c5c7fe3b89b88172eaca32b4aaee09aa0aa52a34f947c614dc3926c3d1878f82e
@@ -74,6 +74,7 @@ module ActiveRecord
74
74
  super
75
75
  strip_null_autoindex_blank_lines!(filename)
76
76
  reformat_create_table_statements!(filename)
77
+ separate_create_table_statements_with_blank_lines!(filename)
77
78
  annotate_physical_layout!(filename)
78
79
  dump_schema_versions!(filename)
79
80
  end
@@ -217,11 +218,11 @@ module ActiveRecord
217
218
  # `ignore_tables` is empty) already skips these rows itself --
218
219
  # confirmed empirically too -- so this is purely a gap in the
219
220
  # raw-SQL fallback, not something either path does on purpose.
220
- # Stripping now, before `reformat_create_table_statements!` touches
221
- # anything, means later steps never have to reason about which blank
222
- # lines are "real" -- there aren't any yet at this point in the
223
- # pipeline (`dump_schema_versions!`'s own deliberate ones are added
224
- # after this runs).
221
+ # Stripping now, before `reformat_create_table_statements!` and
222
+ # `separate_create_table_statements_with_blank_lines!` (below) touch
223
+ # anything, gives those steps a clean slate -- every blank line in the
224
+ # dump from this point on is one THEY deliberately added, not this
225
+ # accidental one.
225
226
  def strip_null_autoindex_blank_lines!(filename)
226
227
  content = File.read(filename)
227
228
  content.gsub!(/\n\n+/, "\n")
@@ -268,6 +269,29 @@ module ActiveRecord
268
269
  File.write(filename, content)
269
270
  end
270
271
 
272
+ # Matches `db/clickhouse_structure.sql` and `db/schema.rb`'s own
273
+ # convention (both, unprompted, separate every top-level table
274
+ # definition with a blank line -- confirmed directly against
275
+ # hintpot's real dumps of each, not assumed) rather than inventing a
276
+ # new one here. Only CREATE TABLE gets a leading blank line, not
277
+ # CREATE INDEX/CREATE UNIQUE INDEX -- those stay glued directly under
278
+ # their own table, same as clickhouse_structure.sql has no equivalent
279
+ # to disagree with and virgodb's own tables (e.g. `inline_batches` +
280
+ # `idx_inline_batches_table_name`) already read naturally that way.
281
+ # Runs after `reformat_create_table_statements!` (so every `CREATE
282
+ # TABLE` is unambiguously alone at the start of its own line already,
283
+ # nothing left to normalize first) but before
284
+ # `annotate_physical_layout!` (so a table WITH a physical-layout
285
+ # comment gets the blank line ahead of the comment block, not
286
+ # wedged between the comment and its own `CREATE TABLE`).
287
+ # `(?<!\A)` skips the very first statement in the file, which should
288
+ # start right at the top with no leading blank line.
289
+ def separate_create_table_statements_with_blank_lines!(filename)
290
+ content = File.read(filename)
291
+ content.gsub!(/(?<!\A)^CREATE TABLE /) { |match| "\n#{match}" }
292
+ File.write(filename, content)
293
+ end
294
+
271
295
  # Splits a CREATE TABLE column list on commas that are NOT nested
272
296
  # inside a type's own parens (e.g. `Decimal(18,2)`) -- a plain
273
297
  # `String#split(",")` would wrongly cut `Decimal(18` and `2)` apart.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-virgodb-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - virgodb