Skip to content

Commit

Permalink
Enforces that heredoc bodies are indented consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
mamantoha committed Feb 7, 2025
1 parent dd57cd6 commit a680f61
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 61 deletions.
16 changes: 8 additions & 8 deletions sample/benchmark/model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ require "benchmark"
Clear::SQL.init("postgres://postgres@localhost/benchmark_clear")

init = <<-SQL
CREATE TABLE benchmark (id serial PRIMARY KEY NOT NULL, y int);
CREATE INDEX benchmark_y ON benchmark (y);
INSERT INTO benchmark
SELECT i AS x, 2*i as y
FROM generate_series(1, 1000000) AS i;
end
SQL
CREATE TABLE benchmark (id serial PRIMARY KEY NOT NULL, y int);
CREATE INDEX benchmark_y ON benchmark (y);
INSERT INTO benchmark
SELECT i AS x, 2*i as y
FROM generate_series(1, 1000000) AS i;
end
SQL

init.split(";").each { |sql| Clear::SQL.execute(sql) }

Expand Down
74 changes: 37 additions & 37 deletions spec/model/converters/json_converter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@ module JSONConverterSpec
# Example found here:
# https://codeblogmoney.com/json-example-with-data-types-including-json-array/
JSON_DATA_SAMPLE = <<-JSON
{
"Actors": [
{
"name": "Tom Cruise",
"age": 56,
"Born At": "Syracuse, NY",
"Birthdate": "July 3, 1962",
"photo": "https://jsonformatter.org/img/tom-cruise.jpg",
"wife": null,
"weight": 67.5,
"hasChildren": true,
"hasGreyHair": false,
"children": [
"Suri",
"Isabella Jane",
"Connor"
]
},
{
"name": "Robert Downey Jr.",
"age": 53,
"Born At": "New York City, NY",
"Birthdate": "April 4, 1965",
"photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg",
"wife": "Susan Downey",
"weight": 77.1,
"hasChildren": true,
"hasGreyHair": false,
"children": [
"Indio Falconer",
"Avri Roel",
"Exton Elias"
]
}
]
}
JSON
{
"Actors": [
{
"name": "Tom Cruise",
"age": 56,
"Born At": "Syracuse, NY",
"Birthdate": "July 3, 1962",
"photo": "https://jsonformatter.org/img/tom-cruise.jpg",
"wife": null,
"weight": 67.5,
"hasChildren": true,
"hasGreyHair": false,
"children": [
"Suri",
"Isabella Jane",
"Connor"
]
},
{
"name": "Robert Downey Jr.",
"age": 53,
"Born At": "New York City, NY",
"Birthdate": "April 4, 1965",
"photo": "https://jsonformatter.org/img/Robert-Downey-Jr.jpg",
"wife": "Susan Downey",
"weight": 77.1,
"hasChildren": true,
"hasGreyHair": false,
"children": [
"Indio Falconer",
"Avri Roel",
"Exton Elias"
]
}
]
}
JSON

class Actor
include JSON::Serializable
Expand Down
2 changes: 1 addition & 1 deletion spec/model/nested_query_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module NestedQuerySpec
INSERT INTO releases VALUES (1, 1, 'Video Release');
INSERT INTO topics VALUES (1, 1, 'foo');
INSERT INTO topics VALUES (2, 1, 'bar');
SQL
SQL
.split(";").each do |qry|
execute(qry)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def initdb
clear_secondary_spec_db.exec(
<<-SQL
CREATE TABLE models_post_stats (id serial PRIMARY KEY, post_id INTEGER);
SQL
SQL
)

Clear::SQL.init("postgres://#{postgres_user}:#{postgres_password}@#{postgres_host}/clear_spec")
Expand Down
22 changes: 11 additions & 11 deletions spec/views/view_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ module ViewSpec
SELECT room_id, day
FROM year_days
CROSS JOIN rooms
SQL
SQL
end

Clear::View.register :rooms do |view|
view.query <<-SQL
SELECT room.id as room_id
FROM generate_series(1, 4) AS room(id)
SQL
SELECT room.id as room_id
FROM generate_series(1, 4) AS room(id)
SQL
end

Clear::View.register :year_days do |view|
view.query <<-SQL
SELECT date.day::date as day
FROM generate_series(
date_trunc('day', NOW()),
date_trunc('day', NOW() + INTERVAL '364 days'),
INTERVAL '1 day'
) AS date(day)
SQL
SELECT date.day::date as day
FROM generate_series(
date_trunc('day', NOW()),
date_trunc('day', NOW() + INTERVAL '364 days'),
INTERVAL '1 day'
) AS date(day)
SQL
end

Clear::Migration::Manager.instance.reinit!
Expand Down
2 changes: 1 addition & 1 deletion src/clear/extensions/full_text_searchable/migration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Clear::Migration::FullTextSearchableOperation < Clear::Migration::Operatio
return new;
end
$$ LANGUAGE plpgsql;
SQL
SQL

cr_tr = <<-SQL
CREATE TRIGGER #{trigger_name} BEFORE INSERT OR UPDATE
Expand Down
4 changes: 2 additions & 2 deletions src/clear/migration/manager.cr
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ class Clear::Migration::Manager
unless @loaded
Clear::SQL.execute <<-SQL
CREATE TABLE IF NOT EXISTS __clear_metadatas ( metatype text NOT NULL, value text NOT NULL );
SQL
SQL

Clear::SQL.execute <<-SQL
CREATE UNIQUE INDEX IF NOT EXISTS __clear_metadatas_idx ON __clear_metadatas (metatype, value);
SQL
SQL

load_existing_migrations
ensure_unicity!
Expand Down

0 comments on commit a680f61

Please sign in to comment.