Skip to content

Commit

Permalink
Fix schema dump of continuous aggregate when no refresh policies are …
Browse files Browse the repository at this point in the history
…defined (#68)
  • Loading branch information
spohlenz authored Jul 8, 2024
1 parent 88c5cfa commit ac919e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/timescaledb/schema_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ def timescale_continuous_aggregates(stream)
interval = timescale_interval(refresh_policy.schedule_interval)
end_offset = timescale_interval(refresh_policy.config["end_offset"])
start_offset = timescale_interval(refresh_policy.config["start_offset"])
%(refresh_policies: { start_offset: "#{start_offset}", end_offset: "#{end_offset}", schedule_interval: "#{interval}"})
%(refresh_policies: { start_offset: "#{start_offset}", end_offset: "#{end_offset}", schedule_interval: "#{interval}"}, )
else
""
end

with_clause_opts = "materialized_only: #{aggregate[:materialized_only]}, finalized: #{aggregate[:finalized]}"
stream.puts <<~AGG.indent(2)
create_continuous_aggregate("#{aggregate.view_name}", <<-SQL, #{refresh_policies_opts}, #{with_clause_opts})
create_continuous_aggregate("#{aggregate.view_name}", <<-SQL, #{refresh_policies_opts}#{with_clause_opts})
#{aggregate.view_definition.strip.gsub(/;$/, '')}
SQL
AGG
Expand Down
1 change: 1 addition & 0 deletions spec/timescaledb/schema_dumper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
expect(dump).to include 'create_continuous_aggregate("event_counts"'
expect(dump).to include 'materialized_only: true, finalized: true'

expect(dump).not_to include ', ,'
expect(dump).not_to include 'create_view "event_counts"' # Verify Scenic ignored this view
expect(dump).to include 'create_view "searches", sql_definition: <<-SQL' if defined?(Scenic)

Expand Down

0 comments on commit ac919e5

Please sign in to comment.