Skip to content

Commit 03c6fac

Browse files
committed
Remove spacing between consecutive SET statements
we want to bundle those kinds of configs together
1 parent 51e5cd8 commit 03c6fac

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

lib/activerecord-pg-format-db-structure/statement_appender.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,27 @@ def append_statement!(statement, statement_kind:)
2727
private
2828

2929
def newlines_separator(previous_kind:, current_kind:)
30-
case [previous_kind, current_kind]
31-
in [nil, _]
30+
case [
31+
previous_kind,
32+
current_kind
33+
]
34+
in [
35+
nil,
36+
_
37+
]
3238
""
33-
in [_, :insert_stmt | :create_stmt | :view_stmt | :create_table_as_stmt]
39+
in [
40+
_,
41+
:insert_stmt | :create_stmt | :view_stmt | :create_table_as_stmt
42+
]
3443
"\n\n\n"
35-
in [ :create_stmt | :view_stmt | :create_table_as_stmt | :index_stmt, :index_stmt]
44+
in [
45+
:create_stmt | :view_stmt | :create_table_as_stmt | :index_stmt,
46+
:index_stmt
47+
] | [
48+
:variable_set_stmt,
49+
:variable_set_stmt
50+
]
3651
"\n"
3752
else
3853
"\n\n"

spec/activerecord-pg-format-db-structure/formatter_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@
184184
SELECT pg_catalog.set_config('search_path', '', false);
185185
186186
SET check_function_bodies TO TRUE;
187-
188187
SET client_min_messages TO warning;
189-
190188
SET row_security TO OFF;
191189
192190
CREATE EXTENSION IF NOT EXISTS pgcrypto SCHEMA public;

spec/activerecord-pg-format-db-structure/transforms/remove_defaults_set_commands_spec.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
SELECT pg_catalog.set_config('search_path', '', false);
2828
2929
SET check_function_bodies TO FALSE;
30-
3130
SET client_min_messages TO warning;
32-
3331
SET row_security TO OFF;
3432
SQL
3533
end
@@ -55,23 +53,16 @@
5553

5654
expect(formatter.format(source)).to eq(<<~SQL)
5755
SET statement_timeout TO 1;
58-
5956
SET default_with_oids TO TRUE;
60-
6157
SET lock_timeout TO 2;
62-
6358
SET idle_in_transaction_session_timeout TO 3;
64-
6559
SET client_encoding TO "UTF8";
66-
6760
SET standard_conforming_strings TO OFF;
6861
6962
SELECT pg_catalog.set_config('search_path', '', false);
7063
7164
SET check_function_bodies TO FALSE;
72-
7365
SET client_min_messages TO warning;
74-
7566
SET row_security TO ON;
7667
SQL
7768
end

0 commit comments

Comments
 (0)