From eda20ecca511560b8bc9ec3734a3d2e7c35edbb3 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Thu, 13 Feb 2025 13:16:06 +0800 Subject: [PATCH] style: improve whitespace in SQL join syntax - Adjusted join statement in SQLite and PostgreSQL - Ensure consistent use of whitespace for better readability This change improves code clarity without changing any query behavior, making it easier for future developers to maintain and read the SQL join conditions. --- app/models/city.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/city.rb b/app/models/city.rb index 8f5e73f..4d7f95b 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -42,14 +42,14 @@ class City < ApplicationRecord # 根据数据库类型构建不同的查询 base_query = if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite" joins(<<-SQL.squish) - LEFT JOIN ahoy_events ON + LEFT JOIN ahoy_events ON#{' '} json_extract(ahoy_events.properties, '$.city_id') = cities.id AND json_extract(ahoy_events.properties, '$.event_type') = 'city_view' AND ahoy_events.time > '#{start_time}' SQL else joins(<<-SQL.squish) - LEFT JOIN ahoy_events ON + LEFT JOIN ahoy_events ON#{' '} (ahoy_events.properties::jsonb->>'city_id')::integer = cities.id AND ahoy_events.properties::jsonb->>'event_type' = 'city_view' AND ahoy_events.time > '#{start_time}'