@@ -769,9 +769,9 @@ module Lustra::Model
769769 end
770770
771771 {% for j in [" left" , " right" , " full_outer" , " inner" ] % }
772- # {{j.id.upcase}} JOIN using association name (auto-detects join conditions)
773- def {{j.id}}_join (association : Lustra ::SQL ::Symbolic , lateral = false )
774- auto_join_association(association, :{{j.id}}, lateral)
772+ # {{ j.id.upcase }} JOIN using association name (auto-detects join conditions)
773+ def {{ j .id }}_join(association : Lustra ::SQL ::Symbolic , lateral = false )
774+ auto_join_association(association, :{{ j.id }}, lateral)
775775 end
776776 {% end % }
777777
@@ -780,21 +780,21 @@ module Lustra::Model
780780 {% begin % }
781781 case association.to_s
782782 {% for name, settings in T ::RELATIONS % }
783- when " {{name}}"
783+ when " {{ name }}"
784784 {% if settings[:relation_type ] == :has_many % }
785785 # has_many :posts => posts.user_id = users.id
786786 % foreign_key =
787787 {% if settings[:foreign_key ] % }
788- " {{settings[:foreign_key]}}"
788+ " {{ settings[:foreign_key] }}"
789789 {% else % }
790790 T .table.to_s.singularize + " _id"
791791 {% end % }
792792
793- % relation_table = {{settings[:type ]}}.table
793+ % relation_table = {{ settings[:type ] }}.table
794794
795795 % primary_key =
796796 {% if settings[:primary_key ] % }
797- " {{settings[:primary_key]}}"
797+ " {{ settings[:primary_key] }}"
798798 {% else % }
799799 T .__pkey__
800800 {% end % }
@@ -805,17 +805,17 @@ module Lustra::Model
805805 # has_one :info => user_infos.user_id = users.id
806806 % foreign_key =
807807 {% if settings[:foreign_key ] % }
808- " {{settings[:foreign_key]}}"
808+ " {{ settings[:foreign_key] }}"
809809 {% else % }
810810 T .table.to_s.singularize + " _id"
811811 {% end % }
812812
813813 # Get the table name from the type (handling nilable like UserInfo?)
814- % relation_table = {{settings[:type ].stringify.gsub(/\s *\|\s *Nil/ , " " ).gsub(/\s *\|\s *::Nil/ , " " ).id}}.table
814+ % relation_table = {{ settings[:type ].stringify.gsub(/\s *\|\s *Nil/ , " " ).gsub(/\s *\|\s *::Nil/ , " " ).id }}.table
815815
816816 % primary_key =
817817 {% if settings[:primary_key ] % }
818- " {{settings[:primary_key]}}"
818+ " {{ settings[:primary_key] }}"
819819 {% else % }
820820 T .__pkey__
821821 {% end % }
@@ -826,13 +826,13 @@ module Lustra::Model
826826 # belongs_to :user => posts.user_id = users.id
827827 % foreign_key =
828828 {% if settings[:foreign_key ] % }
829- " {{settings[:foreign_key]}}"
829+ " {{ settings[:foreign_key] }}"
830830 {% else % }
831- " {{name}}_id"
831+ " {{ name }}_id"
832832 {% end % }
833833
834- % relation_table = {{settings[:type ]}}.table
835- % primary_key = {{settings[:type ]}}.__pkey__
834+ % relation_table = {{ settings[:type ] }}.table
835+ % primary_key = {{ settings[:type ] }}.__pkey__
836836
837837 condition = " #{ Lustra ::SQL .escape(T .table)} .#{ Lustra ::SQL .escape(% foreign_key)} = #{ Lustra ::SQL .escape(% relation_table)} .#{ Lustra ::SQL .escape(% primary_key)} "
838838 join(Lustra ::SQL .escape(% relation_table), type , condition, lateral)
@@ -842,24 +842,24 @@ module Lustra::Model
842842 # 1. JOIN posts ON posts.user_id = users.id
843843 # 2. JOIN categories ON posts.category_id = categories.id
844844
845- % through_table = {{settings[:through ]}}.table
845+ % through_table = {{ settings[:through ] }}.table
846846
847847 % own_key =
848848 {% if settings[:own_key ] % }
849- " {{settings[:own_key]}}"
849+ " {{ settings[:own_key] }}"
850850 {% else % }
851851 T .table.to_s.singularize + " _id"
852852 {% end % }
853853
854854 % through_key =
855855 {% if settings[:foreign_key ] % }
856- " {{settings[:foreign_key]}}"
856+ " {{ settings[:foreign_key] }}"
857857 {% else % }
858- {{settings[:type ]}}.table.to_s.singularize + " _id"
858+ {{ settings[:type ] }}.table.to_s.singularize + " _id"
859859 {% end % }
860860
861- % final_table = {{settings[:type ]}}.table
862- % final_pkey = {{settings[:type ]}}.__pkey__
861+ % final_table = {{ settings[:type ] }}.table
862+ % final_pkey = {{ settings[:type ] }}.__pkey__
863863
864864 # First join: through table
865865 through_condition = " #{ Lustra ::SQL .escape(% through_table)} .#{ Lustra ::SQL .escape(% own_key)} = #{ Lustra ::SQL .escape(T .table)} .#{ Lustra ::SQL .escape(T .__pkey__)} "
0 commit comments