activerecord-virgodb-adapter 0.1.4 → 0.1.5

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: d6376b065e29146c096491b6ce2a68e4331e806161a570b6549b068561a85f1f
4
- data.tar.gz: 1555e75fdf0c2418c1d3439fb1940f7dd284e48e28109248ffd249454b41dc55
3
+ metadata.gz: 19cfa01c6fa3ae36139e4412c022abfe3039c670fd4b29fbffdb399f47c8c36d
4
+ data.tar.gz: 5180372a507b33cd5a51670c3439894efafd72ca8d22538efc5b0a738eeb3937
5
5
  SHA512:
6
- metadata.gz: ab5ef2e0113e6c38295495cb10d1c2ca4bb77d135b65a636cf58aee8777146bc29795b1c7d3d2950898735a81367e2d88e3ce235a3d4f567b7e934ae8d69e885
7
- data.tar.gz: 7375e48809a1b05cc4a1ae8add6ed5e1a36d33a4564e0c711a8a8228e910e4f79d9ad039aaeccd66b839b88a4ff31640aec9e5d0f9ac246398d320b6b1224611
6
+ metadata.gz: 4ffee29b035fe6705dd22022056b35e281f4275c9e009075508d136e87b03e804e62db4052ac8d581a010a50036568a6a6299ee7aa03f33137a56c28532b9a81
7
+ data.tar.gz: 5303c2ceaf69703a4739614f76fd518741ea4555b18cc3bab4276d19c04189e03a9d192b8402dde926f235136bf87ac5e361a331f9e2efc7510f33d761fd19eb
@@ -197,20 +197,36 @@ module ActiveRecord
197
197
  # `SQLite3Adapter#structure_dump`'s raw `SELECT sql FROM sqlite_master`
198
198
  # path (used whenever `ActiveRecord::SchemaDumper.ignore_tables` is
199
199
  # non-empty, e.g. excluding tables owned by a separate replication/
200
- # backup mechanism) reproduces each
201
- # CREATE TABLE exactly as ActiveRecord originally generated it --
202
- # one long line, every column crammed together. Fine for SQLite to
203
- # load back (structure_load doesn't care about whitespace), useless to
204
- # a human reading the dump next to `db/clickhouse_structure.sql`
205
- # (ClickHouse's own `SHOW CREATE TABLE` is naturally one-column-per-line,
206
- # for comparison). Purely cosmetic, safe to do unconditionally: only
200
+ # backup mechanism) reproduces each CREATE TABLE exactly as SQLite
201
+ # stored it -- one long line, every column crammed together, for a
202
+ # table ActiveRecord generated. Fine for SQLite to load back
203
+ # (structure_load doesn't care about whitespace), useless to a human
204
+ # reading the dump next to `db/clickhouse_structure.sql` (ClickHouse's
205
+ # own `SHOW CREATE TABLE` is naturally one-column-per-line, for
206
+ # comparison). Purely cosmetic, safe to do unconditionally: only
207
207
  # rewrites the exact same statement with different whitespace, no DDL
208
- # semantics change. Skips statements that already span multiple lines
209
- # (e.g. this adapter's own hand-written `schema_versions` DDL, created
210
- # via a real newline-containing heredoc) -- nothing to reformat there.
208
+ # semantics change.
209
+ #
210
+ # Must handle statements that ALREADY span multiple lines, not just
211
+ # single-line ones: every virgodb-side manifest table (`crates/
212
+ # manifest/src/lib.rs`'s `maintenance_lease`, `orphaned_files`, this
213
+ # adapter's own `schema_versions`, ...) is bootstrapped from a
214
+ # multi-line, already-indented `CREATE TABLE` literal, and any column
215
+ # added to one of those later via `ALTER TABLE ... ADD COLUMN` (the
216
+ # only way SQLite can add a column to an existing table) gets its
217
+ # definition spliced into that SAME stored multi-line text, right
218
+ # before the final `)` -- with none of the original literal's
219
+ # indentation, producing exactly the lopsided
220
+ # "seven clean columns, then a cramped `, col1, col2)` tail" shape a
221
+ # single-line-only regex would silently skip over and leave raw.
222
+ # `/m` (dot matches newline) plus a non-greedy `(.*?)` is required
223
+ # together: `/m` alone with the old greedy `(.*)` would swallow every
224
+ # later `CREATE TABLE`/`CREATE INDEX` statement up to the LAST `);` in
225
+ # the file into one match, since nothing would stop it at the nearer
226
+ # one.
211
227
  def reformat_create_table_statements!(filename)
212
228
  content = File.read(filename)
213
- content.gsub!(/^CREATE TABLE (IF NOT EXISTS )?("[\w]+"|\w+) \((.*)\);$/) do
229
+ content.gsub!(/^CREATE TABLE (IF NOT EXISTS )?("[\w]+"|\w+) \((.*?)\);$/m) do
214
230
  if_not_exists = Regexp.last_match(1)
215
231
  table_name = Regexp.last_match(2)
216
232
  columns = split_top_level_commas(Regexp.last_match(3))
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.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - virgodb